static int UpgradeNSIS(void) { std::string installPath = GetNSISInstallPath(); if (installPath.empty()) return 0; std::string uninstallerPath = installPath + "\\uninstall.exe"; if (!PathExists(uninstallerPath)) return 0; std::string dataPath = GetIcingaDataPath(); if (dataPath.empty()) return 1; bool moveUserData = !PathExists(dataPath); /* perform open heart surgery on the user's data dirs - yay */ if (moveUserData) { MkDir(dataPath.c_str()); std::string oldNameEtc = installPath + "\\etc"; std::string newNameEtc = dataPath + "\\etc"; if (!CopyDirectory(oldNameEtc, newNameEtc)) return 1; std::string oldNameVar = installPath + "\\var"; std::string newNameVar = dataPath + "\\var"; if (!CopyDirectory(oldNameVar, newNameVar)) return 1; } ExecuteCommand(uninstallerPath, "/S _?=" + installPath); _unlink(uninstallerPath.c_str()); if (moveUserData) { std::string oldNameEtc = installPath + "\\etc"; if (!DeleteDirectory(oldNameEtc)) return 1; std::string oldNameVar = installPath + "\\var"; if (!DeleteDirectory(oldNameVar)) return 1; _rmdir(installPath.c_str()); } return 0; }
void FFileManagerGeneric::ProcessCommandLineOptions() { #if !( UE_BUILD_SHIPPING || UE_BUILD_TEST ) if( FParse::Param( FCommandLine::Get(),TEXT( "CLEANSCREENSHOTS" ) ) ) { DeleteDirectory( *FPaths::ScreenShotDir(), false, true ); } if( FParse::Param( FCommandLine::Get(),TEXT( "CLEANLOGS" ) ) ) { DeleteDirectory( *FPaths::GameLogDir(), false, true ); } #endif }
void PathManager::DeleteDirectory( CString strDir ) { if(strDir.IsEmpty()) { RemoveDirectory(strDir); return; } // 首先删除文件及子文件夹 CFileFind ff; BOOL bFound = ff.FindFile(strDir+_T("\\*"), 0); while(bFound) { bFound = ff.FindNextFile(); if(ff.GetFileName()==_T(".")||ff.GetFileName()==_T("..")) continue; // 去掉文件(夹)只读等属性 SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL); if(ff.IsDirectory()) { // 递归删除子文件夹 DeleteDirectory(ff.GetFilePath()); RemoveDirectory(ff.GetFilePath()); } else { // 删除文件 DeleteFile(ff.GetFilePath()); } } ff.Close(); // 然后删除该文件夹 RemoveDirectory(strDir); }
bool vsFile::DeleteDirectory( const vsString &filename ) { if ( DirectoryExists(filename) ) { vsArray<vsString> files; DirectoryContents(&files, filename); for ( int i = 0; i < files.ItemCount(); i++ ) { vsString ff = vsFormatString("%s/%s", filename.c_str(), files[i].c_str()); if ( vsFile::DirectoryExists( ff ) ) { // it's a directory; remove it! DeleteDirectory( ff ); } else { // it's a file, delete it. Delete( ff ); } } // I should now be empty, so delete me. return DeleteEmptyDirectory( filename ); } return false; }
bool FileSystemDefault::DeleteDirectory(const char* path) { // The following is copied from the EAIO package. // This code is not smart enough to do a recursive delete, but the one in EAIO is. // We need to implement a recursive delete. // Windows doesn't like it when the directory path ends with a // separator (e.g. '\') character, so we correct for this if needed. if(path && *path) { const size_t nStrlen = strlen(path); if((path[nStrlen - 1] != '/') && (path[nStrlen - 1] != '\\')) { #if defined(EA_PLATFORM_MICROSOFT) return (RemoveDirectoryA(path) != 0); #elif defined(EA_PLATFORM_UNIX) || defined(CS_UNDEFINED_STRING) return (rmdir(path) == 0); #endif } // Else we need to remove the separator. char pathMod[EA::WebKit::FileSystem::kMaxPathLength]; EAW_ASSERT_MSG(nStrlen < EA::WebKit::FileSystem::kMaxPathLength, "Directory path exceeds max path length"); memcpy(pathMod, path, nStrlen - 1); // Force 0 terminator in place of directory separator pathMod[nStrlen - 1] = 0; return DeleteDirectory(pathMod); // Call ourselves recursively. } return false; }
Status DeleteDirectory(const OsPath& path) { // note: we have to recursively empty the directory before it can // be deleted (required by Windows and POSIX rmdir()). CFileInfos files; DirectoryNames subdirectoryNames; RETURN_STATUS_IF_ERR(GetDirectoryEntries(path, &files, &subdirectoryNames)); // delete files for(size_t i = 0; i < files.size(); i++) { const OsPath pathname = path / files[i].Name(); errno = 0; if(wunlink(pathname) != 0) WARN_RETURN(StatusFromErrno()); } // recurse over subdirectoryNames for(size_t i = 0; i < subdirectoryNames.size(); i++) RETURN_STATUS_IF_ERR(DeleteDirectory(path / subdirectoryNames[i])); errno = 0; if(wrmdir(path) != 0) WARN_RETURN(StatusFromErrno()); return INFO::OK; }
/* Destroys directory */ HXBOOL CHXDirectory::Destroy(HXBOOL bRemoveContents) { OSErr err; if (bRemoveContents) { CHXDirSpecifier dirSpec(m_strPath); if (dirSpec.IsSet()) { FSRef dirRef = (FSRef) dirSpec; // use MoreFilesX's routine for this err = FSDeleteContainer(&dirRef); return (err == noErr); } } else { return DeleteDirectory(); } return FALSE; }
// 删除文件夹下指定后缀的文件 void DeleteDirectory(CString strPath,CString strSuffix) { CString strTemp=strPath; CString strFilePath=strPath; CFileFind finder; BOOL bWorking; bWorking=finder.FindFile(strPath+_T("\\*")+strSuffix); while(bWorking) { bWorking = finder.FindNextFile(); //如果是“.”则不处理 if (finder.IsDots()) { continue; } //如果是目录,继续扫描此目录 else if (finder.IsDirectory()) { strPath = finder.GetFileName(); strTemp = strTemp+_T("\\")+strPath; DeleteDirectory(strTemp,strSuffix); } //文件 else { strPath = finder.GetFileName(); strFilePath=strFilePath+_T("\\")+strPath; DeleteFile(strFilePath); CString strCut = _T("\\")+strPath; strFilePath.Replace(strCut,_T("")); //strFilePath.TrimLeft(strCut); } } }
BOOL FileMgr::DeleteDirectory(LPCTSTR Directory) { CFileFind tempFind; TCHAR sTempFileFind[MAX_PATH] = { 0 }; _stprintf_s(sTempFileFind,MAX_PATH, _T("%s//*.*"), Directory); BOOL IsFinded = tempFind.FindFile(sTempFileFind); while (IsFinded) { IsFinded = tempFind.FindNextFile(); if (!tempFind.IsDots()) { TCHAR sFoundFileName[MAX_PATH] = { 0 }; _tcscpy_s(sFoundFileName, MAX_PATH, tempFind.GetFileName().GetBuffer(200)); if (tempFind.IsDirectory()) { TCHAR sTempDir[MAX_PATH] = { 0 }; _stprintf_s(sTempDir, MAX_PATH, _T("%s//%s"), Directory, sFoundFileName); DeleteDirectory(sTempDir); } else { TCHAR sTempFileName[MAX_PATH] = { 0 }; _stprintf_s(sTempFileName, MAX_PATH, _T("%s//%s"), Directory, sFoundFileName); DeleteFile(sTempFileName); } } } tempFind.Close(); if (!RemoveDirectory(Directory)) { return FALSE; } return TRUE; }
void PanelView::UniversalDelete(const char *filename) //////////////////////////////////////////////////////////////////////// { BEntry entry(filename); key_info keyinfo; get_key_info(&keyinfo); if (keyinfo.key_states[0] & 0x40) { beep(); return; // ESC } // Don't delete the parent directory!!!!!! if (strlen(filename)>=3) { int len = strlen(filename); if (filename[len-1]=='.' && filename[len-2]=='.' && filename[len-3]=='/') return; } if (entry.InitCheck()==B_OK) { if (entry.Exists()) { if (entry.IsDirectory()) DeleteDirectory(filename); entry.Remove(); } } }
RCODE f_netwareRemoveDir( const char * pszDirName) { RCODE rc = NE_FLM_OK; FLMBYTE pucPseudoLNamePath[ F_PATH_MAX_SIZE + 1]; FLMBYTE pucLNamePath[ F_PATH_MAX_SIZE]; LONG lVolumeID; LONG lPathID; LONG lLNamePathCount; LONG lErrorCode; f_strcpy( (char *)&pucPseudoLNamePath[1], pszDirName); pucPseudoLNamePath[0] = (FLMBYTE)f_strlen( pszDirName); if( (lErrorCode = ConvertPathString( 0, 0, pucPseudoLNamePath, &lVolumeID, &lPathID, pucLNamePath, &lLNamePathCount)) != 0) { goto Exit; } if( (lErrorCode = DeleteDirectory( 0, lVolumeID, lPathID, pucLNamePath, lLNamePathCount, LONGNameSpace)) != 0) { goto Exit; } Exit: if( lErrorCode) { rc = f_mapPlatformError( lErrorCode, NE_FLM_IO_DELETING_FILE); } return( rc); }
BOOL Utils::DeleteDirectory( const LPCTSTR pszDir,BOOL bDeleteRoot /*= TRUE*/ ) { HANDLE hFind; // file handle WIN32_FIND_DATA FindFileData; TCHAR PathToSearchInto [MAX_PATH] = {0}; // Construct the path to search into "C:\\Windows\\System32\\*" _tcscpy(PathToSearchInto, pszDir); _tcscat(PathToSearchInto, _T("\\*")); hFind = ::FindFirstFile(PathToSearchInto,&FindFileData); // find the first file if(hFind == INVALID_HANDLE_VALUE) { return FALSE; } while(true) // until we finds an entry { if(::FindNextFile(hFind,&FindFileData)) { // Don't care about . and .. if ((_tcscmp(FindFileData.cFileName, _T(".")) == 0) || (_tcscmp(FindFileData.cFileName, _T("..")) == 0)) continue; // We have found a directory if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TCHAR AbsolutePathNewFileFound[MAX_PATH] = {0}; _tcscat(AbsolutePathNewFileFound, pszDir); _tcscat(AbsolutePathNewFileFound, _T("\\")); _tcscat(AbsolutePathNewFileFound, FindFileData.cFileName); // Recursive call with the new directory found DeleteDirectory(AbsolutePathNewFileFound); ::RemoveDirectory(AbsolutePathNewFileFound); } else // 是一个文件,删除 { TCHAR AbsolutePathNewFileFound[MAX_PATH] = {0}; _tcscat(AbsolutePathNewFileFound, pszDir); _tcscat(AbsolutePathNewFileFound, _T("\\")); _tcscat(AbsolutePathNewFileFound, FindFileData.cFileName); ::DeleteFile(AbsolutePathNewFileFound); } }//FindNextFile else { break; } }//while ::FindClose(hFind); // closing file handle if ( bDeleteRoot == TRUE) ::RemoveDirectory(pszDir); return TRUE; }
BOOL DeleteDirectory(const char* sPath) { HANDLE hFind; // file handle WIN32_FIND_DATAA FindFileData; char DirPath[MAX_PATH]; char FileName[MAX_PATH]; strcpy(DirPath,sPath); strcat(DirPath,"\\*"); // searching all files strcpy(FileName,sPath); strcat(FileName,"\\"); hFind = FindFirstFileA(DirPath,&FindFileData); // find the first file if(hFind == INVALID_HANDLE_VALUE) return FALSE; strcpy(DirPath,FileName); bool bSearch = true; while(bSearch) { // until we finds an entry if(FindNextFileA(hFind,&FindFileData)) { if(IsDots(FindFileData.cFileName)) continue; strcat(FileName,FindFileData.cFileName); if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { // we have found a directory, recurse if(!DeleteDirectory(FileName)) { FindClose(hFind); return FALSE; // directory couldn't be deleted } RemoveDirectoryA(FileName); // remove the empty directory strcpy(FileName,DirPath); } else { if(!DeleteFileA(FileName)) { // delete the file FindClose(hFind); return FALSE; } strcpy(FileName,DirPath); } } else { if(GetLastError() == ERROR_NO_MORE_FILES) // no more files there bSearch = false; else { // some error occured, close the handle and return FALSE FindClose(hFind); return FALSE; } } } FindClose(hFind); // closing file handle return RemoveDirectoryA(sPath); // remove the empty directory }
bool ff::DeleteDirectory(StringRef path, bool bMustBeEmpty) { if (bMustBeEmpty) { String szRealPath = CanonicalizePath(path, true); return ::RemoveDirectory(szRealPath.c_str()) ? true : false; } else if (DirectoryExists(path)) { Vector<String> dirs; Vector<String> files; if (GetDirectoryContents(path, dirs, files)) { String szRealPath = CanonicalizePath(path, true); for (size_t i = 0; i < files.Size(); i++) { String szDelete = szRealPath; AppendPathTail(szDelete, files[i]); if (!DeleteFile(szDelete)) { return false; } } for (size_t i = 0; i < dirs.Size(); i++) { String szDelete = szRealPath; AppendPathTail(szDelete, dirs[i]); if (!DeleteDirectory(szDelete, false)) { return false; } } return DeleteDirectory(path, true); } } return false; }
bool FSandboxPlatformFile::DeleteDirectory( const TCHAR* Path, bool Tree ) { if( Tree ) { // Support code for removing a directory tree. bool Result = true; // Delete all files in the directory first FString Spec = FString( Path ) / TEXT( "*" ); TArray<FString> List; FindFiles( List, *Spec, true, false ); for( int32 FileIndex = 0; FileIndex < List.Num(); FileIndex++ ) { FString Filename( FString( Path ) / List[ FileIndex ] ); // Delete the file even if it's read-only if( LowerLevel->FileExists( *Filename ) ) { LowerLevel->SetReadOnly( *Filename, false ); if( !LowerLevel->DeleteFile( *Filename ) ) { Result = false; } } else { Result = false; } } // Clear out the list of found files and look for directories this time List.Empty(); FindFiles( List, *Spec, false, true ); for( int32 DirectoryIndex = 0; DirectoryIndex < List.Num(); DirectoryIndex++ ) { if( !DeleteDirectory( *( FString( Path ) / List[ DirectoryIndex ] ), true ) ) { Result = false; } } // The directory is empty now so it can be deleted return DeleteDirectory( Path, false ) && Result; } else { return LowerLevel->DeleteDirectory( Path ) || ( !LowerLevel->DirectoryExists( Path ) ); } }
static int DeleteDirectory(char *refcstrRootDirectory) { DIR *dir; struct dirent *ent; dir = opendir(refcstrRootDirectory) ; if (dir == NULL) { sciprint(_("Warning: Error while opening %s: %s\n"), refcstrRootDirectory, strerror(errno)); return -1; } while ((ent = readdir(dir)) != NULL) { char *filename = NULL; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { continue ; } filename = MALLOC(sizeof(char) * (strlen(refcstrRootDirectory) + 1 + strlen(ent->d_name) + 1 + 1)) ; sprintf(filename, "%s/%s", refcstrRootDirectory, ent->d_name); if (isdir(filename)) { /* Delete recursively */ DeleteDirectory(filename); if (filename) { FREE(filename); filename = NULL; } } else { /* Not a directory... It must be a file (at least, I hope it is a file */ if (remove(filename) != 0) { sciprint(_("Warning: Could not remove file %s: %s\n"), filename, strerror(errno)); } if (filename) { FREE(filename); filename = NULL; } } } if (rmdir(refcstrRootDirectory) != 0) { sciprint(_("Warning: Could not remove directory %s: %s\n"), refcstrRootDirectory, strerror(errno)); } if (dir) { FREE(dir); dir = NULL; } return 0; }
/*----------------------------------------------------------------------------*/ int CFileApi::Delete(LPCTSTR lpPath) { if(CheckDirectory(lpPath)) { return DeleteDirectory(lpPath); }else{ return ::DeleteFile(lpPath); } }
bool DeleteDirectory(const UnicodeString & ADirName) { TSearchRecChecked SearchRec; bool retval = true; if (::FindFirst(ADirName + L"\\*", faAnyFile, SearchRec) == 0) // VCL Function { if (FLAGSET(SearchRec.Attr, faDirectory)) { if ((SearchRec.Name != THISDIRECTORY) && (SearchRec.Name != PARENTDIRECTORY)) retval = DeleteDirectory(ADirName + L"\\" + SearchRec.Name); } else { retval = ::DeleteFile(ApiPath(ADirName + L"\\" + SearchRec.Name)); } if (retval) { while (FindNextChecked(SearchRec) == 0) { // VCL Function if (FLAGSET(SearchRec.Attr, faDirectory)) { if ((SearchRec.Name != THISDIRECTORY) && (SearchRec.Name != PARENTDIRECTORY)) retval = DeleteDirectory(ADirName + L"\\" + SearchRec.Name); } else { retval = ::DeleteFile(ApiPath(ADirName + L"\\" + SearchRec.Name)); } if (!retval) { break; } } } } FindClose(SearchRec); if (retval) { retval = ::RemoveDir(ADirName); // VCL function } return retval; }
BOOL BookModel::DeleteBook(CString strBookName) { CString strFile = GetBook(strBookName); if (PathIsDirectory(strFile)) { DeleteDirectory(strFile); } else { DeleteFile(strFile); } return TRUE; }
void EventList::Init() { TCHAR temp[MAX_PATH]; temp[0] = 0; GetTempPath(MAX_PATH, temp); contactFileDir = temp; contactFileDir += L"BasicHistoryImportDir\\"; DeleteDirectory(contactFileDir.c_str()); CreateDirectory(contactFileDir.c_str(), NULL); }
/*--------------------------------------------------------------------------*/ BOOL removedirW(wchar_t *pathW) { if (isdirW(pathW)) { #ifdef _MSC_VER DeleteDirectory(pathW); #else char *path = wide_string_to_UTF8(pathW); if (path) { DeleteDirectory(path); FREE(path); path = NULL; } #endif if (!isdirW(pathW)) return TRUE; } return FALSE; }
/*----------------------------------------------------------------------------- Clear out the temp files folder -----------------------------------------------------------------------------*/ void CurlBlastDlg::ClearTemp() { TCHAR path[MAX_PATH]; if( GetTempPath(_countof(path), path) ) { TCHAR longPath[MAX_PATH]; if( GetLongPathName(path, longPath, _countof(longPath)) ) DeleteDirectory(longPath, false); } }
void CleanTemp(void) { OSErr err = noErr; short vRefNum; long dirID; FSSpec viewerFSp; XPISpec *xpiList, *currXPI = 0, *nextXPI = 0; #ifdef MIW_DEBUG Boolean isDir = false; #endif #ifndef MIW_DEBUG /* get "viewer" in "Temporary Items" folder */ ERR_CHECK(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID)); err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp); #else /* for DEBUG builds temp is "<currProcessVolume>:Temp NSInstall:" */ ERR_CHECK(GetCWD(&dirID, &vRefNum)); err = FSMakeFSSpec(vRefNum, 0, kTempFolder, &viewerFSp); if (err == fnfErr) return; /* no debug temp exists */ err = FSpGetDirectoryID(&viewerFSp, &dirID, &isDir); if (err != noErr || !isDir) return; err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp); #endif /* whack the viewer folder if it exists */ if (err == noErr) { ERR_CHECK(DeleteDirectory(viewerFSp.vRefNum, viewerFSp.parID, viewerFSp.name)); } /* clean out the zippies (.xpi's) */ xpiList = (XPISpec *) NewPtrClear(sizeof(XPISpec)); if (!xpiList) return; IterateDirectory(vRefNum, dirID, "\p", 1, CheckIfXPI, (void*)&xpiList); if (xpiList) { currXPI = xpiList; while(currXPI) { nextXPI = currXPI->next; /* save nextXPI before we blow away currXPI */ if (currXPI->FSp) { FSpDelete(currXPI->FSp); DisposePtr((Ptr)currXPI->FSp); } DisposePtr((Ptr)currXPI); currXPI = nextXPI; } } }
bool P12218319_CALL DeleteDirectoryRecursive(const std::string& aPath) throw() { const std::vector<std::string> children = ListChildren(aPath); for(const std::string& i : children) { const uint32_t attributes = GetFileAttributes(i); if(attributes & IS_FILE) { if(! DeleteFile(i)) return false; }else if (attributes & IS_DIRECTORY) { if(! DeleteDirectoryRecursive(i)) return false; }else { return false; } } return DeleteDirectory(aPath); }
void CFileManager::OnReceive(LPBYTE lpBuffer, UINT nSize) { switch (lpBuffer[0]) { case COMMAND_LIST_FILES:// 获取文件列表 SendFilesList((char *)lpBuffer + 1); break; case COMMAND_DELETE_FILE:// 删除文件 DeleteFile((char *)lpBuffer + 1); SendToken(TOKEN_DELETE_FINISH); break; case COMMAND_DELETE_DIRECTORY:// 删除文件 ////printf("删除目录 %s\n", (char *)(bPacket + 1)); DeleteDirectory((char *)lpBuffer + 1); SendToken(TOKEN_DELETE_FINISH); break; case COMMAND_DOWN_FILES: // 上传文件 UploadToRemote(lpBuffer + 1); break; case COMMAND_CONTINUE: // 上传文件 SendFileData(lpBuffer + 1); break; case COMMAND_CREATE_FOLDER: CreateFolder(lpBuffer + 1); break; case COMMAND_RENAME_FILE: Rename(lpBuffer + 1); break; case COMMAND_STOP: StopTransfer(); break; case COMMAND_SET_TRANSFER_MODE: SetTransferMode(lpBuffer + 1); break; case COMMAND_FILE_SIZE: CreateLocalRecvFile(lpBuffer + 1); break; case COMMAND_FILE_DATA: WriteLocalRecvFile(lpBuffer + 1, nSize -1); break; case COMMAND_OPEN_FILE_SHOW: OpenFile((char *)lpBuffer + 1, SW_SHOW); break; case COMMAND_OPEN_FILE_HIDE: OpenFile((char *)lpBuffer + 1, SW_HIDE); break; default: break; } }
int Uninstall(HWND hWnd) { // Remove all installed files DeleteDirectory(g_sInstallPath); DeleteShortcut(hWnd); DeleteRegistryKey(); if (!g_bRunFromSetupDll) RunSystemUninstall(); // TODO: May probably handle errors during deletion (such as locked directories) // and notify user. Right now just return OK. return ErrOK; }
CArchiveBuilder::CArchiveBuilder(const OsPath& mod, const OsPath& tempdir) : m_TempDir(tempdir) { m_VFS = CreateVfs(20*MiB); DeleteDirectory(m_TempDir/"_archivecache"); // clean up in case the last run failed m_VFS->Mount(L"cache/", m_TempDir/"_archivecache"/""); m_VFS->Mount(L"", mod/"", VFS_MOUNT_MUST_EXIST | VFS_MOUNT_KEEP_DELETED); // Collect the list of files before loading any base mods vfs::ForEachFile(m_VFS, L"", &CollectFileCB, (uintptr_t)static_cast<void*>(this), 0, vfs::DIR_RECURSIVE); }
int main(int argc, char* argv[]) { afout.open("out.txt"); wclock = new sf::Clock; bool record = true; bool init_selection = true; if (argc > 1) { if (strcmp(argv[1], "norecord")==0) record = false; else init_selection = false; } if (init_selection) { if (record) DeleteDirectory("arch"); int ngenerations = 100; int ngs = 2; Genome** gs = new Genome*[ngs]; gs[0] = readgenome("shipmind.mind"); gs[1] = readgenome("shipmind2.mind"); Population* pop = new Population(gs, ngs); for (int gen = 0; gen < ngenerations; gen++) { pop->calcfitness(evaluate); pop->printspecies(); if (record) pop->savegeneration(); pop->nextgen(); } return 0; } else { Genome* g1 = readgenome(argv[1]); Genome* g2 = 0; if (argc > 2) g2 = readgenome(argv[2]); else g2 = readgenome("shipmind.mind"); return openwindow(g1, g2); } }
void DeleteDirectory(QDir &dir) { QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); for(unsigned i = 0; i != (unsigned) files.size(); ++i) { dir.remove(files.at(i).fileName()); } QFileInfoList subdirs = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for(unsigned i = 0; i != (unsigned) subdirs.size(); ++i) { dir.cd(subdirs.at(i).fileName()); DeleteDirectory(dir); } QString current = dir.dirName(); dir.cdUp(); dir.rmdir(current); }
bool GalleryUtil::Delete(const QFileInfo &file) { if (!file.exists()) return false; if (file.isDir()) return DeleteDirectory(file); MSqlQuery query(MSqlQuery::InitCon()); query.prepare("DELETE FROM gallerymetadata " "WHERE image = :IMAGE ;"); query.bindValue(":IMAGE", file.absoluteFilePath()); if (query.exec()) return FileDelete(file); return false; }