diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index c360055ccb..061313fad2 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -560,36 +560,6 @@ bool Move(const Path &srcFilename, const Path &destFilename) { } } -std::string GetDir(const std::string &path) { - if (path == "/") - return path; - int n = (int)path.size() - 1; - while (n >= 0 && path[n] != '\\' && path[n] != '/') - n--; - std::string cutpath = n > 0 ? path.substr(0, n) : ""; - for (size_t i = 0; i < cutpath.size(); i++) { - if (cutpath[i] == '\\') cutpath[i] = '/'; - } -#ifndef _WIN32 - if (!cutpath.size()) { - return "/"; - } -#endif - return cutpath; -} - -std::string GetFileExtension(const std::string & fn) { - size_t pos = fn.rfind("."); - if (pos == std::string::npos) { - return ""; - } - std::string ext = fn.substr(pos); - for (size_t i = 0; i < ext.size(); i++) { - ext[i] = tolower(ext[i]); - } - return ext; -} - // Returns the size of file (64bit) // TODO: Add a way to return an error. uint64_t GetFileSize(const std::string &filename) { diff --git a/Common/File/FileUtil.h b/Common/File/FileUtil.h index b918d90d4d..6d5ae1d42d 100644 --- a/Common/File/FileUtil.h +++ b/Common/File/FileUtil.h @@ -53,12 +53,6 @@ bool ExistsInDir(const Path &path, const std::string &filename); // Supports Android content URIs. bool IsDirectory(const Path &filename); -// Parses the extension out from a filename. -std::string GetFileExtension(const std::string &filename); - -// Extracts the directory from a path. -std::string GetDir(const std::string &path); - // Returns struct with modification date of file bool GetModifTime(const Path &filename, tm &return_time); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index ee4dd2ead2..3a8058a67c 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -559,8 +559,8 @@ namespace Libretro bool retro_load_game(const struct retro_game_info *game) { - static std::string retro_base_dir; - static std::string retro_save_dir; + static Path retro_base_dir; + static Path retro_save_dir; std::string error_string; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; const char *nickname = NULL; @@ -600,41 +600,28 @@ bool retro_load_game(const struct retro_game_info *game) if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir_ptr) && dir_ptr) { - size_t last; - retro_base_dir = dir_ptr; - // Make sure that we don't have any lingering slashes, etc, as they break Windows. - last = retro_base_dir.find_last_not_of(DIR_SEP_CHRS); - if (last != std::string::npos) - last++; - - retro_base_dir = retro_base_dir.substr(0, last) + DIR_SEP; + retro_base_dir = Path(dir_ptr); } if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir_ptr) && dir_ptr) { - retro_save_dir = dir_ptr; - // Make sure that we don't have any lingering slashes, etc, as they break Windows. - size_t last = retro_save_dir.find_last_not_of(DIR_SEP_CHRS); - if (last != std::string::npos) - last++; - - retro_save_dir = retro_save_dir.substr(0, last) + DIR_SEP; + retro_save_dir = Path(dir_ptr); } if (retro_base_dir.empty()) - retro_base_dir = File::GetDir(game->path); + retro_base_dir = Path(game->path).NavigateUp(); - retro_base_dir += "PPSSPP" DIR_SEP; + retro_base_dir /= "PPSSPP"; if (retro_save_dir.empty()) - retro_save_dir = File::GetDir(game->path); + retro_save_dir = Path(game->path).NavigateUp(); - g_Config.currentDirectory = retro_base_dir; - g_Config.externalDirectory = retro_base_dir; - g_Config.memStickDirectory = Path(retro_save_dir); - g_Config.flash0Directory = Path(retro_base_dir) / "flash0"; - g_Config.internalDataDirectory = retro_base_dir; + g_Config.currentDirectory = retro_base_dir.ToString(); + g_Config.externalDirectory = retro_base_dir.ToString(); + g_Config.memStickDirectory = retro_save_dir; + g_Config.flash0Directory = retro_base_dir / "flash0"; + g_Config.internalDataDirectory = retro_base_dir.ToString(); VFSRegister("", new DirectoryAssetReader(retro_base_dir.c_str()));