Ejemplo n.º 1
0
void ForceInline main2(int argc, WChar **argv)
{
    LPWSTR lpFileName;
    WCHAR  szPath[MAX_PATH];
    HANDLE hFind;
    WIN32_FIND_DATAW wfd;

//    setlocale(LC_CTYPE, "");
    for (int i = 1; i != argc; ++i)
    {
        hFind = FindFirstFileW(argv[i], &wfd);
        if (hFind == INVALID_HANDLE_VALUE)
            continue;

        lstrcpyW(szPath, argv[i]);
        lpFileName = findnamew(szPath);

        do
        {
            if (IsParentDirectory(wfd.cFileName))
                continue;

            lstrcpyW(lpFileName, wfd.cFileName);

            if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                DeleteFolder(szPath, &wfd);
            else
                _DeleteFile(szPath);
        } while (FindNextFileW(hFind, &wfd));

        FindClose(hFind);
    }
}
Ejemplo n.º 2
0
Void DeleteFolder(LPWSTR lpPath, LPWIN32_FIND_DATAW pWfd)
{
    LPWSTR lpEnd;
    HANDLE hFind;

    if (GetFileAttributesW(lpPath) == -1)
        return;

    lpEnd = lpPath + lstrlenW(lpPath);
    lstrcpyW(lpEnd, L"\\*.*");

    hFind = FindFirstFileW(lpPath, pWfd);
    if (hFind != INVALID_HANDLE_VALUE)
    {
        do
        {
            if (IsParentDirectory(pWfd->cFileName))
                continue;

            lstrcpyW(lpEnd + 1, pWfd->cFileName);
            if (pWfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                DeleteFolder(lpPath, pWfd);
            }
            else
            {
                _DeleteFile(lpPath);
            }
        } while (FindNextFileW(hFind, pWfd));
        FindClose(hFind);
    }

    *lpEnd = 0;
}
Ejemplo n.º 3
0
BOOL _DeleteFileUpdateDir(_In_ PFILEINFO pFileToDelete, _In_ PDIRINFO pDeleteFrom,
    _Inout_opt_ CHL_HT_ITERATOR *pFromItr, _In_opt_ PDIRINFO pUpdateDir)
{
    SB_ASSERT(pFileToDelete->fIsDirectory == FALSE);
    if (pUpdateDir) // BUG Why is this _In_opt_
    {
        // Find this file in the other directory and update that file info
        // to say that it is not a duplicate any more.
        PFILEINFO pFileToUpdate;
        BOOL fFound = SUCCEEDED(CHL_DsFindHT(pUpdateDir->phtFiles, pFileToDelete->szFilename,
            StringSizeBytes(pFileToDelete->szFilename), &pFileToUpdate, NULL, TRUE));

        // Must find in the other dir also.
        SB_ASSERT(fFound);
        ClearDuplicateAttr(pFileToUpdate);
    }

    // Now, delete file from the specified dir and from file lists
    return _DeleteFile(pDeleteFrom, pFromItr, pFileToDelete);
}