Changeset 2866 for trunk/src/lib/nt


Ignore:
Timestamp:
Sep 3, 2016, 1:04:26 AM (9 years ago)
Author:
bird
Message:

updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/kFsCache.c

    r2864 r2866  
    807807                                              )
    808808{
     809    /*
     810     * Convert the names to ANSI first, that way we know all the lengths.
     811     */
     812    char szName[KFSCACHE_CFG_MAX_ANSI_NAME];
     813    int  cchName = WideCharToMultiByte(CP_ACP, 0, pwcName, cwcName, szName, sizeof(szName) - 1, NULL, NULL);
     814    if (cchName >= 0)
     815    {
     816#ifdef KFSCACHE_CFG_SHORT_NAMES
     817        char szShortName[12*3 + 1];
     818        int  cchShortName = 0;
     819        if (   cwcShortName == 0
     820            || (cchShortName = WideCharToMultiByte(CP_ACP, 0, pwcShortName, cwcShortName,
     821                                                   szShortName, sizeof(szShortName) - 1, NULL, NULL)) > 0)
     822#endif
     823        {
     824            /*
     825             * Shortening is easy for non-directory objects, for
     826             * directory object we're only good when the length doesn't change
     827             * on any of the components (cchParent et al).
     828             *
     829             * This deals with your typical xxxx.ext.tmp -> xxxx.ext renames.
     830             */
     831            if (   cchName <= pCur->cchName
     832#ifdef KFSCACHE_CFG_UTF16
     833                && cwcName <= pCur->cwcName
     834#endif
     835#ifdef KFSCACHE_CFG_SHORT_NAMES
     836                && (   cchShortName == 0
     837                    || (   cchShortName <= pCur->cchShortName
     838                        && pCur->pszShortName != pCur->pszName
     839# ifdef KFSCACHE_CFG_UTF16
     840                        && cwcShortName <= pCur->cwcShortName
     841                        && pCur->pwszShortName != pCur->pwszName
     842# endif
     843                       )
     844                   )
     845#endif
     846               )
     847            {
     848                if (   pCur->bObjType != KFSOBJ_TYPE_DIR
     849                    || (   cchName == pCur->cchName
     850#ifdef KFSCACHE_CFG_UTF16
     851                        && cwcName == pCur->cwcName
     852#endif
     853#ifdef KFSCACHE_CFG_SHORT_NAMES
     854                        && (   cchShortName == 0
     855                            || (   cchShortName == pCur->cchShortName
     856# ifdef KFSCACHE_CFG_UTF16
     857                                && cwcShortName == pCur->cwcShortName
     858                                )
     859# endif
     860                           )
     861#endif
     862                       )
     863                   )
     864                {
     865                    KFSCACHE_LOG(("Refreshing %ls - name changed to '%*.*ls'\n", pCur->pwszName, cwcName, cwcName, pwcName));
     866                    *(char *)kHlpMemPCopy((void *)pCur->pszName, szName, cchName) = '\0';
     867                    pCur->cchName = cchName;
     868#ifdef KFSCACHE_CFG_UTF16
     869                    *(wchar_t *)kHlpMemPCopy((void *)pCur->pwszName, pwcName, cwcName * sizeof(wchar_t)) = '\0';
     870                    pCur->cwcName = cwcName;
     871#endif
     872#ifdef KFSCACHE_CFG_SHORT_NAMES
     873                    *(char *)kHlpMemPCopy((void *)pCur->pszShortName, szShortName, cchShortName) = '\0';
     874                    pCur->cchShortName = cchShortName;
     875# ifdef KFSCACHE_CFG_UTF16
     876                    *(wchar_t *)kHlpMemPCopy((void *)pCur->pwszShortName, pwcShortName, cwcShortName * sizeof(wchar_t)) = '\0';
     877                    pCur->cwcShortName = cwcShortName;
     878# endif
     879#endif
     880                    return pCur;
     881                }
     882            }
     883        }
     884    }
     885
     886
     887    fprintf(stderr,
     888            "kFsCacheDirRefreshOldChildName - not implemented!\n"
     889            "  Old name:  %#x '%ls'\n"
     890            "  New name:  %#x '%*.*ls'\n"
     891            "  Old short: %#x '%ls'\n"
     892            "  New short: %#x '%*.*ls'\n",
     893            pCur->cwcName, pCur->pwszName,
     894            cwcName, cwcName, cwcName, pwcName,
     895            pCur->cwcShortName, pCur->pwszShortName,
     896            cwcShortName, cwcShortName, cwcShortName, pwcShortName);
    809897    __debugbreak();
    810898    /** @todo implement this.  It's not entirely straight forward, especially if
     
    16921780                    KFSCACHE_LOG(("Refreshing %s/%s, ID changed %#llx -> %#llx and names too...\n",
    16931781                                  pObj->pParent->Obj.pszName, pObj->pszName, pObj->Stats.st_ino, uBuf.WithId.FileId.QuadPart));
     1782                    fprintf(stderr, "kFsCacheRefreshObj - ID + name change not implemented!!\n");
    16941783                    __debugbreak();
    16951784                    pObj->Stats.st_ino = uBuf.WithId.FileId.QuadPart;
     
    17171806                /* ouch! */
    17181807                kHlpAssertMsgFailed(("%#x\n", rcNt));
     1808                fprintf(stderr, "kFsCacheRefreshObj - rcNt=%#x on non-dir - not implemented!\n", rcNt);
    17191809                __debugbreak();
    17201810                fRc = K_FALSE;
     
    17751865                /* ouch! */
    17761866                kHlpAssertMsgFailed(("%#x\n", rcNt));
     1867                fprintf(stderr, "kFsCacheRefreshObj - rcNt=%#x on dir - not implemented!\n", rcNt);
    17771868                __debugbreak();
    17781869                fRc = K_FALSE;
     
    27332824        else
    27342825        {
     2826            fprintf(stderr, "kFsCacheRefreshPathA - refresh failure handling not implemented!\n");
    27352827            __debugbreak();
    27362828            /** @todo just remove this entry.   */
     
    27812873        else
    27822874        {
     2875            fprintf(stderr, "kFsCacheRefreshPathW - refresh failure handling not implemented!\n");
    27832876            __debugbreak();
    27842877            /** @todo just remove this entry.   */
     
    31623255
    31633256    KFSCACHE_LOG(("Destroying %s/%s, type=%d\n", pObj->pParent ? pObj->pParent->Obj.pszName : "", pObj->pszName, pObj->bObjType));
    3164 __debugbreak();
    31653257
    31663258    /*
Note: See TracChangeset for help on using the changeset viewer.