WCHAR* DirFileProvider::NextFile() { if (filesToOpen.size() > 0) { return filesToOpen.PopAt(0); } if (dirsToVisit.size() > 0) { // test next directory AutoFreeW path(dirsToVisit.PopAt(0)); OpenDir(path); return NextFile(); } return nullptr; }
WCHAR *DirFileProvider::NextFile() { if (filesToOpen.Count() > 0) { return filesToOpen.PopAt(0); } if (dirsToVisit.Count() > 0) { // test next directory ScopedMem<WCHAR> path(dirsToVisit.PopAt(0)); OpenDir(path); return NextFile(); } return nullptr; }
bool Delete(int index) { if (index < Count()) { free(text.PopAt(index)); return true; } return false; }
virtual void Run() { // filters all file paths on network drives, removable drives and // all paths which still exist from the list (remaining paths will // be marked as inexistent in gFileHistory) for (size_t i = 0; i < paths.Count() && !WasCancelRequested(); i++) { WCHAR *path = paths.At(i); if (!path || !path::IsOnFixedDrive(path) || DocumentPathExists(path)) { free(paths.PopAt(i--)); } } if (!WasCancelRequested()) uitask::Post(this); }
static size_t GetAllMatchingFiles(const WCHAR* dir, const WCHAR* filter, WStrVec& files, bool showProgress) { WStrVec dirsToVisit; dirsToVisit.Append(str::Dup(dir)); while (dirsToVisit.size() > 0) { if (showProgress) { wprintf(L"."); fflush(stdout); } AutoFreeW path(dirsToVisit.PopAt(0)); CollectStressTestSupportedFilesFromDirectory(path, filter, files); AutoFreeW pattern(str::Format(L"%s\\*", path)); CollectPathsFromDirectory(pattern, dirsToVisit, true); } return files.size(); }
// removes thumbnails that don't belong to any frequently used item in file history void CleanUpThumbnailCache(const FileHistory& fileHistory) { AutoFreeW thumbsPath(AppGenDataFilename(THUMBNAILS_DIR_NAME)); if (!thumbsPath) return; AutoFreeW pattern(path::Join(thumbsPath, L"*.png")); WStrVec files; WIN32_FIND_DATA fdata; HANDLE hfind = FindFirstFile(pattern, &fdata); if (INVALID_HANDLE_VALUE == hfind) return; do { if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) files.Append(str::Dup(fdata.cFileName)); } while (FindNextFile(hfind, &fdata)); FindClose(hfind); Vec<DisplayState*> list; fileHistory.GetFrequencyOrder(list); for (size_t i = 0; i < list.size() && i < FILE_HISTORY_MAX_FREQUENT * 2; i++) { AutoFreeW bmpPath(GetThumbnailPath(list.at(i)->filePath)); if (!bmpPath) continue; int idx = files.Find(path::GetBaseName(bmpPath)); if (idx != -1) { CrashIf(idx < 0 || files.size() <= (size_t)idx); free(files.PopAt(idx)); } } for (size_t i = 0; i < files.size(); i++) { AutoFreeW bmpPath(path::Join(thumbsPath, files.at(i))); file::Delete(bmpPath); } }