mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Move remaining FileUtil functions into the File namespace.
This commit is contained in:
parent
0ccc63b43e
commit
1b13badeb4
32 changed files with 103 additions and 103 deletions
|
@ -11,7 +11,7 @@ JsonReader::JsonReader(const std::string &filename) {
|
|||
parse();
|
||||
} else {
|
||||
// Okay, try to read on the local file system
|
||||
buffer_ = (char *)ReadLocalFile(filename.c_str(), &buf_size);
|
||||
buffer_ = (char *)File::ReadLocalFile(filename.c_str(), &buf_size);
|
||||
if (buffer_) {
|
||||
parse();
|
||||
} else {
|
||||
|
|
|
@ -72,7 +72,7 @@ std::string I18NRepo::GetIniPath(const std::string &languageID) const {
|
|||
}
|
||||
|
||||
bool I18NRepo::IniExists(const std::string &languageID) const {
|
||||
FileInfo info;
|
||||
File::FileInfo info;
|
||||
if (!VFSGetFileInfo(GetIniPath(languageID).c_str(), &info))
|
||||
return false;
|
||||
if (!info.exists)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/File/DirListing.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
|
||||
#if !defined(__linux__) && !defined(_WIN32) && !defined(__QNX__)
|
||||
#define stat64 stat
|
||||
|
@ -33,12 +34,7 @@
|
|||
#define fileno
|
||||
#endif // HAVE_LIBNX
|
||||
|
||||
// Returns true if filename is a directory
|
||||
bool isDirectory(const std::string & filename) {
|
||||
FileInfo info;
|
||||
getFileInfo(filename.c_str(), &info);
|
||||
return info.isDirectory;
|
||||
}
|
||||
namespace File {
|
||||
|
||||
bool getFileInfo(const char *path, FileInfo * fileInfo) {
|
||||
// TODO: Expand relative paths?
|
||||
|
@ -172,7 +168,7 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> * files, const
|
|||
dir.append("/");
|
||||
|
||||
info.fullName = dir + virtualName;
|
||||
info.isDirectory = isDirectory(info.fullName);
|
||||
info.isDirectory = IsDirectory(info.fullName);
|
||||
info.exists = true;
|
||||
info.size = 0;
|
||||
info.isWritable = false; // TODO - implement some kind of check
|
||||
|
@ -244,3 +240,5 @@ std::vector<std::string> getWindowsDrives()
|
|||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
// Beginnings of a directory utility system. TODO: Improve.
|
||||
|
||||
namespace File {
|
||||
|
||||
struct FileInfo {
|
||||
std::string name;
|
||||
std::string fullName;
|
||||
|
@ -33,3 +35,5 @@ int64_t getDirectoryRecursiveSize(const std::string &path, const char *filter =
|
|||
#ifdef _WIN32
|
||||
std::vector<std::string> getWindowsDrives();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -984,8 +984,6 @@ bool IOFile::Resize(uint64_t size)
|
|||
return m_good;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool readFileToString(bool text_file, const char *filename, std::string & str)
|
||||
{
|
||||
FILE *f = File::OpenCFile(filename, text_file ? "r" : "rb");
|
||||
|
@ -1056,3 +1054,5 @@ bool writeDataToFile(bool text_file, const void* data, const unsigned int size,
|
|||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace File
|
||||
|
|
|
@ -191,8 +191,6 @@ private:
|
|||
bool m_good;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// TODO: Refactor, this was moved from the old file_util.cpp.
|
||||
|
||||
// Whole-file reading/writing
|
||||
|
@ -202,3 +200,5 @@ bool writeDataToFile(bool text_file, const void* data, const unsigned int size,
|
|||
bool readFileToString(bool text_file, const char *filename, std::string &str);
|
||||
// Return value must be delete[]-d.
|
||||
uint8_t *ReadLocalFile(const char *filename, size_t *size);
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "Core/System.h"
|
||||
|
||||
bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<FileInfo> &files) {
|
||||
bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<File::FileInfo> &files) {
|
||||
http::Client http;
|
||||
Buffer result;
|
||||
int code = 500;
|
||||
|
@ -77,7 +77,7 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<FileIn
|
|||
if (item == baseURL.Resource())
|
||||
continue;
|
||||
|
||||
FileInfo info;
|
||||
File::FileInfo info;
|
||||
info.name = item;
|
||||
info.fullName = baseURL.Relative(item).ToString();
|
||||
info.isDirectory = endsWith(item, "/");
|
||||
|
@ -91,7 +91,7 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<FileIn
|
|||
return !files.empty();
|
||||
}
|
||||
|
||||
std::vector<FileInfo> ApplyFilter(std::vector<FileInfo> files, const char *filter) {
|
||||
std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const char *filter) {
|
||||
std::set<std::string> filters;
|
||||
if (filter) {
|
||||
std::string tmp;
|
||||
|
@ -107,10 +107,10 @@ std::vector<FileInfo> ApplyFilter(std::vector<FileInfo> files, const char *filte
|
|||
filters.insert(std::move(tmp));
|
||||
}
|
||||
|
||||
auto pred = [&](const FileInfo &info) {
|
||||
auto pred = [&](const File::FileInfo &info) {
|
||||
if (info.isDirectory || !filter)
|
||||
return false;
|
||||
std::string ext = getFileExtension(info.fullName);
|
||||
std::string ext = File::getFileExtension(info.fullName);
|
||||
return filters.find(ext) == filters.end();
|
||||
};
|
||||
files.erase(std::remove_if(files.begin(), files.end(), pred), files.end());
|
||||
|
@ -174,7 +174,7 @@ void PathBrowser::HandlePath() {
|
|||
setCurrentThreadName("PathBrowser");
|
||||
|
||||
std::unique_lock<std::mutex> guard(pendingLock_);
|
||||
std::vector<FileInfo> results;
|
||||
std::vector<File::FileInfo> results;
|
||||
std::string lastPath;
|
||||
while (!pendingStop_) {
|
||||
while (lastPath == pendingPath_ && !pendingCancel_) {
|
||||
|
@ -233,7 +233,7 @@ std::string PathBrowser::GetFriendlyPath() const {
|
|||
return str;
|
||||
}
|
||||
|
||||
bool PathBrowser::GetListing(std::vector<FileInfo> &fileInfo, const char *filter, bool *cancel) {
|
||||
bool PathBrowser::GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter, bool *cancel) {
|
||||
std::unique_lock<std::mutex> guard(pendingLock_);
|
||||
while (!IsListingReady() && (!cancel || !*cancel)) {
|
||||
// In case cancel changes, just sleep.
|
||||
|
@ -245,11 +245,11 @@ bool PathBrowser::GetListing(std::vector<FileInfo> &fileInfo, const char *filter
|
|||
#ifdef _WIN32
|
||||
if (path_ == "/") {
|
||||
// Special path that means root of file system.
|
||||
std::vector<std::string> drives = getWindowsDrives();
|
||||
std::vector<std::string> drives = File::getWindowsDrives();
|
||||
for (auto drive = drives.begin(); drive != drives.end(); ++drive) {
|
||||
if (*drive == "A:/" || *drive == "B:/")
|
||||
continue;
|
||||
FileInfo fake;
|
||||
File::FileInfo fake;
|
||||
fake.fullName = *drive;
|
||||
fake.name = *drive;
|
||||
fake.isDirectory = true;
|
||||
|
@ -265,7 +265,7 @@ bool PathBrowser::GetListing(std::vector<FileInfo> &fileInfo, const char *filter
|
|||
fileInfo = ApplyFilter(pendingFiles_, filter);
|
||||
return true;
|
||||
} else {
|
||||
getFilesInDir(path_.c_str(), &fileInfo, filter);
|
||||
File::getFilesInDir(path_.c_str(), &fileInfo, filter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
void SetPath(const std::string &path);
|
||||
bool IsListingReady();
|
||||
bool GetListing(std::vector<FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
|
||||
bool GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
|
||||
|
||||
bool CanNavigateUp();
|
||||
void NavigateUp();
|
||||
|
@ -41,7 +41,7 @@ private:
|
|||
|
||||
std::string path_;
|
||||
std::string pendingPath_;
|
||||
std::vector<FileInfo> pendingFiles_;
|
||||
std::vector<File::FileInfo> pendingFiles_;
|
||||
std::condition_variable pendingCond_;
|
||||
std::mutex pendingLock_;
|
||||
std::thread pendingThread_;
|
||||
|
|
|
@ -42,7 +42,7 @@ ZipAssetReader::ZipAssetReader(const char *zip_file, const char *in_zip_path) {
|
|||
ERROR_LOG(IO, "Failed to open %s as a zip file", zip_file);
|
||||
}
|
||||
|
||||
std::vector<FileInfo> info;
|
||||
std::vector<File::FileInfo> info;
|
||||
GetFileListing("assets", &info, 0);
|
||||
for (size_t i = 0; i < info.size(); i++) {
|
||||
if (info[i].isDirectory) {
|
||||
|
@ -187,10 +187,10 @@ uint8_t *DirectoryAssetReader::ReadAsset(const char *path, size_t *size) {
|
|||
strcpy(new_path, path_);
|
||||
}
|
||||
strcat(new_path, path);
|
||||
return ReadLocalFile(new_path, size);
|
||||
return File::ReadLocalFile(new_path, size);
|
||||
}
|
||||
|
||||
bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter = 0)
|
||||
bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = 0)
|
||||
{
|
||||
char new_path[2048];
|
||||
new_path[0] = '\0';
|
||||
|
@ -201,13 +201,13 @@ bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<FileInfo
|
|||
strcpy(new_path, path_);
|
||||
}
|
||||
strcat(new_path, path);
|
||||
FileInfo info;
|
||||
if (!getFileInfo(new_path, &info))
|
||||
File::FileInfo info;
|
||||
if (!File::getFileInfo(new_path, &info))
|
||||
return false;
|
||||
|
||||
if (info.isDirectory)
|
||||
{
|
||||
getFilesInDir(new_path, listing, filter);
|
||||
File::getFilesInDir(new_path, listing, filter);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -216,7 +216,7 @@ bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<FileInfo
|
|||
}
|
||||
}
|
||||
|
||||
bool DirectoryAssetReader::GetFileInfo(const char *path, FileInfo *info)
|
||||
bool DirectoryAssetReader::GetFileInfo(const char *path, File::FileInfo *info)
|
||||
{
|
||||
char new_path[2048];
|
||||
new_path[0] = '\0';
|
||||
|
@ -227,5 +227,5 @@ bool DirectoryAssetReader::GetFileInfo(const char *path, FileInfo *info)
|
|||
strcpy(new_path, path_);
|
||||
}
|
||||
strcat(new_path, path);
|
||||
return getFileInfo(new_path, info);
|
||||
return File::getFileInfo(new_path, info);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
|
||||
// Direct readers. deallocate using delete [].
|
||||
uint8_t *ReadLocalFile(const char *filename, size_t *size);
|
||||
#include "Common/File/FileUtil.h"
|
||||
|
||||
class AssetReader {
|
||||
public:
|
||||
|
@ -19,8 +17,8 @@ public:
|
|||
// use delete[]
|
||||
virtual uint8_t *ReadAsset(const char *path, size_t *size) = 0;
|
||||
// Filter support is optional but nice to have
|
||||
virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter = 0) = 0;
|
||||
virtual bool GetFileInfo(const char *path, FileInfo *info) = 0;
|
||||
virtual bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = 0) = 0;
|
||||
virtual bool GetFileInfo(const char *path, File::FileInfo *info) = 0;
|
||||
virtual std::string toString() const = 0;
|
||||
};
|
||||
|
||||
|
@ -49,8 +47,8 @@ public:
|
|||
explicit DirectoryAssetReader(const char *path);
|
||||
// use delete[]
|
||||
virtual uint8_t *ReadAsset(const char *path, size_t *size);
|
||||
virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter);
|
||||
virtual bool GetFileInfo(const char *path, FileInfo *info);
|
||||
virtual bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter);
|
||||
virtual bool GetFileInfo(const char *path, File::FileInfo *info);
|
||||
virtual std::string toString() const {
|
||||
return path_;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
|
|||
if (IsLocalPath(filename)) {
|
||||
// Local path, not VFS.
|
||||
// INFO_LOG(IO, "Not a VFS path: %s . Reading local file.", filename);
|
||||
return ReadLocalFile(filename, size);
|
||||
return File::ReadLocalFile(filename, size);
|
||||
}
|
||||
|
||||
int fn_len = (int)strlen(filename);
|
||||
|
@ -64,11 +64,11 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter) {
|
||||
bool VFSGetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) {
|
||||
if (IsLocalPath(path)) {
|
||||
// Local path, not VFS.
|
||||
// INFO_LOG(IO, "Not a VFS path: %s . Reading local directory.", path);
|
||||
getFilesInDir(path, listing, filter);
|
||||
File::getFilesInDir(path, listing, filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const c
|
|||
return false;
|
||||
}
|
||||
|
||||
bool VFSGetFileInfo(const char *path, FileInfo *info) {
|
||||
bool VFSGetFileInfo(const char *path, File::FileInfo *info) {
|
||||
if (IsLocalPath(path)) {
|
||||
// Local path, not VFS.
|
||||
// INFO_LOG(IO, "Not a VFS path: %s . Getting local file info.", path);
|
||||
return getFileInfo(path, info);
|
||||
return File::getFileInfo(path, info);
|
||||
}
|
||||
|
||||
bool fileSystemFound = false;
|
||||
|
|
|
@ -17,5 +17,5 @@ void VFSShutdown();
|
|||
// Always allocates an extra zero byte at the end, so that it
|
||||
// can be used for text like shader sources.
|
||||
uint8_t *VFSReadFile(const char *filename, size_t *size);
|
||||
bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter = 0);
|
||||
bool VFSGetFileInfo(const char *filename, FileInfo *fileInfo);
|
||||
bool VFSGetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = 0);
|
||||
bool VFSGetFileInfo(const char *filename, File::FileInfo *fileInfo);
|
||||
|
|
|
@ -104,7 +104,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) {
|
|||
program->vshader_mtime = vs.st_mtime;
|
||||
if (!program->vshader_source) {
|
||||
size_t sz;
|
||||
vsh_src.reset((char *)ReadLocalFile(program->vshader_filename, &sz));
|
||||
vsh_src.reset((char *)File::ReadLocalFile(program->vshader_filename, &sz));
|
||||
}
|
||||
} else {
|
||||
program->vshader_mtime = 0;
|
||||
|
@ -114,7 +114,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) {
|
|||
program->fshader_mtime = fs.st_mtime;
|
||||
if (!program->fshader_source) {
|
||||
size_t sz;
|
||||
fsh_src.reset((char *)ReadLocalFile(program->fshader_filename, &sz));
|
||||
fsh_src.reset((char *)File::ReadLocalFile(program->fshader_filename, &sz));
|
||||
}
|
||||
} else {
|
||||
program->fshader_mtime = 0;
|
||||
|
|
|
@ -794,7 +794,7 @@ u32 DiskCachingFileLoaderCache::CountCachedFiles() {
|
|||
dir = GetSysDirectory(DIRECTORY_CACHE);
|
||||
}
|
||||
|
||||
std::vector<FileInfo> files;
|
||||
std::vector<File::FileInfo> files;
|
||||
return (u32)getFilesInDir(dir.c_str(), &files, "ppdc:");
|
||||
}
|
||||
|
||||
|
@ -811,12 +811,12 @@ void DiskCachingFileLoaderCache::GarbageCollectCacheFiles(u64 goalBytes) {
|
|||
dir = GetSysDirectory(DIRECTORY_CACHE);
|
||||
}
|
||||
|
||||
std::vector<FileInfo> files;
|
||||
getFilesInDir(dir.c_str(), &files, "ppdc:");
|
||||
std::vector<File::FileInfo> files;
|
||||
File::getFilesInDir(dir.c_str(), &files, "ppdc:");
|
||||
|
||||
u64 remaining = goalBytes;
|
||||
// TODO: Could order by LRU or etc.
|
||||
for (FileInfo file : files) {
|
||||
for (File::FileInfo &file : files) {
|
||||
if (file.isDirectory) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -112,15 +112,15 @@ bool LocalFileLoader::Exists() {
|
|||
#else
|
||||
if (handle_ != INVALID_HANDLE_VALUE || IsDirectory()) {
|
||||
#endif
|
||||
FileInfo info;
|
||||
return getFileInfo(filename_.c_str(), &info);
|
||||
File::FileInfo info;
|
||||
return File::getFileInfo(filename_.c_str(), &info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LocalFileLoader::IsDirectory() {
|
||||
FileInfo info;
|
||||
if (getFileInfo(filename_.c_str(), &info)) {
|
||||
File::FileInfo info;
|
||||
if (File::getFileInfo(filename_.c_str(), &info)) {
|
||||
return info.isDirectory;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1095,7 +1095,7 @@ PSPFileInfo VFSFileSystem::GetFileInfo(std::string filename) {
|
|||
x.name = filename;
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
FileInfo fo;
|
||||
File::FileInfo fo;
|
||||
if (VFSGetFileInfo(fullName.c_str(), &fo)) {
|
||||
x.exists = fo.exists;
|
||||
if (x.exists) {
|
||||
|
|
|
@ -82,7 +82,7 @@ static PluginInfo ReadPluginIni(const std::string &subdir, IniFile &ini) {
|
|||
}
|
||||
|
||||
static std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std::string &lang) {
|
||||
std::vector<FileInfo> pluginDirs;
|
||||
std::vector<File::FileInfo> pluginDirs;
|
||||
getFilesInDir(GetSysDirectory(DIRECTORY_PLUGINS).c_str(), &pluginDirs);
|
||||
|
||||
std::vector<PluginInfo> found;
|
||||
|
|
|
@ -450,7 +450,7 @@ namespace Reporting
|
|||
void AddScreenshotData(MultipartFormDataEncoder &postdata, std::string filename)
|
||||
{
|
||||
std::string data;
|
||||
if (!filename.empty() && readFileToString(false, filename.c_str(), data))
|
||||
if (!filename.empty() && File::readFileToString(false, filename.c_str(), data))
|
||||
postdata.Add("screenshot", data, "screenshot.jpg", "image/jpeg");
|
||||
|
||||
const std::string iconFilename = "disc0:/PSP_GAME/ICON0.PNG";
|
||||
|
|
|
@ -78,8 +78,8 @@ void LoadPostShaderInfo(const std::vector<std::string> &directories) {
|
|||
};
|
||||
|
||||
for (size_t d = 0; d < directories.size(); d++) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
getFilesInDir(directories[d].c_str(), &fileInfo, "ini:");
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
File::getFilesInDir(directories[d].c_str(), &fileInfo, "ini:");
|
||||
|
||||
if (fileInfo.size() == 0) {
|
||||
VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:");
|
||||
|
|
|
@ -63,7 +63,7 @@ void CwCheatScreen::LoadCheatInfo() {
|
|||
|
||||
// We won't parse this, just using it to detect changes to the file.
|
||||
std::string str;
|
||||
if (readFileToString(true, engine_->CheatFilename().c_str(), str)) {
|
||||
if (File::readFileToString(true, engine_->CheatFilename().c_str(), str)) {
|
||||
fileCheckHash_ = XXH3_64bits(str.c_str(), str.size());
|
||||
}
|
||||
fileCheckCounter_ = 0;
|
||||
|
@ -120,7 +120,7 @@ void CwCheatScreen::update() {
|
|||
if (fileCheckCounter_++ >= FILE_CHECK_FRAME_INTERVAL && engine_) {
|
||||
// Check if the file has changed. If it has, we'll reload.
|
||||
std::string str;
|
||||
if (readFileToString(true, engine_->CheatFilename().c_str(), str)) {
|
||||
if (File::readFileToString(true, engine_->CheatFilename().c_str(), str)) {
|
||||
uint64_t newHash = XXH3_64bits(str.c_str(), str.size());
|
||||
if (newHash != fileCheckHash_) {
|
||||
// This will update the hash.
|
||||
|
|
|
@ -113,7 +113,7 @@ u64 GameInfo::GetGameSizeInBytes() {
|
|||
switch (fileType) {
|
||||
case IdentifiedFileType::PSP_PBP_DIRECTORY:
|
||||
case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY:
|
||||
return getDirectoryRecursiveSize(ResolvePBPDirectory(filePath_), nullptr, GETFILES_GETHIDDEN);
|
||||
return File::getDirectoryRecursiveSize(ResolvePBPDirectory(filePath_), nullptr, File::GETFILES_GETHIDDEN);
|
||||
|
||||
default:
|
||||
return GetFileLoader()->FileSize();
|
||||
|
@ -124,8 +124,8 @@ u64 GameInfo::GetGameSizeInBytes() {
|
|||
std::vector<std::string> GameInfo::GetSaveDataDirectories() {
|
||||
std::string memc = GetSysDirectory(DIRECTORY_SAVEDATA);
|
||||
|
||||
std::vector<FileInfo> dirs;
|
||||
getFilesInDir(memc.c_str(), &dirs);
|
||||
std::vector<File::FileInfo> dirs;
|
||||
File::getFilesInDir(memc.c_str(), &dirs);
|
||||
|
||||
std::vector<std::string> directories;
|
||||
if (id.size() < 5) {
|
||||
|
@ -149,12 +149,12 @@ u64 GameInfo::GetSaveDataSizeInBytes() {
|
|||
u64 totalSize = 0;
|
||||
u64 filesSizeInDir = 0;
|
||||
for (size_t j = 0; j < saveDataDir.size(); j++) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
File::getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
// Note: getFileInDir does not fill in fileSize properly.
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
FileInfo finfo;
|
||||
getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
|
||||
File::FileInfo finfo;
|
||||
File::getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
|
||||
if (!finfo.isDirectory)
|
||||
filesSizeInDir += finfo.size;
|
||||
}
|
||||
|
@ -176,12 +176,12 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
|
|||
u64 totalSize = 0;
|
||||
u64 filesSizeInDir = 0;
|
||||
for (size_t j = 0; j < saveDataDir.size(); j++) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
File::getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
// Note: getFileInDir does not fill in fileSize properly.
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
FileInfo finfo;
|
||||
getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
|
||||
File::FileInfo finfo;
|
||||
File::getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
|
||||
if (!finfo.isDirectory)
|
||||
filesSizeInDir += finfo.size;
|
||||
}
|
||||
|
@ -230,8 +230,8 @@ void GameInfo::DisposeFileLoader() {
|
|||
bool GameInfo::DeleteAllSaveData() {
|
||||
std::vector<std::string> saveDataDir = GetSaveDataDirectories();
|
||||
for (size_t j = 0; j < saveDataDir.size(); j++) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
File::getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
|
||||
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
File::Delete(fileInfo[i].fullName.c_str());
|
||||
|
@ -402,9 +402,9 @@ public:
|
|||
std::string screenshot_png = GetSysDirectory(DIRECTORY_SCREENSHOT) + info_->id + "_00000.png";
|
||||
// Try using png/jpg screenshots first
|
||||
if (File::Exists(screenshot_png))
|
||||
readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
else if (File::Exists(screenshot_jpg))
|
||||
readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
else
|
||||
// Read standard icon
|
||||
ReadVFSToString("unknown.png", &info_->icon.data, &info_->lock);
|
||||
|
@ -449,9 +449,9 @@ handleELF:
|
|||
std::string screenshot_png = GetSysDirectory(DIRECTORY_SCREENSHOT) + info_->id + "_00000.png";
|
||||
// Try using png/jpg screenshots first
|
||||
if (File::Exists(screenshot_png)) {
|
||||
readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
} else if (File::Exists(screenshot_jpg)) {
|
||||
readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
} else {
|
||||
// Read standard icon
|
||||
VERBOSE_LOG(LOADER, "Loading unknown.png because there was an ELF");
|
||||
|
@ -492,7 +492,7 @@ handleELF:
|
|||
// Let's use the screenshot as an icon, too.
|
||||
std::string screenshotPath = ReplaceAll(gamePath_, ".ppst", ".jpg");
|
||||
if (File::Exists(screenshotPath)) {
|
||||
if (readFileToString(false, screenshotPath.c_str(), info_->icon.data)) {
|
||||
if (File::readFileToString(false, screenshotPath.c_str(), info_->icon.data)) {
|
||||
info_->icon.dataLoaded = true;
|
||||
} else {
|
||||
ERROR_LOG(G3D, "Error loading screenshot data: '%s'", screenshotPath.c_str());
|
||||
|
@ -577,9 +577,9 @@ handleELF:
|
|||
std::string screenshot_png = GetSysDirectory(DIRECTORY_SCREENSHOT) + info_->id + "_00000.png";
|
||||
// Try using png/jpg screenshots first
|
||||
if (File::Exists(screenshot_png))
|
||||
readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_png.c_str(), info_->icon.data);
|
||||
else if (File::Exists(screenshot_jpg))
|
||||
readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
File::readFileToString(false, screenshot_jpg.c_str(), info_->icon.data);
|
||||
else {
|
||||
DEBUG_LOG(LOADER, "Loading unknown.png because no icon was found");
|
||||
ReadVFSToString("unknown.png", &info_->icon.data, &info_->lock);
|
||||
|
|
|
@ -421,7 +421,7 @@ void SetBackgroundPopupScreen::update() {
|
|||
|
||||
if (pic) {
|
||||
const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png";
|
||||
writeStringToFile(false, pic->data, bgPng.c_str());
|
||||
File::writeStringToFile(false, pic->data, bgPng.c_str());
|
||||
}
|
||||
|
||||
NativeMessageReceived("bgImage_updated", "");
|
||||
|
|
|
@ -1772,10 +1772,10 @@ UI::EventReturn DeveloperToolsScreen::OnCopyStatesToRoot(UI::EventParams &e) {
|
|||
std::string savestate_dir = GetSysDirectory(DIRECTORY_SAVESTATE);
|
||||
std::string root_dir = GetSysDirectory(DIRECTORY_MEMSTICK_ROOT);
|
||||
|
||||
std::vector<FileInfo> files;
|
||||
std::vector<File::FileInfo> files;
|
||||
getFilesInDir(savestate_dir.c_str(), &files, nullptr, 0);
|
||||
|
||||
for (const FileInfo &file : files) {
|
||||
for (const File::FileInfo &file : files) {
|
||||
std::string src = file.fullName;
|
||||
std::string dst = root_dir + file.name;
|
||||
INFO_LOG(SYSTEM, "Copying file '%s' to '%s'", src.c_str(), dst.c_str());
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
void InstallZipScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
|
||||
FileInfo fileInfo;
|
||||
bool success = getFileInfo(zipPath_.c_str(), &fileInfo);
|
||||
File::FileInfo fileInfo;
|
||||
bool success = File::getFileInfo(zipPath_.c_str(), &fileInfo);
|
||||
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
auto iz = GetI18NCategory("InstallZip");
|
||||
|
|
|
@ -712,7 +712,7 @@ void GameBrowser::Refresh() {
|
|||
gameButtons.push_back(new GameButton(filenames[i], *gridStyle_, new UI::LinearLayoutParams(*gridStyle_ == true ? UI::WRAP_CONTENT : UI::FILL_PARENT, UI::WRAP_CONTENT)));
|
||||
}
|
||||
} else if (!listingPending_) {
|
||||
std::vector<FileInfo> fileInfo;
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
path_.GetListing(fileInfo, "iso:cso:pbp:elf:prx:ppdmp:");
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
bool isGame = !fileInfo[i].isDirectory;
|
||||
|
|
|
@ -485,7 +485,7 @@ NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen
|
|||
#endif
|
||||
langValuesMapping = GetLangValuesMapping();
|
||||
|
||||
std::vector<FileInfo> tempLangs;
|
||||
std::vector<File::FileInfo> tempLangs;
|
||||
VFSGetFileListing("lang", &tempLangs, "ini");
|
||||
std::vector<std::string> listing;
|
||||
int selected = -1;
|
||||
|
@ -508,7 +508,7 @@ NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen
|
|||
}
|
||||
#endif
|
||||
|
||||
FileInfo lang = tempLangs[i];
|
||||
File::FileInfo lang = tempLangs[i];
|
||||
langs_.push_back(lang);
|
||||
|
||||
std::string code;
|
||||
|
|
|
@ -100,7 +100,7 @@ private:
|
|||
bool ShowButtons() const override { return true; }
|
||||
std::map<std::string, std::pair<std::string, int>> langValuesMapping;
|
||||
std::map<std::string, std::string> titleCodeMapping;
|
||||
std::vector<FileInfo> langs_;
|
||||
std::vector<File::FileInfo> langs_;
|
||||
};
|
||||
|
||||
class PostProcScreen : public ListPopupScreen {
|
||||
|
|
|
@ -386,7 +386,7 @@ static void CheckFailedGPUBackends() {
|
|||
|
||||
if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
|
||||
std::string data;
|
||||
if (readFileToString(true, cache.c_str(), data))
|
||||
if (File::readFileToString(true, cache.c_str(), data))
|
||||
g_Config.sFailedGPUBackends = data;
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ static void CheckFailedGPUBackends() {
|
|||
// Let's try to create, in case it doesn't exist.
|
||||
if (!File::Exists(GetSysDirectory(DIRECTORY_APP_CACHE)))
|
||||
File::CreateDir(GetSysDirectory(DIRECTORY_APP_CACHE));
|
||||
writeStringToFile(true, g_Config.sFailedGPUBackends, cache.c_str());
|
||||
File::writeStringToFile(true, g_Config.sFailedGPUBackends, cache.c_str());
|
||||
} else {
|
||||
// Just save immediately, since we have storage.
|
||||
g_Config.Save("got storage permission");
|
||||
|
@ -1023,8 +1023,8 @@ void TakeScreenshot() {
|
|||
snprintf(filename, sizeof(filename), "%s/%s_%05d.png", path.c_str(), gameId.c_str(), i);
|
||||
else
|
||||
snprintf(filename, sizeof(filename), "%s/%s_%05d.jpg", path.c_str(), gameId.c_str(), i);
|
||||
FileInfo info;
|
||||
if (!getFileInfo(filename, &info))
|
||||
File::FileInfo info;
|
||||
if (!File::Exists(filename))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort
|
|||
|
||||
static bool LoadGameList(const std::string &url, std::vector<std::string> &games) {
|
||||
PathBrowser browser(url);
|
||||
std::vector<FileInfo> files;
|
||||
std::vector<File::FileInfo> files;
|
||||
browser.GetListing(files, "iso:cso:pbp:elf:prx:ppdmp:", &scanCancelled);
|
||||
if (scanCancelled) {
|
||||
return false;
|
||||
|
|
|
@ -430,7 +430,7 @@ static time_t GetTotalSize(const SavedataButton *b) {
|
|||
switch (Identify_File(fileLoader.get())) {
|
||||
case IdentifiedFileType::PSP_PBP_DIRECTORY:
|
||||
case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY:
|
||||
return getDirectoryRecursiveSize(ResolvePBPDirectory(b->GamePath()), nullptr, GETFILES_GETHIDDEN);
|
||||
return File::getDirectoryRecursiveSize(ResolvePBPDirectory(b->GamePath()), nullptr, File::GETFILES_GETHIDDEN);
|
||||
|
||||
default:
|
||||
return fileLoader->FileSize();
|
||||
|
@ -488,7 +488,7 @@ void SavedataBrowser::Refresh() {
|
|||
// Find games in the current directory and create new ones.
|
||||
std::vector<SavedataButton *> savedataButtons;
|
||||
|
||||
std::vector<FileInfo> fileInfo;
|
||||
std::vector<File::FileInfo> fileInfo;
|
||||
getFilesInDir(path_.c_str(), &fileInfo, "ppst:");
|
||||
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
|
|
|
@ -269,12 +269,12 @@ void WindowsHost::BootDone() {
|
|||
}
|
||||
|
||||
static std::string SymbolMapFilename(const char *currentFilename, const char* ext) {
|
||||
FileInfo info;
|
||||
File::FileInfo info;
|
||||
|
||||
std::string result = currentFilename;
|
||||
|
||||
// can't fail, definitely exists if it gets this far
|
||||
getFileInfo(currentFilename, &info);
|
||||
File::getFileInfo(currentFilename, &info);
|
||||
if (info.isDirectory) {
|
||||
#ifdef _WIN32
|
||||
const char* slash = "\\";
|
||||
|
|
|
@ -297,7 +297,7 @@ bool CompareOutput(const std::string &bootFilename, const std::string &output, b
|
|||
printf("%s", output.c_str());
|
||||
printf("============== expected output:\n");
|
||||
std::string fullExpected;
|
||||
if (readFileToString(true, expect_filename.c_str(), fullExpected))
|
||||
if (File::readFileToString(true, expect_filename.c_str(), fullExpected))
|
||||
printf("%s", fullExpected.c_str());
|
||||
printf("===============================\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue