亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stream.c

?? 從大量的wince源代碼中剝離出的fat文件系統源代碼。移植性非常高。 微軟的代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
/*++


Module Name:

    stream.c

Abstract:

    This file contains routines for manipulating streams.

Revision History:

--*/

#include "fatfs.h"


/*  OpenStream - Open/create stream
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      clusFirst - first cluster of stream (the search criteria)
 *      psid - pointer to SID, NULL if none
 *      pstmParent - pointer to parent DSTREAM (NULL if none/unknown)
 *      pdi - pointer to DIRINFO (NULL if none/unknown)
 *      dwFlags - one or more OPENSTREAM_* flags (eg, OPENSTREAM_CREATE, OPENSTREAM_REFRESH)
 *
 *  EXIT
 *      pointer to DSTREAM if successful (and critical section left held),
 *      NULL if not (ie, out of memory)
 *
 *  NOTES
 *      If clusFirst is UNKNOWN_CLUSTER, then psid becomes the search criteria.
 *
 *      Streams for data that is not cluster-mapped (eg, FAT, root directory)
 *      must be completely contiguous;  their RUN info must be set to match
 *      the size of the stream, so that ReadStream will always call directly
 *      to ReadStreamBuffer without attempting to call UnpackRun (which knows
 *      only how to deal with cluster-mapped data).
 */

PDSTREAM OpenStream(PVOLUME pvol, DWORD clusFirst, PDSID psid, PDSTREAM pstmParent, PDIRINFO pdi, DWORD dwFlags)
{
    PDSTREAM pstm;

    // Assert that at least one search criteria appears valid

    ASSERT(clusFirst != UNKNOWN_CLUSTER? TRUE : (int)psid);

    EnterCriticalSection(&pvol->v_csStms);

    // If the caller wants to create a private stream, then skip the search

    if ((dwFlags & (OPENSTREAM_CREATE|OPENSTREAM_PRIVATE)) != (OPENSTREAM_CREATE|OPENSTREAM_PRIVATE)) {

        for (pstm = pvol->v_dlOpenStreams.pstmNext; pstm != (PDSTREAM)&pvol->v_dlOpenStreams; pstm = pstm->s_dlOpenStreams.pstmNext) {

            if (!(pstm->s_flags & STF_PRIVATE) != !(dwFlags & OPENSTREAM_PRIVATE))
                continue;

            if (clusFirst != UNKNOWN_CLUSTER &&
                    pstm->s_clusFirst == clusFirst ||
                clusFirst == UNKNOWN_CLUSTER &&
                    pstm->s_sid.sid_clusDir == psid->sid_clusDir && pstm->s_sid.sid_ordDir == psid->sid_ordDir) {

                ASSERT(pstm->s_refs != 0);
                goto init;
            }
        }
    }

    // The requested stream is not open.  Bail if the volume is unmounted and
    // has not yet been remounted or recycled, or if the volume is fine and we
    // simply cannot allocate memory for a new stream.

    if (!(dwFlags & OPENSTREAM_CREATE) ||
        (pvol->v_flags & (VOLF_UNMOUNTED | VOLF_REMOUNTED | VOLF_RECYCLED)) == VOLF_UNMOUNTED ||
        !(pstm = LocalAlloc(LPTR, sizeof(DSTREAM)))) {

        LeaveCriticalSection(&pvol->v_csStms);
        return NULL;
    }
    DEBUGALLOC(sizeof(DSTREAM));

    InitializeCriticalSection(&pstm->s_cs);
    DEBUGALLOC(DEBUGALLOC_CS);

    pstm->s_pvol = pvol;
    pstm->s_flags = STF_VOLUME;

    pstm->s_clusFirst = clusFirst;
    if (psid)
        pstm->s_sid = *psid;

    pstm->s_blkDir = INVALID_BLOCK;

    RewindStream(pstm, INVALID_POS);

    // If the caller wanted a PRIVATE root stream, then we have to clone
    // the appropriate fields from the volume's root stream.

    if (dwFlags & OPENSTREAM_PRIVATE) {
        ASSERT(clusFirst);
        pstm->s_flags |= STF_PRIVATE;
        if (clusFirst == ROOT_PSEUDO_CLUSTER) {
            pstm->s_run = pvol->v_pstmRoot->s_run;
            pstm->s_size = pvol->v_pstmRoot->s_size;
        }
    }

    InitList((PDLINK)&pstm->s_dlOpenHandles);
    AddItem((PDLINK)&pvol->v_dlOpenStreams, (PDLINK)&pstm->s_dlOpenStreams);

    // Common code for both cases (old stream, new stream).  An old
    // stream might have been created with minimal information by a thread
    // for its own minimal purposes, but if another thread requests the same
    // stream and provides more detailed information, we need to record/update
    // that information, so that the stream will satisfy both threads'
    // purposes.

  init:
    pstm->s_refs++;

    LeaveCriticalSection(&pvol->v_csStms);
    EnterCriticalSection(&pstm->s_cs);

    
    if (!pstm->s_clusFirst || pstm->s_clusFirst == UNKNOWN_CLUSTER)
        pstm->s_clusFirst = clusFirst;

    if (psid) {
        if (!pstm->s_sid.sid_clusDir || pstm->s_sid.sid_clusDir == UNKNOWN_CLUSTER) {
            pstm->s_sid = *psid;
        }
    }

    if (pdi && (!(pstm->s_flags & STF_INIT) || (dwFlags & OPENSTREAM_REFRESH))) {

        // Whenever pdi is provided, pstmParent must be provided too.

        ASSERT(pstmParent);

        // We save the OEM name in the DIRENTRY for validation during handle
        // regeneration.

        memcpy(pstm->s_achOEM, pdi->di_pde->de_name, sizeof(pdi->di_pde->de_name));
        pstm->s_attr = pdi->di_pde->de_attr;
        pstm->s_size = (pdi->di_pde->de_attr & ATTR_DIR_MASK) == ATTR_DIRECTORY? MAX_DIRSIZE : pdi->di_pde->de_size;

        pstm->s_sidParent = pstmParent->s_sid;
        pstm->s_cwPath = pdi->di_cwName + pstmParent->s_cwPath + 1;

        // We should never need to query or update a DIRECTORY stream's
        // DIRENTRY however (or the date/time values inside it).

        if (!(pstm->s_attr & ATTR_DIRECTORY)) {

            pstm->s_flags &= ~STF_VOLUME;

            // As an optimization, remember the physical block and offset
            // within that block of the stream's DIRENTRY.  This will save
            // us from having to perform a OpenStream/FindNext combination
            // in CommitStream whenever we need to update a stream's DIRENTRY.

            // For that information to be available and valid, however, all
            // callers must have a "lock" on the parent stream, and the stream
            // in turn must have a "current buffer".

            ASSERT(OWNCRITICALSECTION(&pstmParent->s_cs));
            ASSERT(pstmParent->s_pbufCur);

            if (pstmParent->s_pbufCur) {
                pstm->s_blkDir = pstmParent->s_pbufCur->b_blk;
                pstm->s_offDir = (PBYTE)pdi->di_pde - pstmParent->s_pbufCur->b_pdata;
            }

            // DOSTimeToFileTime can fail because it doesn't range-check any of
            // the date/time values in the directory entry;  it just pulls them apart
            // and calls SystemTimeToFileTime, which won't initialize the FILETIME
            // structure if there's an error.  Fortunately, all the FILETIMEs have been
            // zero-initialized, because that's what the Win32 API dictates when a time
            // is unknown/not supported.

            DOSTimeToFileTime(pdi->di_pde->de_createdDate,
                              pdi->di_pde->de_createdTime,
                              pdi->di_pde->de_createdTimeMsec, &pstm->s_ftCreate);

            DOSTimeToFileTime(pdi->di_pde->de_date, pdi->di_pde->de_time, 0, &pstm->s_ftWrite);

            DOSTimeToFileTime(pdi->di_pde->de_lastAccessDate, 0, 0, &pstm->s_ftAccess);
        }

        pstm->s_flags |= STF_INIT;

    }

#ifdef DEBUG
    else {
        if (clusFirst == FAT_PSEUDO_CLUSTER)
            memcpy(pstm->s_achOEM, "<FAT>", 5);
        else if (clusFirst == ROOT_PSEUDO_CLUSTER)
            memcpy(pstm->s_achOEM, "<ROOT>", 6);
    }
#endif

    DEBUGMSGW(ZONE_STREAMS,(DBGTEXTW("FATFS!OpenStream %s stream 0x%08x for '%.11hs'\n"), pstm->s_refs > 1? TEXTW("opened") : TEXTW("created"), pstm, pstm->s_achOEM));
    return pstm;
}




DWORD CloseStream(PDSTREAM pstm)
{
    DWORD dwError = ERROR_SUCCESS;

    if (pstm) {

        PVOLUME pvol = pstm->s_pvol;

        ASSERT(OWNCRITICALSECTION(&pstm->s_cs));

        // When there is no lazy-writer, CloseStream may be the last opportunity we
        // have to visit buffers for this stream, so we need to call CommitStream(TRUE),
        // lest any buffers languish dirty indefinitely -- which would in turn increase
        // the chances of the media appearing inconsistent if it was removed unexpectedly.
        // Of course, we warn the user to put the media back in when that happens, but
        // it's best to prevent such warnings in the first place.
        //
        // When there IS a lazy-writer, we can let it take care of buffers for path-based
        // and volume-based streams, and invoke CommitStream(TRUE) only for handle-based streams.
        //
        // This logic is somewhat arbitrary -- we could always call CommitStream(FALSE) -- but
        // since files are often closed as a result of some explicit user action, and since such
        // actions often precede unexpected media removal, I'm not exactly being paranoid for
        // no reason here.... -JTP

        dwError = CommitStream(pstm, TRUE);

        ASSERT(!(pstm->s_flags & STF_BUFCURHELD) && pstm->s_pbufCur == NULL);

        LeaveCriticalSection(&pstm->s_cs);
        EnterCriticalSection(&pvol->v_csStms);

        if (--pstm->s_refs == 0) {
            DEBUGMSG(ZONE_STREAMS,(DBGTEXT("FATFS!CloseStream destroying stream 0x%08x for '%.11hs'\n"), pstm, pstm->s_achOEM));
            RemoveItem((PDLINK)&pstm->s_dlOpenStreams);
            DEBUGFREE(DEBUGALLOC_CS);
            DeleteCriticalSection(&pstm->s_cs);
            DEBUGFREE(sizeof(DSTREAM));
            VERIFYNULL(LocalFree(pstm));
        }

        LeaveCriticalSection(&pvol->v_csStms);
    }
    return dwError;
}


/*  CommitStream - flush buffers (and DIRENTRY) associated with this stream
 *
 *  ENTRY
 *      pstm - pointer to DSTREAM
 *      fAll - TRUE to commit all stream buffers, FALSE to just update DIRENTRY
 *
 *  EXIT
 *      ERROR_SUCCESS (0) if successful, non-zero if not
 *
 *  NOTES
 *      As an optimization, OpenStream remembers the physical block and
 *      within that block of the stream's DIRENTRY.  This will save
 *      us from having to perform a OpenStream/FindNext combination
 *      in CommitStream every time we need to update a stream's DIRENTRY.
 *
 *      As an added optimization, OpenStream also records the parent's OID
 *      if a parent stream was specified when the stream was created.  Thus,
 *      CommitStream has all the information it needs to post a CEOID_CHANGED
 *      message if the stream changed, again without having to open the
 *      parent stream.
 */

DWORD CommitStream(PDSTREAM pstm, BOOL fAll)
{
    DWORD dwError = ERROR_SUCCESS;

    ASSERT(OWNCRITICALSECTION(&pstm->s_cs));

    // NOTE: CommitStream refuses to update an unmounted stream because
    // the volume the stream was associated with may have been unmounted and
    // RECYCLED, in which case this stream is dead and its directory entry
    // can never be safely updated.  The stream will eventually go away when
    // all the apps with handles to the stream close their handles.

    if (!(pstm->s_flags & STF_UNMOUNTED)) {

        // Commit all dirty buffers associated with this stream.  There
        // is no return value from this function.  Any held stream buffer will
        // be released as well.

        if (!fAll)
            dwError = ReleaseStreamBuffer(pstm, FALSE);
        else
            dwError = CommitAndReleaseStreamBuffers(pstm);

        // The rest of this is for non-FAT, non-root, non-directory
        // streams only (ie, streams with DIRENTRY's that should be updated).

        if (!(pstm->s_flags & STF_VOLUME)) {

            SYSTEMTIME stLocal;

            GetLocalTime(&stLocal);

            // A stream gets a new access time if it's a new day, unless
            // STF_ACCESS_TIME is set, in which case someone has already set a
            // specific access time.

            

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美韩国一区二区| 欧美无人高清视频在线观看| 91精品午夜视频| 水野朝阳av一区二区三区| 欧美三区免费完整视频在线观看| 亚洲影视资源网| 欧美情侣在线播放| 精品亚洲国产成人av制服丝袜 | 久久久久久久电影| 国产一区二区导航在线播放| 中文一区在线播放| caoporm超碰国产精品| 亚洲精品视频在线看| 欧美日韩国产成人在线免费| 六月婷婷色综合| 久久九九久久九九| 91免费版pro下载短视频| 亚洲电影视频在线| 精品国产百合女同互慰| 99久久99久久久精品齐齐| 亚洲一区在线播放| 日韩免费视频线观看| 波多野结衣亚洲一区| 亚洲成人一区在线| 久久伊99综合婷婷久久伊| 成人久久久精品乱码一区二区三区| 亚洲欧洲一区二区三区| 欧美福利视频导航| 成人免费看片app下载| 香港成人在线视频| 久久精品视频免费| 欧美系列在线观看| 粉嫩av亚洲一区二区图片| 日韩有码一区二区三区| 国产精品午夜久久| 91精品国产综合久久香蕉麻豆| 国产成人精品三级麻豆| 亚洲国产精品人人做人人爽| 26uuu久久天堂性欧美| 欧美亚洲免费在线一区| 国产福利一区二区三区视频| 亚洲电影一区二区三区| 国产精品久久久久久福利一牛影视| 欧美日韩国产精品成人| 成人黄色777网| 美女脱光内衣内裤视频久久网站| 中文字幕一区二区5566日韩| 日韩一级在线观看| 在线观看91视频| 不卡电影一区二区三区| 精品制服美女久久| 日韩va亚洲va欧美va久久| 亚洲三级在线观看| 亚洲国产精品传媒在线观看| 日韩欧美的一区二区| 欧美午夜在线观看| 99精品在线观看视频| 国产精品亚洲综合一区在线观看| 日韩一区精品视频| 亚洲一区二区三区视频在线播放| 国产精品夫妻自拍| 久久精品视频网| 久久欧美中文字幕| 欧美va亚洲va在线观看蝴蝶网| 欧美三片在线视频观看| 在线观看欧美精品| 91亚洲精品久久久蜜桃网站 | 国产蜜臀97一区二区三区| 欧美成人欧美edvon| 欧美久久一二三四区| 欧美系列在线观看| 欧美午夜电影网| 欧美系列亚洲系列| 欧美性生活久久| 欧美午夜一区二区三区| 色婷婷亚洲精品| 色婷婷精品大在线视频| 色综合久久88色综合天天免费| 国产91富婆露脸刺激对白| 国产91精品久久久久久久网曝门| 国产在线精品免费av| 国产一区 二区 三区一级| 国产综合久久久久影院| 国产精品一二三四区| 国产成人免费在线观看| 国产成人午夜精品影院观看视频| 岛国一区二区在线观看| 不卡视频免费播放| 91国偷自产一区二区开放时间 | 国产精品自拍网站| 粉嫩绯色av一区二区在线观看 | 色欧美片视频在线观看| 色国产综合视频| 欧美人xxxx| 日韩欧美中文字幕制服| 久久久久久久免费视频了| 中文字幕免费不卡| 亚洲日穴在线视频| 五月综合激情婷婷六月色窝| 久久精品72免费观看| 国产精品一区二区你懂的| 成人精品在线视频观看| 日本精品视频一区二区三区| 欧美精品一卡两卡| 久久久99精品免费观看不卡| 自拍偷拍国产亚洲| 日韩综合小视频| 国产不卡视频一区二区三区| 91色乱码一区二区三区| 欧美日韩第一区日日骚| 久久久久一区二区三区四区| 中文字幕一区二区三区蜜月| 日欧美一区二区| 国产毛片精品视频| 在线观看视频一区二区| 2023国产精华国产精品| 亚洲天堂a在线| 久久精品国产一区二区| av男人天堂一区| 欧美老人xxxx18| 国产精品美女久久久久高潮| 香港成人在线视频| 成人福利视频在线看| 4438成人网| 综合久久久久综合| 国内精品在线播放| 欧美日韩国产中文| 中文字幕一区二区三| 久久99精品久久久久婷婷| 91美女在线看| 欧美精品一区二区高清在线观看| 亚洲精品日韩综合观看成人91| 韩国av一区二区三区在线观看| 欧洲精品一区二区| 国产欧美1区2区3区| 天天综合色天天综合色h| 9l国产精品久久久久麻豆| wwwwxxxxx欧美| 日本成人在线看| 色综合久久88色综合天天免费| 久久视频一区二区| 日韩av网站在线观看| 91免费观看视频| 国产精品蜜臀av| 韩国女主播一区二区三区| 69堂精品视频| 亚洲伊人伊色伊影伊综合网| 不卡一区二区中文字幕| 久久久天堂av| 久久精品国产在热久久| 91麻豆精品国产自产在线观看一区| 亚洲色图色小说| www.在线欧美| 日本一区二区三区国色天香| 韩国成人福利片在线播放| 欧美一级片在线看| 日韩一区精品视频| 欧美日韩综合色| 一区二区三区波多野结衣在线观看| 成人黄色电影在线| 亚洲国产精品成人综合| 国产成人av资源| 久久精品人人做人人爽人人| 国产一区二区三区精品视频| 精品久久久久久久久久久久久久久久久 | 777久久久精品| 天天综合日日夜夜精品| 欧美日韩在线三区| 亚洲成人自拍一区| 欧美日本国产视频| 日韩国产欧美在线播放| 在线综合+亚洲+欧美中文字幕| 婷婷国产在线综合| 日韩一区二区免费视频| 麻豆成人久久精品二区三区小说| 日韩一级大片在线| 精品综合免费视频观看| 国产网红主播福利一区二区| 国产老妇另类xxxxx| 国产精品少妇自拍| 97久久精品人人做人人爽50路| 一区二区三区四区在线免费观看 | 亚洲一区二区三区在线| 欧美精品粉嫩高潮一区二区| 免费在线看成人av| 精品成人免费观看| 成人av网站在线| 又紧又大又爽精品一区二区| 欧美日韩一二区| 美腿丝袜一区二区三区| 国产亚洲成aⅴ人片在线观看| 成人动漫一区二区在线| 亚洲一区二区三区中文字幕在线| 欧美另类videos死尸| 国内精品不卡在线| 亚洲欧美一区二区三区极速播放| 欧美视频第二页| 激情综合五月婷婷| 成人欧美一区二区三区黑人麻豆| 欧美日韩中文另类|