Exemplo n.º 1
0
static bool RemoveDirRecursive(const char *dir, const char *mask)
{
  if (dir == 0 || dir[0] == 0) return false;
  if (strcmp(dir,"\\") == 0) return false;
  bool res = true;
  Pathname newp;
  newp.SetDirectory(dir);
  if (mask)
  {
    WIN32_FIND_DATAA fnd;
    HANDLE h;
    newp.SetFilename(mask);
    h = FindFirstFileA(newp,&fnd);
    if (h) 
    {
      do
      {
        if (!(fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
        {
          newp.SetFilename(fnd.cFileName);
          if (DeleteFile(newp) == FALSE) res = false;
        }
      }while (FindNextFileA(h,&fnd));
      CloseHandle(h);
    }
  }
  {
    WIN32_FIND_DATAA fnd;
    HANDLE h;
    newp.SetFilename("*.*");
    h = FindFirstFileA(newp,&fnd);
    if (h) 
    {
      do
      {
        if ((fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strcmp(fnd.cFileName,".") != 0 && strcmp(fnd.cFileName,"..") != 0)
        {
          newp.SetFilename(fnd.cFileName);
          if (RemoveDirRecursive(newp,mask) == false) res = false;
          else DeleteFile(newp);
        }
      }while (FindNextFileA(h,&fnd));
      CloseHandle(h);
    }
  }
  return res;

}
Exemplo n.º 2
0
bool Pathname::CreateFolder(const char *path, void *security_descriptor)
{
  Pathname pth;
  pth.SetDirectory(path);
  return pth.CreateFolder(security_descriptor);
}