Files
ppsspp/Common/File/DirListing.h
T
Henrik RydgårdandClaude Opus 5.5 adfbd7a259 PathBrowser: Abandon a network listing when navigating away
PathBrowser lists on one thread, so going up from the network folder
waited for its listing to finish (up to 8 seconds) before the drive list
showed. Pass GetFilesInDir a cancel flag that PathBrowser sets whenever
the path changes, or on destruction, and check it while waiting.

Also don't probe the drives in the drive list for game folders.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-24 02:44:17 +02:00

53 lines
1.4 KiB
C++

#pragma once
#include <string>
#include <string_view>
#include <vector>
#include <cstdio>
#include <cstdint>
#include "Common/File/Path.h"
namespace File {
struct FileInfo {
std::string name; // local name in directory
Path fullName;
bool exists = false;
bool isDirectory = false;
bool isWritable = false;
uint64_t size = 0; // in bytes
// time_t
uint64_t atime = 0;
uint64_t mtime = 0;
uint64_t ctime = 0;
// Microseconds, addition to the time_t.
int atimeUs = 0;
int mtimeUs = 0;
int ctimeUs = 0;
// Access bitfield
uint32_t access = 0; // st_mode & 0x1ff
bool operator <(const FileInfo &other) const;
};
bool GetFileInfo(const Path &path, FileInfo *fileInfo);
enum {
GETFILES_GETHIDDEN = 1,
GETFILES_GET_NAVIGATION_ENTRIES = 2, // If you don't set this, "." and ".." will be skipped.
};
// Note: extensionFilter is ignored for directories, so you can recurse.
// cancel is only checked while waiting for a network listing (Windows), which can take seconds.
bool GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const char *extensionFilter = nullptr, int flags = 0, std::string_view prefix = std::string_view(), const bool *cancel = nullptr);
std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const char *extensionFilter, std::string_view prefix);
#ifdef _WIN32
std::vector<std::string> GetWindowsDrives();
#endif
} // namespace File