mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Common: Remove File funcs redundant with Path.
Shouldn't use these anymore anyway.
This commit is contained in:
parent
138d81e14d
commit
15038bb663
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user