Message: 1 Date: Wed, 22 Oct 2003 10:10:58 +0200 From: Jakob Eriksson <jakov(a)vmlinux.org> To: dpaun(a)rogers.com CC: Ferenc Wagner <wferi(a)afavant.elte.hu>, wine-devel(a)winehq.org Subject: Re: winetests: new addition
My thought exactly. I also tried to write a recursive delete using plain Win32 but failed miserably. :-)
You mean something like this: (Stolen shamelessly and a little modified fror SHELL_DeleteDirectory in shlfileop.c) #define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) static BOOL removeDir(LPCSTR dir) { BOOL ret = TRUE; HANDLE hFind; WIN32_FIND_DATAA wfd; CHAR path[MAX_PATH]; /* Make sure the directory exists before going further */ PathCombineA(path, dir, "*"); hFind = FindFirstFileA(path, &wfd); if (hFind == INVALID_HANDLE_VALUE) return ret; do { LPSTR lp = wfd.cFileName; if (!lp[0]) lp = wfd.cAlternateFileName; if (IsDotDir(lp)) continue; PathCombineA(path, dir, lp); if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) { ret = removeDir(path); } else ret = DeleteFileA(path); } while (ret && FindNextFileA(hFind, &wfd)); FindClose(hFind); RemoveDirectoryA(dir); return ret; } Rolf Kalbermatter
Rolf Kalbermatter wrote:
You mean something like this: (Stolen shamelessly and a little modified fror SHELL_DeleteDirectory in shlfileop.c)
#define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
static BOOL removeDir(LPCSTR dir) { BOOL ret = TRUE; HANDLE hFind; WIN32_FIND_DATAA wfd; CHAR path[MAX_PATH];
/* Make sure the directory exists before going further */ PathCombineA(path, dir, "*"); hFind = FindFirstFileA(path, &wfd); if (hFind == INVALID_HANDLE_VALUE) return ret;
do { LPSTR lp = wfd.cFileName; if (!lp[0]) lp = wfd.cAlternateFileName; if (IsDotDir(lp)) continue; PathCombineA(path, dir, lp); if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) { ret = removeDir(path); } else ret = DeleteFileA(path); } while (ret && FindNextFileA(hFind, &wfd)); FindClose(hFind); RemoveDirectoryA(dir); return ret; }
I have set myself up for embarrassment. :-) Yes, I tried to clone abovementioned code. Did not even succeed doing that. Also figured it was silly to clone functionality already in any not totally unreasonably outdated version of Windows. Jakob
participants (2)
-
Jakob Eriksson -
Rolf Kalbermatter