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

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

?? cache.c

?? 從大量的wince源代碼中剝離出的fat文件系統源代碼.移植性非常高. 里面帶有source i.rar
?? C
字號:
//
// 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:

    cache.c

Abstract:

    This file contains FAT file system path/name cache functions.

Revision History:

--*/

#include "fatfs.h"


#ifdef PATH_CACHING

/*  PathCacheCreate - Create a new entry in a volume's path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsPath - pointer to path
 *      len - length of path (ie, portion to cache)
 *      pstm - pointer to DSTREAM corresponding to path (other than root)
 *
 *  EXIT
 *      None.  If the entry can be added to the path cache, great;
 *      if not, oh well.
 *
 *  NOTES
 *      Pre-processed paths should include NEITHER a leading [back]slash
 *      NOR a trailing one (ie, only the characters inbetween).  Furthermore,
 *      callers should never try to cache the root;  it's pointless because
 *      the root stream is already persistent.
 *
 *      If the caller has NOT pre-processed the path according to the above
 *      rules, then he should pass len == 0 and we will take care of the
 *      rest.  In that case though, the path must be null-terminated.
 *
 *      Also, when streams are cached, their critical section is usually
 *      being held by the caller at the time.  So, after we take the *cache*
 *      critical section, it is important that we not attempt to take any
 *      *other* stream's critical section, since that could cause a deadlock.
 *
 *      This is why PathCacheDestroy has the option of returning the stream
 *      belonging to a destroyed cache entry;  if PathCacheDestroy was allowed
 *      to close its reference to the stream on the spot, it would have to
 *      briefly relinquish the *cache* critical section first, and we'd rather
 *      not do that in this particular function.
 */

void PathCacheCreate(PVOLUME pvol, PCWSTR pwsPath, int len, PDSTREAM pstm)
{
    PCACHE pcch;
    PDSTREAM pstmFree = NULL;

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

    if (pvol->v_flags & VOLF_UNMOUNTED)
        return;

    EnterCriticalSection(&pvol->v_csCaches);

    ASSERT(pvol->v_cCaches <= MAX_CACHE_PER_VOLUME && pstm != pvol->v_pstmRoot);

    // Cache this stream, if it isn't already cached

    if (!PathCacheFindStream(pvol, pstm)) {

        // If len <= 0, then the caller has an unprocessed null-terminated
        // path which we must calculate the length of;  in particular,
        // if len < 0, then -len is the number of elements to remove from the
        // end of the path being cached.

        if (len <= 0) {
            len = PathCacheLength(&pwsPath, -len);
            if (len <= 0)
                goto exit;
            if (pstm->s_cwPath == 0)
                pstm->s_cwPath = len + 1;
        }

#ifdef DEMAND_PAGING_DEADLOCKS
        // If the stream we've opened can currently be demand-paged,
        // then we MUST temporarily release the stream's CS around these
        // memory manager calls.

        if (pstm->s_flags & STF_DEMANDPAGED)
            LeaveCriticalSection(&pstm->s_cs);
#endif
        // If we've already got the (hard-coded) maximum number of cache
        // entries, then destroy the oldest one.  We don't free the stream
        // right away -- we wait until we've released the cache critical
        // section first, to avoid deadlocks.

        if (pvol->v_cCaches == MAX_CACHE_PER_VOLUME)
            pstmFree = PathCacheDestroy(pvol, pvol->v_dlCaches.pcchPrev, FALSE);

        // Now allocate a new entry.

        pcch = (PCACHE)LocalAlloc(LPTR, sizeof(CACHE)+(len+1-ARRAYSIZE(pcch->c_awcPath))*sizeof(WCHAR));

#ifdef DEMAND_PAGING_DEADLOCKS
        if (pstm->s_flags & STF_DEMANDPAGED)
            EnterCriticalSection(&pstm->s_cs);
#endif
        if (pcch) {

            DEBUGALLOC(pcch->c_cbAlloc = sizeof(CACHE)+(len+1-ARRAYSIZE(pcch->c_awcPath))*sizeof(WCHAR));

            pstm->s_refs++;
            pcch->c_pstm = pstm;
            pcch->c_flags = CACHE_PATH;

            pvol->v_cCaches++;
            AddItem((PDLINK)&pvol->v_dlCaches, (PDLINK)&pcch->c_dlink);

            __try {
                memcpy(pcch->c_awcPath, pwsPath, len*sizeof(WCHAR));
                pcch->c_cwPath = len;
            }
            __except (EXCEPTION_EXECUTE_HANDLER) {
                ;
            }
        }
    }
  exit:
    LeaveCriticalSection(&pvol->v_csCaches);

    if (pstmFree) {

#ifdef DEMAND_PAGING_DEADLOCKS
        if (pstm->s_flags & STF_DEMANDPAGED)
            LeaveCriticalSection(&pstm->s_cs);
#endif

        EnterCriticalSection(&pstmFree->s_cs);
        CloseStream(pstmFree);

#ifdef DEMAND_PAGING_DEADLOCKS
        if (pstm->s_flags & STF_DEMANDPAGED)
            EnterCriticalSection(&pstm->s_cs);
#endif
    }
}


/*  PathCacheSearch - Search for a path in a volume's path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      ppwsPath - address of pointer to path
 *
 *  EXIT
 *      Pointer to DSTREAM if found, NULL if not
 *
 *  NOTES
 *      This will advance the caller's pwsPath up to the final
 *      [back]slash in the specified path.  Also, we don't bother with
 *      exception handling around the first bit of code because the only
 *      caller (OpenPath) already has a handler.
 */

PDSTREAM PathCacheSearch(PVOLUME pvol, PCWSTR *ppwsPath)
{
    int len;
    PCACHE pcch, pcchEnd;
    PCWSTR pwsPath = *ppwsPath, pwsPathEnd;
    PDSTREAM pstmreturn = NULL;

    // Determine the path length we need to compare.  To do so,
    // we must find the final [back]slash.

    if (!(pwsPathEnd = wcsrchr(pwsPath, TEXTW('\\'))) &&
        !(pwsPathEnd = wcsrchr(pwsPath, TEXTW('/'))))
        return NULL;

    len = pwsPathEnd - pwsPath;

    // We don't cache the root (not much point), so get out if that's
    // the case...

    if (len == 0)
        return NULL;

    EnterCriticalSection(&pvol->v_csCaches);

    __try {
        pcch = pvol->v_dlCaches.pcchNext;
        pcchEnd = (PCACHE)&pvol->v_dlCaches;

        while (pcch != pcchEnd) {

            if (len == pcch->c_cwPath && _wcsnicmp(pcch->c_awcPath, pwsPath, len) == 0) {

                PDSTREAM pstm = pcch->c_pstm;

                // Since this entry is a match, bump it up in the list

                RemoveItem((PDLINK)&pcch->c_dlink);
                AddItem((PDLINK)&pvol->v_dlCaches, (PDLINK)&pcch->c_dlink);

                *ppwsPath = pwsPath + len + 1;

                pstm->s_refs++;
                pstmreturn = pstm;
                break;
            }
            pcch = pcch->c_dlink.pcchNext;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ;
    }

    LeaveCriticalSection(&pvol->v_csCaches);
    if (pstmreturn) {
        EnterCriticalSection(&pstmreturn->s_cs);
    }
    return pstmreturn;
}


/*  PathCacheInvalidate - Invalidate all cached paths containing this path
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsPath - pointer to path to invalidate
 *
 *  EXIT
 *      TRUE if any cache entries were invalidated, FALSE if not
 */

BOOL PathCacheInvalidate(PVOLUME pvol, PCWSTR pwsPath)
{
    int len;
    BOOL fInvalidate;

    len = PathCacheLength(&pwsPath, 0);
    if (len == 0)
        return FALSE;

    fInvalidate = FALSE;

    EnterCriticalSection(&pvol->v_csCaches);

    __try {
        PCACHE pcch, pcchEnd;

        pcch = pvol->v_dlCaches.pcchNext;
        pcchEnd = (PCACHE)&pvol->v_dlCaches;

        while (pcch != pcchEnd) {

            if (len <= pcch->c_cwPath && _wcsnicmp(pcch->c_awcPath, pwsPath, len) == 0 &&
                (pcch->c_awcPath[len] == 0 || pcch->c_awcPath[len] == TEXTW('\\') || pcch->c_awcPath[len] == TEXTW('/'))) {
                PathCacheDestroy(pvol, pcch, TRUE);
                pcch = pvol->v_dlCaches.pcchNext;
                fInvalidate = TRUE;
                continue;
            }
            pcch = pcch->c_dlink.pcchNext;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ;
    }

    LeaveCriticalSection(&pvol->v_csCaches);

    return fInvalidate;
}


/*  PathCacheLength - Calculate the length of a path
 *
 *  ENTRY
 *      ppwsPath - pointer to pointer to path
 *      celRemove - count of elements to remove from end
 *
 *  EXIT
 *      length of path (leading and terminating slashes ignored);
 *      *ppwsPath is updated as well
 */

int PathCacheLength(PCWSTR *ppwsPath, int celRemove)
{
    int len;
    PCWSTR pwsEnd, pwsPath = *ppwsPath;

    // Ignore leading slash

    __try {
        if (*pwsPath == TEXTW('\\') || *pwsPath == TEXTW('/'))
            ++pwsPath;

        len = wcslen(pwsPath);
        if (len > 0) {

            pwsEnd = pwsPath + len - 1;

            // Ignore trailing slash

            if (*pwsEnd == TEXTW('\\') || *pwsEnd == TEXTW('/')) {
                pwsEnd--;
                len--;
            }

            while (celRemove > 0 && pwsEnd > pwsPath) {
                if (*pwsEnd == TEXTW('\\') || *pwsEnd == TEXTW('/'))
                    celRemove--;
                pwsEnd--;
                len--;
            }
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        len = 0;
    }
    *ppwsPath = pwsPath;
    return len;
}


/*  PathCacheFindStream - Search for specific stream in path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pstm - pointer to DSTREAM
 *
 *  EXIT
 *      Pointer to CACHE entry, NULL if none.  This function is really for
 *      internal use only.
 */

PCACHE PathCacheFindStream(PVOLUME pvol, PDSTREAM pstm)
{
    PCACHE pcch, pcchEnd;

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

    pcch = pvol->v_dlCaches.pcchNext;
    pcchEnd = (PCACHE)&pvol->v_dlCaches;

    while (pcch != pcchEnd) {
        if (pcch->c_pstm == pstm)
            return pcch;
        pcch = pcch->c_dlink.pcchNext;
    }
    return NULL;
}


/*  PathCacheDestroy - Free a specific path cache entry
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pcch - pointer to CACHE entry
 *      fClose - TRUE to close associated stream, FALSE to return
 *
 *  EXIT
 *      None.  This function is really for internal use only.
 */

PDSTREAM PathCacheDestroy(PVOLUME pvol, PCACHE pcch, BOOL fClose)
{
    PDSTREAM pstm = pcch->c_pstm;

    ASSERT(OWNCRITICALSECTION(&pvol->v_csCaches));

    pvol->v_cCaches--;
    RemoveItem((PDLINK)&pcch->c_dlink);

    DEBUGFREE(pcch->c_cbAlloc);
    VERIFYNULL(LocalFree((HLOCAL)pcch));

    if (fClose) {
        LeaveCriticalSection(&pvol->v_csCaches);
        EnterCriticalSection(&pstm->s_cs);
        CloseStream(pstm);
        EnterCriticalSection(&pvol->v_csCaches);
        return NULL;
    }
    return pstm;
}


/*  PathCacheDestroyAll - Free all path cache entries for a volume
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *
 *  EXIT
 *      None.  Calls PathCacheDestroy for each cache entry until the
 *      cache is empty.
 */

void PathCacheDestroyAll(PVOLUME pvol)
{
    PCACHE pcch, pcchEnd;

    EnterCriticalSection(&pvol->v_csCaches);

    pcchEnd = (PCACHE)&pvol->v_dlCaches;

    do {
        pcch = pvol->v_dlCaches.pcchNext;

        if (pcch == pcchEnd)
            break;

        PathCacheDestroy(pvol, pcch, TRUE);

    } while (TRUE);

    ASSERT(pvol->v_cCaches == 0);

    LeaveCriticalSection(&pvol->v_csCaches);
}

#endif  // PATH_CACHING

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
5566中文字幕一区二区电影| 亚洲精品一区二区三区精华液 | 国产一区二区三区黄视频 | 91在线视频18| 精品久久99ma| 伊人色综合久久天天人手人婷| 精品一区免费av| 欧美三区在线视频| 国产精品美日韩| 老汉av免费一区二区三区 | 欧美日韩免费一区二区三区 | 精品欧美乱码久久久久久1区2区 | 久久伊人中文字幕| 夜夜夜精品看看| 成人免费黄色在线| 26uuu国产在线精品一区二区| 亚洲成av人片在线观看| 91性感美女视频| 国产日韩欧美在线一区| 蜜桃传媒麻豆第一区在线观看| 在线免费亚洲电影| 国产精品国产三级国产a| 国产一区二区久久| 日韩免费电影网站| 视频在线观看一区二区三区| 91久久精品一区二区三| 中文字幕亚洲不卡| 成人动漫一区二区在线| 久久久青草青青国产亚洲免观| 免费久久99精品国产| 欧美精品色一区二区三区| 一区二区三区日韩在线观看| 色综合色综合色综合色综合色综合| 国产精品网站导航| 成人一区二区三区| 国产精品卡一卡二卡三| 成人av网站大全| 国产精品高潮久久久久无| 成人一级黄色片| 国产精品午夜电影| 成人精品视频.| 国产精品国产自产拍在线| eeuss鲁片一区二区三区| 国产精品福利一区二区| 99热99精品| 亚洲六月丁香色婷婷综合久久| 91社区在线播放| 夜色激情一区二区| 在线区一区二视频| 舔着乳尖日韩一区| 欧美一区二区不卡视频| 久久激情五月婷婷| 26uuu欧美日本| 国产成a人亚洲| 亚洲欧洲日韩综合一区二区| 91无套直看片红桃| 亚洲午夜久久久| 7777精品伊人久久久大香线蕉完整版| 丝袜亚洲精品中文字幕一区| 91精品国产欧美一区二区| 看电影不卡的网站| 久久久影院官网| 成人性色生活片| 亚洲精品国产a久久久久久| 欧美视频在线播放| 蜜臀av性久久久久蜜臀aⅴ四虎| 精品福利一区二区三区免费视频| 麻豆国产精品一区二区三区 | 欧美狂野另类xxxxoooo| 全国精品久久少妇| 久久久精品免费网站| 成人av手机在线观看| 一区二区在线观看av| 欧美精品123区| 国产裸体歌舞团一区二区| 国产精品美女www爽爽爽| 欧美丝袜丝交足nylons| 久久精品国产成人一区二区三区| 久久精品欧美一区二区三区不卡| 91麻豆视频网站| 全部av―极品视觉盛宴亚洲| 中文av字幕一区| 欧美日韩在线三级| 国产另类ts人妖一区二区| 亚洲欧美另类在线| 欧美一区中文字幕| 成人性色生活片| 日韩—二三区免费观看av| 国产欧美日韩另类视频免费观看| 欧美在线你懂得| 激情文学综合网| 一区二区三区精品久久久| 精品欧美久久久| 色系网站成人免费| 精品一区二区精品| 亚洲自拍偷拍图区| 久久久精品人体av艺术| 欧美日韩久久久久久| 国产a区久久久| 午夜精品久久一牛影视| 国产精品美女久久久久久久久 | 欧美猛男男办公室激情| 国产成人一区二区精品非洲| 亚洲国产成人av好男人在线观看| 久久免费看少妇高潮| 精品视频一区三区九区| 国产盗摄视频一区二区三区| 午夜精品久久久久| 国产精品传媒在线| 2欧美一区二区三区在线观看视频| 在线观看视频一区二区欧美日韩| 国产激情一区二区三区| 亚洲国产一区二区三区| 99精品在线免费| 色999日韩国产欧美一区二区| 日韩电影在线观看网站| 国产精品情趣视频| 日韩欧美久久一区| 欧美午夜片在线看| 成人免费看黄yyy456| 久久精品国产**网站演员| 亚洲国产精品久久久男人的天堂 | 91丝袜高跟美女视频| 精品中文字幕一区二区小辣椒| 亚洲一区二区欧美| 中文字幕一区二区三区四区不卡 | 久久久久国产精品人| 91麻豆精品国产91久久久| 日韩美女一区二区三区四区| 一本色道综合亚洲| 成人免费视频视频| 国产一本一道久久香蕉| 蜜桃视频免费观看一区| 午夜精品福利在线| 一区二区三区免费看视频| 中文字幕一区二区三| 国产欧美精品在线观看| 精品国产乱码久久久久久1区2区| 久久99久久99精品免视看婷婷| 亚洲精品久久久蜜桃| 亚洲国产高清aⅴ视频| 久久免费美女视频| 精品国产免费久久| 精品少妇一区二区三区| 欧美一级爆毛片| 欧美一级高清片| 欧美一区二区三区色| 91精品在线免费观看| 欧美男人的天堂一二区| 欧美男生操女生| 欧美久久高跟鞋激| 51精品国自产在线| 在线成人小视频| 欧美一级片免费看| 日韩欧美亚洲国产精品字幕久久久 | 亚洲女性喷水在线观看一区| 中文字幕中文字幕在线一区| 国产精品日韩成人| 国产精品久久久久久久久免费相片| 国产亚洲美州欧州综合国| 久久久久国产一区二区三区四区 | 欧美电影免费观看高清完整版在线观看 | 91亚洲男人天堂| 亚洲欧美另类小说视频| 中文字幕中文字幕一区二区 | 欧美三片在线视频观看| 在线观看日韩一区| 欧美日韩在线播放一区| 在线不卡的av| 日韩欧美久久久| 久久亚洲私人国产精品va媚药| 久久九九久精品国产免费直播| 久久久久久久久久久黄色| 国产三级欧美三级日产三级99| 三级久久三级久久| 久久激情五月婷婷| 国产成人免费视频一区| 国产成人av电影在线播放| av不卡免费电影| 欧美伊人久久久久久久久影院| 欧美精品亚洲一区二区在线播放| 日韩视频一区二区在线观看| 26uuu精品一区二区在线观看| 欧美极品xxx| 一级日本不卡的影视| 日本欧美大码aⅴ在线播放| 国产在线一区观看| 99久久婷婷国产| 欧美三电影在线| 精品国产第一区二区三区观看体验| 国产午夜精品一区二区三区四区| 亚洲欧洲av色图| 午夜精品久久久久影视| 狠狠色丁香久久婷婷综| 成人免费高清视频| 欧美日韩亚洲综合在线 | 欧美日韩精品一区视频| 精品国产乱码久久久久久1区2区| 国产精品久久久久久户外露出 | 尤物av一区二区|