diff --git a/Common/Data/Format/IniFile.cpp b/Common/Data/Format/IniFile.cpp index f195ef5c71..06ee1acd60 100644 --- a/Common/Data/Format/IniFile.cpp +++ b/Common/Data/Format/IniFile.cpp @@ -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; } diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index ea665b4276..1140c64d7e 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -192,7 +192,7 @@ size_t GetFilesInDir(const Path &directory, std::vector * 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; } diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 2509b3db81..64b661395a 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -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) { diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index 07d2c34b75..5f5a28bd4d 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -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 { diff --git a/Common/File/VFS/AssetReader.cpp b/Common/File/VFS/AssetReader.cpp index b8729d39bf..8608bbd07f 100644 --- a/Common/File/VFS/AssetReader.cpp +++ b/Common/File/VFS/AssetReader.cpp @@ -130,8 +130,10 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vectorfilename; 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))) diff --git a/Core/Config.cpp b/Core/Config.cpp index 6c350a9dcc..2bc4200c57 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -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; } diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index b76e5ef6f7..b265b74759 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -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) { diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index fdba84d11f..b727889e71 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -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()); diff --git a/Core/System.cpp b/Core/System.cpp index 607b1b3819..bdbe292b7e 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -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()) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 8389fb786b..b3eb8e8c0b 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -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); } diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index f06267601c..1d888f13e3 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -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(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b280f950a0..5c504b8392 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -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())); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 328d4da790..fea5ff2e85 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -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; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 35f2b6f2fd..61f3732b9c 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -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; diff --git a/android/jni/TestRunner.cpp b/android/jni/TestRunner.cpp index 2c7e95fe80..281f904fab 100644 --- a/android/jni/TestRunner.cpp +++ b/android/jni/TestRunner.cpp @@ -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() { diff --git a/android/jni/app-android.h b/android/jni/app-android.h index 7a41d7c6b0..3a4935d63b 100644 --- a/android/jni/app-android.h +++ b/android/jni/app-android.h @@ -20,4 +20,3 @@ public: }; extern std::string g_extFilesDir; -