VirtualBox

Changeset 2997 in kBuild


Ignore:
Timestamp:
Nov 1, 2016 11:28:02 PM (8 years ago)
Author:
bird
Message:

rm.c: Use fts_dirfd on windows.

Location:
trunk/src/lib/nt
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/fts-nt.h

    r2992 r2997  
    5353#ifdef _WINNT_
    5454typedef HANDLE fts_fd_t;
     55# define NT_FTS_INVALID_HANDLE_VALUE    INVALID_HANDLE_VALUE
    5556#else
    5657typedef void * fts_fd_t;
     58# define NT_FTS_INVALID_HANDLE_VALUE    ((void *)~(uintptr_t)0)
    5759#endif
    5860#define FTSCALL __cdecl
     
    98100        int fts_errno;                  /* errno for this node */
    99101        fts_fd_t fts_symfd;             /* NT: Normally -1; -2 we followed this symlinked dir */
    100         fts_fd_t fts_dirfd;             /* NT: Handle to the directory */
     102        fts_fd_t fts_dirfd;             /* NT: Handle to the directory (NT_FTS_)INVALID_HANDLE_VALUE if not valid */
    101103        size_t fts_pathlen;             /* strlen(fts_path) */
    102104        size_t fts_namelen;             /* strlen(fts_name) */
  • trunk/src/lib/nt/nthlp.h

    r2985 r2997  
    7575void        birdCloseFile(HANDLE hFile);
    7676int         birdDosToNtPath(const char *pszPath, MY_UNICODE_STRING *pNtPath);
     77int         birdDosToRelativeNtPath(const char *pszPath, MY_UNICODE_STRING *pNtPath);
    7778void        birdFreeNtPath(MY_UNICODE_STRING *pNtPath);
    7879
  • trunk/src/lib/nt/nthlpfs.c

    r2985 r2997  
    175175
    176176/**
    177  * Converts UNIX slashes to DOS ones and trims trailing ones.
     177 * Converts UNIX slashes to DOS ones.
    178178 *
    179179 * @returns 0
     
    194194    }
    195195
     196#if 0
    196197    /* Strip trailing slashes (NT doesn't like them). */
    197198    while (   pNtPath->Length >= sizeof(wchar_t)
     
    210211        pNtPath->Buffer[1] = '\0';
    211212    }
     213#endif
    212214
    213215    return 0;
  • trunk/src/lib/nt/ntunlink.c

    r2985 r2997  
    8383
    8484
    85 static int birdUnlinkInternal(const char *pszFile, int fReadOnlyToo, int fFast)
     85static int birdUnlinkInternal(HANDLE hRoot, const char *pszFile, int fReadOnlyToo, int fFast)
    8686{
    8787    MY_UNICODE_STRING   NtPath;
    8888    int                 rc;
    8989
    90     rc = birdDosToNtPath(pszFile, &NtPath);
     90    if (hRoot == INVALID_HANDLE_VALUE)
     91        hRoot = NULL;
     92    if (hRoot == NULL)
     93        rc = birdDosToNtPath(pszFile, &NtPath);
     94    else
     95        rc = birdDosToRelativeNtPath(pszFile, &NtPath);
    9196    if (rc == 0)
    9297    {
     
    96101            /* This uses FILE_DELETE_ON_CLOSE. Probably only suitable when in a hurry... */
    97102            MY_OBJECT_ATTRIBUTES ObjAttr;
    98             MyInitializeObjectAttributes(&ObjAttr, &NtPath, OBJ_CASE_INSENSITIVE, NULL /*hRoot*/, NULL /*pSecAttr*/);
     103            MyInitializeObjectAttributes(&ObjAttr, &NtPath, OBJ_CASE_INSENSITIVE, hRoot, NULL /*pSecAttr*/);
    99104            rcNt = g_pfnNtDeleteFile(&ObjAttr);
    100105
     
    113118            for (;;)
    114119            {
    115                 rcNt = birdOpenFileUniStr(NULL /*hRoot*/,
     120                rcNt = birdOpenFileUniStr(hRoot,
    116121                                          &NtPath,
    117122                                          DELETE,
     
    157162int birdUnlink(const char *pszFile)
    158163{
    159     return birdUnlinkInternal(pszFile, 0 /*fReadOnlyToo*/, 0 /*fFast*/);
     164    return birdUnlinkInternal(NULL /*hRoot*/, pszFile, 0 /*fReadOnlyToo*/, 0 /*fFast*/);
     165}
     166
     167
     168int birdUnlinkEx(void *hRoot, const char *pszFile)
     169{
     170    return birdUnlinkInternal((HANDLE)hRoot, pszFile, 0 /*fReadOnlyToo*/, 0 /*fFast*/);
    160171}
    161172
     
    163174int birdUnlinkForced(const char *pszFile)
    164175{
    165     return birdUnlinkInternal(pszFile, 1 /*fReadOnlyToo*/, 0 /*fFast*/);
     176    return birdUnlinkInternal(NULL /*hRoot*/, pszFile, 1 /*fReadOnlyToo*/, 0 /*fFast*/);
     177}
     178
     179
     180int birdUnlinkForcedEx(void *hRoot, const char *pszFile)
     181{
     182    return birdUnlinkInternal((HANDLE)hRoot, pszFile, 1 /*fReadOnlyToo*/, 0 /*fFast*/);
    166183}
    167184
     
    169186int birdUnlinkForcedFast(const char *pszFile)
    170187{
    171     return birdUnlinkInternal(pszFile, 1 /*fReadOnlyToo*/, 1 /*fFast*/);
     188    return birdUnlinkInternal(NULL /*hRoot*/, pszFile, 1 /*fReadOnlyToo*/, 1 /*fFast*/);
    172189}
    173190
     191
     192int birdUnlinkForcedFastEx(void *hRoot, const char *pszFile)
     193{
     194    return birdUnlinkInternal((HANDLE)hRoot, pszFile, 1 /*fReadOnlyToo*/, 1 /*fFast*/);
     195}
     196
  • trunk/src/lib/nt/ntunlink.h

    r2713 r2997  
    3535
    3636int birdUnlink(const char *pszFile);
     37int birdUnlinkEx(void *hRoot, const char *pszFile);
    3738int birdUnlinkForced(const char *pszFile);
     39int birdUnlinkForcedEx(void *hRoot, const char *pszFile);
    3840int birdUnlinkForcedFast(const char *pszFile);
     41int birdUnlinkForcedFastEx(void *hRoot, const char *pszFile);
    3942
    4043#undef  unlink
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette