mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Address all the easy feedback. Some is left.
This commit is contained in:
@@ -594,7 +594,7 @@ bool IniFile::Load(std::istream &in) {
|
||||
|
||||
bool IniFile::Save(const Path &filename)
|
||||
{
|
||||
FILE *file = File::OpenCFile(Path(filename), "w");
|
||||
FILE *file = File::OpenCFile(filename, "w");
|
||||
if (!file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const
|
||||
info.name = virtualName;
|
||||
|
||||
info.fullName = directory / virtualName;
|
||||
info.isDirectory = IsDirectory(Path(info.fullName));
|
||||
info.isDirectory = IsDirectory(info.fullName);
|
||||
info.exists = true;
|
||||
info.size = 0;
|
||||
info.isWritable = false; // TODO - implement some kind of check
|
||||
@@ -228,11 +228,11 @@ int64_t GetDirectoryRecursiveSize(const Path &path, const char *filter, int flag
|
||||
// Note: GetFilesInDir does not fill in fileSize.
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
FileInfo finfo;
|
||||
GetFileInfo(Path(fileInfo[i].fullName), &finfo);
|
||||
GetFileInfo(fileInfo[i].fullName, &finfo);
|
||||
if (!finfo.isDirectory)
|
||||
sizeSum += finfo.size;
|
||||
else
|
||||
sizeSum += GetDirectoryRecursiveSize(Path(finfo.fullName), filter, flags);
|
||||
sizeSum += GetDirectoryRecursiveSize(finfo.fullName, filter, flags);
|
||||
}
|
||||
return sizeSum;
|
||||
}
|
||||
|
||||
@@ -715,7 +715,7 @@ bool DeleteDirRecursively(const Path &directory) {
|
||||
continue;
|
||||
|
||||
Path newPath = directory / virtualName;
|
||||
if (IsDirectory(Path(newPath))) {
|
||||
if (IsDirectory(newPath)) {
|
||||
if (!DeleteDirRecursively(newPath)) {
|
||||
#ifndef _WIN32
|
||||
closedir(dirp);
|
||||
@@ -726,7 +726,7 @@ bool DeleteDirRecursively(const Path &directory) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!File::Delete(Path(newPath))) {
|
||||
if (!File::Delete(newPath)) {
|
||||
#ifndef _WIN32
|
||||
closedir(dirp);
|
||||
#else
|
||||
@@ -743,7 +743,7 @@ bool DeleteDirRecursively(const Path &directory) {
|
||||
}
|
||||
closedir(dirp);
|
||||
#endif
|
||||
return File::DeleteDir(Path(directory));
|
||||
return File::DeleteDir(directory);
|
||||
}
|
||||
|
||||
void OpenFileInEditor(const Path &fileName) {
|
||||
|
||||
@@ -59,7 +59,7 @@ Path Path::operator /(const std::string &subdir) const {
|
||||
}
|
||||
|
||||
void Path::operator /=(const std::string &subdir) {
|
||||
path_ += path_ + "/" + subdir;
|
||||
*this = *this / subdir;
|
||||
}
|
||||
|
||||
Path Path::WithExtraExtension(const std::string &ext) const {
|
||||
|
||||
@@ -130,8 +130,10 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
|
||||
info.exists = true;
|
||||
info.isWritable = false;
|
||||
info.isDirectory = false;
|
||||
std::string ext = File::GetFileExtension(info.fullName.ToString());
|
||||
std::string ext = info.fullName.GetFileExtension();
|
||||
if (filter) {
|
||||
if (!ext.empty())
|
||||
ext = ext.substr(1);
|
||||
if (filters.find(ext) == filters.end())
|
||||
continue;
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ bool AVIDump::CreateAVI() {
|
||||
const char *filename = s_format_context->filename;
|
||||
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", video_file_name.c_str());
|
||||
#endif
|
||||
INFO_LOG(COMMON, "Recording Video to: %s", video_file_name.c_str());
|
||||
INFO_LOG(COMMON, "Recording Video to: %s", video_file_name.ToVisualString().c_str());
|
||||
|
||||
// Make sure that the path exists
|
||||
if (!File::Exists(GetSysDirectory(DIRECTORY_VIDEO)))
|
||||
|
||||
+1
-2
@@ -1614,13 +1614,12 @@ void Config::changeGameSpecific(const std::string &pGameId, const std::string &t
|
||||
}
|
||||
|
||||
bool Config::createGameConfig(const std::string &pGameId) {
|
||||
Path fullIniFilePath = Path(getGameConfigFile(pGameId));
|
||||
Path fullIniFilePath = getGameConfigFile(pGameId);
|
||||
|
||||
if (hasGameConfig(pGameId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO(scoped):
|
||||
File::CreateEmptyFile(fullIniFilePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -180,9 +180,7 @@ Path DirectoryFileHandle::GetLocalPath(const Path &basePath, std::string localpa
|
||||
if (localpath[0] == '/')
|
||||
localpath.erase(0, 1);
|
||||
|
||||
Path result = basePath / localpath;
|
||||
// TODO?: Windows used to translate to backslashes here.
|
||||
return result;
|
||||
return basePath / localpath;
|
||||
}
|
||||
|
||||
bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, FileAccess access, u32 &error) {
|
||||
|
||||
+1
-1
@@ -864,7 +864,7 @@ namespace SaveState
|
||||
{
|
||||
int maxRes = g_Config.iInternalResolution > 2 ? 2 : -1;
|
||||
// TODO(scoped): Pass the path properly into TakeGameScreenshot.
|
||||
tempResult = TakeGameScreenshot(Path(op.filename), ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, nullptr, nullptr, maxRes);
|
||||
tempResult = TakeGameScreenshot(op.filename, ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, nullptr, nullptr, maxRes);
|
||||
callbackResult = tempResult ? Status::SUCCESS : Status::FAILURE;
|
||||
if (!tempResult) {
|
||||
ERROR_LOG(SAVESTATE, "Failed to take a screenshot for the savestate! %s", op.filename.c_str());
|
||||
|
||||
+1
-2
@@ -621,8 +621,7 @@ Path GetSysDirectory(PSPDirectories directoryType) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
// Run this at startup time. Please use GetSysDirectory if you need to query where folders are.
|
||||
void InitSysDirectories() {
|
||||
if (!g_Config.memStickDirectory.empty() && !g_Config.flash0Directory.empty())
|
||||
|
||||
@@ -55,7 +55,7 @@ void TextureReplacer::NotifyConfigChanged() {
|
||||
|
||||
enabled_ = g_Config.bReplaceTextures || g_Config.bSaveNewTextures;
|
||||
if (enabled_) {
|
||||
basePath_ = Path(GetSysDirectory(DIRECTORY_TEXTURES)) / gameID_;
|
||||
basePath_ = GetSysDirectory(DIRECTORY_TEXTURES) / gameID_;
|
||||
|
||||
Path newTextureDir = basePath_ / NEW_TEXTURE_DIR;
|
||||
|
||||
@@ -400,7 +400,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey,
|
||||
bool good = false;
|
||||
ReplacedTextureLevel level;
|
||||
level.fmt = ReplacedTextureFormat::F_8888;
|
||||
level.file = filename.ToString();
|
||||
level.file = filename;
|
||||
|
||||
png_image png = {};
|
||||
png.version = PNG_IMAGE_VERSION;
|
||||
@@ -569,7 +569,7 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl
|
||||
// Remember that we've saved this for next time.
|
||||
ReplacedTextureLevel saved;
|
||||
saved.fmt = ReplacedTextureFormat::F_8888;
|
||||
saved.file = filename.ToString();
|
||||
saved.file = filename;
|
||||
saved.w = w;
|
||||
saved.h = h;
|
||||
savedCache_[replacementKey] = saved;
|
||||
@@ -729,7 +729,7 @@ void ReplacedTexture::Load(int level, void *out, int rowPitch) {
|
||||
png_image_free(&png);
|
||||
}
|
||||
|
||||
bool TextureReplacer::GenerateIni(const std::string &gameID, Path *generatedFilename) {
|
||||
bool TextureReplacer::GenerateIni(const std::string &gameID, Path &generatedFilename) {
|
||||
if (gameID.empty())
|
||||
return false;
|
||||
|
||||
@@ -738,12 +738,11 @@ bool TextureReplacer::GenerateIni(const std::string &gameID, Path *generatedFile
|
||||
File::CreateFullPath(texturesDirectory);
|
||||
}
|
||||
|
||||
if (generatedFilename)
|
||||
*generatedFilename = texturesDirectory / INI_FILENAME;
|
||||
if (File::Exists(*generatedFilename))
|
||||
generatedFilename = texturesDirectory / INI_FILENAME;
|
||||
if (File::Exists(generatedFilename))
|
||||
return true;
|
||||
|
||||
FILE *f = File::OpenCFile(texturesDirectory / INI_FILENAME, "wb");
|
||||
FILE *f = File::OpenCFile(generatedFilename, "wb");
|
||||
if (f) {
|
||||
fwrite("\xEF\xBB\xBF", 1, 3, f);
|
||||
|
||||
@@ -772,5 +771,5 @@ bool TextureReplacer::GenerateIni(const std::string &gameID, Path *generatedFile
|
||||
fprintf(f, "[reducehashranges]\n");
|
||||
fclose(f);
|
||||
}
|
||||
return File::Exists(texturesDirectory / INI_FILENAME);
|
||||
return File::Exists(generatedFilename);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ struct ReplacedTextureLevel {
|
||||
int w;
|
||||
int h;
|
||||
ReplacedTextureFormat fmt;
|
||||
std::string file;
|
||||
Path file;
|
||||
};
|
||||
|
||||
struct ReplacementCacheKey {
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
void NotifyTextureDecoded(const ReplacedTextureDecodeInfo &replacedInfo, const void *data, int pitch, int level, int w, int h);
|
||||
|
||||
static bool GenerateIni(const std::string &gameID, Path *generatedFilename);
|
||||
static bool GenerateIni(const std::string &gameID, Path &generatedFilename);
|
||||
|
||||
protected:
|
||||
bool LoadIni();
|
||||
|
||||
+1
-1
@@ -1189,7 +1189,7 @@ void EmuScreen::update() {
|
||||
|
||||
if (errorMessage_.size()) {
|
||||
auto err = GetI18NCategory("Error");
|
||||
std::string errLoadingFile = gamePath_.ToString() + "\n";
|
||||
std::string errLoadingFile = gamePath_.ToVisualString() + "\n";
|
||||
errLoadingFile.append(err->T("Error loading file", "Could not load game"));
|
||||
errLoadingFile.append(" ");
|
||||
errLoadingFile.append(err->T(errorMessage_.c_str()));
|
||||
|
||||
@@ -1728,7 +1728,7 @@ UI::EventReturn DeveloperToolsScreen::OnLoadLanguageIni(UI::EventParams &e) {
|
||||
UI::EventReturn DeveloperToolsScreen::OnOpenTexturesIniFile(UI::EventParams &e) {
|
||||
std::string gameID = g_paramSFO.GetDiscID();
|
||||
Path generatedFilename;
|
||||
if (TextureReplacer::GenerateIni(gameID, &generatedFilename)) {
|
||||
if (TextureReplacer::GenerateIni(gameID, generatedFilename)) {
|
||||
File::OpenFileInEditor(generatedFilename);
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
|
||||
+1
-1
@@ -722,7 +722,7 @@ void GameBrowser::Refresh() {
|
||||
bool isGame = !fileInfo[i].isDirectory;
|
||||
bool isSaveData = false;
|
||||
// Check if eboot directory
|
||||
if (!isGame && path_.GetPath().size() >= 4 && IsValidPBP(Path(path_.GetPath()) / fileInfo[i].name / "EBOOT.PBP", true))
|
||||
if (!isGame && path_.GetPath().size() >= 4 && IsValidPBP(path_.GetPath() / fileInfo[i].name / "EBOOT.PBP", true))
|
||||
isGame = true;
|
||||
else if (!isGame && File::Exists(path_.GetPath() / fileInfo[i].name / "PSP_GAME/SYSDIR"))
|
||||
isGame = true;
|
||||
|
||||
@@ -67,7 +67,7 @@ bool TestsAvailable() {
|
||||
if (File::IsDirectory(Path("../pspautotests"))) {
|
||||
testDirectory = Path("..");
|
||||
}
|
||||
return File::Exists(Path(testDirectory) / "pspautotests" / "tests");
|
||||
return File::Exists(testDirectory / "pspautotests" / "tests");
|
||||
}
|
||||
|
||||
bool RunTests() {
|
||||
|
||||
@@ -20,4 +20,3 @@ public:
|
||||
};
|
||||
|
||||
extern std::string g_extFilesDir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user