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





Reply via email to