Created
April 4, 2014 06:52
-
-
Save moehuster/9969426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int clean_subdir(TCHAR *szPath) | |
{ | |
HANDLE hFind; | |
BOOL bContinue = TRUE; | |
WIN32_FIND_DATA FindData; | |
TCHAR szFile[MAX_PATH]; | |
wsprintf(szFile, TEXT("%s\\*"), szPath); | |
hFind = FindFirstFile(szFile, &FindData); | |
if (hFind==INVALID_HANDLE_VALUE) | |
return 0; | |
while (bContinue){ | |
if (_tcscmp(FindData.cFileName, TEXT("."))&& | |
_tcscmp(FindData.cFileName, TEXT(".."))){ | |
wsprintf(szFile, TEXT("%s\\%s"), szPath, FindData.cFileName); | |
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){ | |
func(szFile); | |
RemoveDirectory(szFile); | |
} | |
else{ | |
DWORD dwAttributes = GetFileAttributes(szFile); | |
dwAttributes &= ~FILE_ATTRIBUTE_READONLY; | |
SetFileAttributes(szFile, dwAttributes); | |
DeleteFile(szFile); | |
} | |
} | |
bContinue = FindNextFile(hFind, &FindData); | |
} | |
FindClose(hFind); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment