27 #include "precompiled.h"
42 std::vector<CFileInfo> files;
46 pathnames.reserve(files.size());
48 for(
size_t i = 0; i < files.size(); i++)
51 pathnames.push_back(path / files[i].Name());
65 std::queue<VfsPath> pendingDirectories;
66 pendingDirectories.push(startPath/
"");
67 while(!pendingDirectories.empty())
69 const VfsPath& path = pendingDirectories.front();
73 for(
size_t i = 0; i < files.size(); i++)
80 cb(pathname, fileInfo, cbData);
86 for(
size_t i = 0; i < subdirectoryNames.size(); i++)
87 pendingDirectories.push(path / subdirectoryNames[i]/
"");
88 pendingDirectories.pop();
107 size_t maxNumber = 0;
109 fs->GetDirectoryEntries(path, &files, 0);
110 for(
size_t i = 0; i < files.size(); i++)
113 if(
swscanf_s(files[i].Name().
string().c_str(), nameFormat.
string().c_str(), &number) == 1)
114 maxNumber = std::max(
size_t(number), maxNumber);
117 nextNumber = maxNumber+1;
129 nextPathname = pathnameBuf;
131 while(fs->GetFileInfo(nextPathname, 0) ==
INFO::OK);
void NextNumberedFilename(const PIVFS &fs, const VfsPath &pathnameFormat, size_t &nextNumber, VfsPath &nextPathname)
Determine the next available pathname with a given format.
const OsPath & Name() const
Status(* FileCallback)(const VfsPath &pathname, const CFileInfo &fileInfo, const uintptr_t cbData)
called for files in a directory.
int match_wildcard(const wchar_t *s, const wchar_t *w)
see if string matches pattern.
int swprintf_s(wchar_t *buf, size_t max_chars, const wchar_t *fmt,...) WPRINTF_ARGS(3)
const String & string() const
i64 Status
Error handling system.
Status ForEachFile(const PIVFS &fs, const VfsPath &startPath, FileCallback cb, uintptr_t cbData, const wchar_t *pattern, size_t flags)
call back for each file in a directory tree
std::vector< OsPath > DirectoryNames
std::vector< VfsPath > VfsPaths
std::vector< CFileInfo > CFileInfos
Status GetPathnames(const PIVFS &fs, const VfsPath &path, const wchar_t *filter, VfsPaths &pathnames)
#define RETURN_STATUS_IF_ERR(expression)