亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
99精品黄色片免费大全| 国产日韩欧美制服另类| 欧美精品一区二区三区蜜桃| 国产精品免费久久| 久久99久国产精品黄毛片色诱| 成人性生交大片免费看中文网站| 欧美日本在线一区| 亚洲女同ⅹxx女同tv| 韩国av一区二区| 91精品欧美综合在线观看最新| 亚洲欧洲日韩在线| 成人综合在线观看| 久久综合狠狠综合久久综合88| 视频一区二区中文字幕| 在线视频一区二区免费| 国产精品久久久久久久久免费相片 | 国产福利电影一区二区三区| 91精选在线观看| 亚洲一区视频在线观看视频| 91在线免费播放| 国产精品色噜噜| 东方欧美亚洲色图在线| 久久久影视传媒| 激情国产一区二区| 精品欧美乱码久久久久久 | 91久久人澡人人添人人爽欧美 | 精品一区二区三区香蕉蜜桃| 91麻豆精品国产91久久久使用方法| 久久成人免费电影| 欧美久久一二区| 视频一区二区三区在线| 欧美肥胖老妇做爰| 日韩精品一级二级| 欧美电影免费观看高清完整版| 日韩电影在线免费| 日韩欧美aaaaaa| 国产资源在线一区| 国产日韩高清在线| proumb性欧美在线观看| 亚洲色图欧美偷拍| 欧美天天综合网| 青青草视频一区| 欧美va亚洲va国产综合| 国产一区二区三区四区五区入口| 国产午夜三级一区二区三| 成人一区二区三区视频 | 国产传媒日韩欧美成人| 国产精品美女久久久久久2018| 99精品国产热久久91蜜凸| 一区二区三区国产精品| 7878成人国产在线观看| 国模冰冰炮一区二区| 国产精品视频免费| 欧美日韩精品三区| 国产综合色视频| 中文字幕欧美一| 欧美日韩亚洲高清一区二区| 毛片不卡一区二区| 国产精品网友自拍| 欧美亚洲图片小说| 精品在线观看免费| 专区另类欧美日韩| 日韩美一区二区三区| av亚洲精华国产精华| 五月开心婷婷久久| 欧美韩国日本不卡| 欧美色图12p| 国产成人亚洲综合色影视| 亚洲综合色区另类av| 欧美videos大乳护士334| 色综合一个色综合亚洲| 久久国产精品72免费观看| 国产日韩欧美不卡在线| 欧美精品日韩一区| 91女厕偷拍女厕偷拍高清| 青青草国产成人av片免费| 最新不卡av在线| 久久亚洲一区二区三区四区| 色婷婷激情久久| 顶级嫩模精品视频在线看| 视频一区视频二区在线观看| 亚洲欧美中日韩| 精品国产sm最大网站| 欧美天堂一区二区三区| 成人黄色网址在线观看| 黄色资源网久久资源365| 亚洲国产欧美另类丝袜| 国产精品剧情在线亚洲| 欧美xxxxx裸体时装秀| 欧美精品在线一区二区| 日本福利一区二区| 欧美精品电影在线播放| 不卡免费追剧大全电视剧网站| 日本不卡在线视频| 亚洲午夜在线视频| 亚洲三级视频在线观看| 国产精品入口麻豆九色| 久久综合色鬼综合色| 日韩一卡二卡三卡国产欧美| 91福利精品视频| 91小视频在线观看| 成人va在线观看| 成人中文字幕合集| 国产精品1区2区3区在线观看| 麻豆专区一区二区三区四区五区| 亚洲一区二区三区小说| 亚洲欧洲中文日韩久久av乱码| 国产精品美女视频| 欧美激情综合五月色丁香小说| 精品国产一区二区三区久久久蜜月| 91麻豆精品国产91久久久久久| 欧美欧美欧美欧美| 欧美日韩mp4| 欧美一卡二卡在线| 91精品国产综合久久精品| 欧美日韩一本到| 欧美精品在线一区二区三区| 欧美日韩国产综合久久| 欧美巨大另类极品videosbest| 欧美无砖专区一中文字| 在线精品国精品国产尤物884a| 欧美综合视频在线观看| 欧美乱妇15p| 日韩欧美123| 国产亚洲精品超碰| 亚洲欧洲精品一区二区精品久久久| 亚洲欧美一区二区不卡| 亚洲成av人综合在线观看| 午夜电影网一区| 老司机午夜精品| 国产精品小仙女| 色欧美乱欧美15图片| 欧美浪妇xxxx高跟鞋交| 91精品婷婷国产综合久久竹菊| 欧美久久久久久蜜桃| 2019国产精品| 亚洲三级电影全部在线观看高清| 一区二区高清免费观看影视大全 | 久久精品国产99国产| 激情五月播播久久久精品| 国产精品一区一区三区| 91在线视频免费观看| 欧美美女直播网站| 精品国产一区二区三区不卡| 亚洲欧洲av一区二区三区久久| 亚洲综合免费观看高清完整版| 蜜臀久久久99精品久久久久久| 国产一区二区福利视频| 91在线视频免费91| 欧美一级国产精品| 国产精品国产三级国产aⅴ入口| 亚洲国产日韩综合久久精品| 九九精品视频在线看| 99久久99久久精品免费看蜜桃| 91麻豆精品国产自产在线| 欧美国产日韩在线观看| 亚洲高清久久久| 国产91对白在线观看九色| 欧美日韩精品一区视频| 国产欧美视频一区二区三区| 亚洲国产综合在线| 成人精品免费视频| 日韩欧美激情四射| 亚洲精品国产一区二区精华液| 精品一二三四区| 欧美日韩一二区| 中文字幕一区av| 国产综合久久久久久鬼色 | 一区二区三区在线观看视频 | 99re成人精品视频| 欧美精品一区二区在线观看| 夜夜操天天操亚洲| 成人国产亚洲欧美成人综合网 | 久久久99免费| 99精品久久免费看蜜臀剧情介绍| 欧美一区二区在线免费观看| 中文字幕一区二区三区在线不卡 | 亚洲激情自拍视频| 丁香六月综合激情| 久久久久久毛片| 日韩精品福利网| 色婷婷精品久久二区二区蜜臀av| 久久久影视传媒| 国产中文一区二区三区| 日韩一区二区三区视频| 亚洲123区在线观看| 91片黄在线观看| 亚洲精品水蜜桃| 91色在线porny| 综合久久久久综合| av在线综合网| 亚洲色欲色欲www在线观看| 丁香天五香天堂综合| 国产日韩欧美高清在线| 国产精品99久久久久久久vr| 久久先锋影音av鲁色资源网| 久久精品国产亚洲aⅴ| 日韩精品一区二区三区中文不卡 | 欧美二区乱c少妇| 天天影视色香欲综合网老头|