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

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

?? stream.c

?? 從大量的wince源代碼中剝離出的fat文件系統源代碼.移植性非常高. 里面帶有source i.rar
?? 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麻豆果冻| 欧美一级黄色片| 欧美韩国日本综合| 日本vs亚洲vs韩国一区三区二区 | 欧美日韩一级片在线观看| 亚洲精品一区二区三区影院| 亚洲一区二区三区在线| 国产综合色视频| 欧美放荡的少妇| 亚洲影院久久精品| a亚洲天堂av| 亚洲国产精品激情在线观看| 蜜桃视频一区二区| 欧美日韩国产三级| 一区二区三区资源| 成人夜色视频网站在线观看| 精品国产区一区| 日韩黄色片在线观看| 欧美综合久久久| 亚洲精品欧美在线| av一区二区三区四区| 国产欧美精品一区二区色综合| 青青草伊人久久| 7799精品视频| 视频在线在亚洲| 欧美另类高清zo欧美| 亚洲午夜电影网| 91国产福利在线| 亚洲一二三四在线| 欧美三级电影在线观看| 一区二区三区不卡视频在线观看 | 日本麻豆一区二区三区视频| 欧美视频你懂的| 亚洲第一电影网| 欧美久久婷婷综合色| 婷婷成人激情在线网| 91精品综合久久久久久| 日产国产高清一区二区三区 | 91亚洲国产成人精品一区二三| 中文文精品字幕一区二区| 国产成人精品三级| 国产精品久线在线观看| 91热门视频在线观看| 亚洲一二三四久久| 日韩欧美在线123| 经典一区二区三区| 国产精品亲子伦对白| 9色porny自拍视频一区二区| 亚洲欧美色图小说| 欧美色图一区二区三区| 日韩精品电影一区亚洲| 26uuu另类欧美| 欧美亚洲精品一区| 日韩综合小视频| 日韩一区二区在线播放| 国产一区二区三区四区在线观看| 久久久久久亚洲综合| 91亚洲男人天堂| 午夜国产不卡在线观看视频| 欧美成人三级在线| 99久久综合99久久综合网站| 亚洲国产日韩a在线播放性色| 91精品国产91久久久久久一区二区| 狠狠色丁香婷综合久久| 国产精品国产馆在线真实露脸| 欧洲激情一区二区| 久草在线在线精品观看| 亚洲少妇30p| 88在线观看91蜜桃国自产| 国产91精品精华液一区二区三区| 一区二区三区中文免费| 欧美精品一区二区三区一线天视频| 成人丝袜18视频在线观看| 婷婷国产在线综合| 国产精品久久久爽爽爽麻豆色哟哟| 欧美性猛片xxxx免费看久爱| 紧缚捆绑精品一区二区| 亚洲男人天堂av网| 精品国产乱码久久久久久蜜臀| 99热这里都是精品| 激情亚洲综合在线| 丁香亚洲综合激情啪啪综合| 久久一夜天堂av一区二区三区| 久久精品国产亚洲高清剧情介绍 | 91精品国产综合久久精品性色| 亚洲成a人在线观看| 欧美日韩精品是欧美日韩精品| 亚洲地区一二三色| 日韩天堂在线观看| 国产精品亚洲一区二区三区妖精| 国产欧美精品一区| 99久久免费视频.com| 夜夜亚洲天天久久| 欧美一级欧美三级| 国产成人综合网| 最新国产の精品合集bt伙计| 在线观看不卡视频| 免费成人av资源网| 国产精品久久久久久久久图文区| 91视频www| 蜜臀av一区二区三区| 亚洲国产精品99久久久久久久久| 日本高清视频一区二区| 日日摸夜夜添夜夜添精品视频| 精品久久久久久久久久久久久久久 | 日本一二三不卡| 日本伦理一区二区| 狠狠色丁香久久婷婷综合_中| 国产精品午夜久久| 欧美日韩另类一区| 国产伦精一区二区三区| 亚洲精品福利视频网站| 日韩欧美一级精品久久| thepron国产精品| 日韩成人免费在线| 综合色天天鬼久久鬼色| 欧美一区二区三区色| 99精品视频在线播放观看| 日韩电影在线看| 亚洲欧美成人一区二区三区| 日韩欧美卡一卡二| 一本一本大道香蕉久在线精品| 蜜桃av噜噜一区| 一区二区三区av电影| 欧美国产精品中文字幕| 这里只有精品视频在线观看| kk眼镜猥琐国模调教系列一区二区 | 亚洲国产成人自拍| 日韩欧美激情四射| 欧美三级日本三级少妇99| 99久久精品国产一区二区三区| 精品无人码麻豆乱码1区2区| 亚洲国产精品一区二区久久| 国产无一区二区| 免费高清不卡av| 国产成人在线影院| 91麻豆自制传媒国产之光| 欧洲视频一区二区| 9191成人精品久久| 国产亚洲综合在线| 亚洲欧洲综合另类在线 | 国产日韩高清在线| 一区二区三区国产精品| 日本 国产 欧美色综合| 国产成人精品免费在线| 在线看日韩精品电影| 日韩午夜电影在线观看| 国产精品少妇自拍| 亚洲成人免费电影| 国产精品正在播放| 久久久久久久精| 久久久久亚洲综合| 久久嫩草精品久久久精品一| 欧美xxxxx裸体时装秀| 日韩欧美国产精品一区| 日韩区在线观看| 2021久久国产精品不只是精品| 欧美大片一区二区| 久久久综合视频| 欧美国产一区在线| 亚洲视频网在线直播| 亚洲你懂的在线视频| 亚洲高清免费在线| 日韩精品一二三| 国产在线精品一区二区不卡了 | 久久国产精品露脸对白| 久久成人久久鬼色| 国产成人小视频| 91丝袜呻吟高潮美腿白嫩在线观看| 99国产精品久久久久久久久久久| 99久久99精品久久久久久 | 日韩精品亚洲专区| 国产一区欧美日韩| av不卡在线观看| 欧美日韩国产一级二级| 日韩一本二本av| 国产亚洲午夜高清国产拍精品| 国产精品久久久久影院| 伊人开心综合网| 日日噜噜夜夜狠狠视频欧美人 | 国产精品传媒入口麻豆| 亚洲另类色综合网站| 日韩av一区二区在线影视| 国产一区二区主播在线| 日本韩国一区二区三区| 日韩亚洲欧美综合| 亚洲视频在线一区观看| 人人爽香蕉精品| 97精品久久久久中文字幕 | 国产乱国产乱300精品| av高清久久久| 欧美mv和日韩mv的网站| 日韩毛片在线免费观看| 青青草原综合久久大伊人精品优势| 成人免费视频一区| 91麻豆精品国产91| 亚洲乱码国产乱码精品精可以看| 蜜桃视频第一区免费观看| av网站一区二区三区|