mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
sceIoRename function
This commit is contained in:
@@ -35,17 +35,16 @@ std::string DirectoryFileSystem::GetLocalPath(std::string localpath)
|
||||
if (localpath.empty())
|
||||
return basePath;
|
||||
|
||||
if (localpath[0] == '/')
|
||||
localpath.erase(0,1);
|
||||
if (localpath[0] == '/')
|
||||
localpath.erase(0,1);
|
||||
//Convert slashes
|
||||
#ifdef _WIN32
|
||||
for (size_t i = 0; i < localpath.size(); i++)
|
||||
{
|
||||
if (localpath[i] == '/')
|
||||
localpath[i] = '\\';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return basePath + localpath;
|
||||
}
|
||||
|
||||
@@ -56,8 +55,8 @@ bool DirectoryFileSystem::MkDir(const std::string &dirname)
|
||||
#ifdef _WIN32
|
||||
return CreateDirectory(fullName.c_str(), NULL) == TRUE;
|
||||
#else
|
||||
mkdir(fullName.c_str(), 0777);
|
||||
return true;
|
||||
mkdir(fullName.c_str(), 0777);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -67,7 +66,26 @@ bool DirectoryFileSystem::RmDir(const std::string &dirname)
|
||||
#ifdef _WIN32
|
||||
return RemoveDirectory(fullName.c_str()) == TRUE;
|
||||
#else
|
||||
return 0 == rmdir(fullName.c_str());
|
||||
return 0 == rmdir(fullName.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to)
|
||||
{
|
||||
std::string fullFrom = GetLocalPath(from);
|
||||
std::string fullTo = to;
|
||||
// TO filename may not include path. Intention is that it uses FROM's path
|
||||
if (to.find("/") != std::string::npos) {
|
||||
int offset = from.find_last_of("/");
|
||||
if (offset >= 0) {
|
||||
fullTo = from.substr(0, offset + 1) + to;
|
||||
}
|
||||
}
|
||||
fullTo = GetLocalPath(fullTo);
|
||||
#ifdef _WIN32
|
||||
return MoveFile(fullFrom.c_str(), fullTo.c_str()) == TRUE;
|
||||
#else
|
||||
return 0 == rename(fullFrom.c_str(), fullTo.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -77,7 +95,7 @@ bool DirectoryFileSystem::DeleteFile(const std::string &filename)
|
||||
#ifdef _WIN32
|
||||
return DeleteFile(fullName.c_str()) == TRUE;
|
||||
#else
|
||||
return 0 == unlink(fullName.c_str());
|
||||
return 0 == unlink(fullName.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -243,7 +261,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
|
||||
x.name = filename;
|
||||
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
if (!File::Exists(fullName)) {
|
||||
return x;
|
||||
}
|
||||
@@ -257,8 +275,8 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
|
||||
|
||||
x.size = data.nFileSizeLow | ((u64)data.nFileSizeHigh<<32);
|
||||
#else
|
||||
x.size = File::GetSize(fullName);
|
||||
//TODO
|
||||
x.size = File::GetSize(fullName);
|
||||
//TODO
|
||||
#endif
|
||||
|
||||
return x;
|
||||
|
||||
Reference in New Issue
Block a user