mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-26 07:43:36 +01:00
Delete some duplicate code
This commit is contained in:
1 parent
0084b2ac30
commit
cf63ec6d3c
4 files changed
+11
-79
No files matched your search
@@ -110,10 +110,10 @@ void GameManager::Update() {
|
||||
InstallGame(zipName);
|
||||
// Doesn't matter if the install succeeds or not, we delete the temp file to not squander space.
|
||||
// TODO: Handle disk full?
|
||||
deleteFile(zipName.c_str());
|
||||
File::Delete(zipName.c_str());
|
||||
} else {
|
||||
ERROR_LOG(HLE, "Expected HTTP status code 200, got status code %i. Install cancelled.", curDownload_->ResultCode());
|
||||
deleteFile(zipName.c_str());
|
||||
File::Delete(zipName.c_str());
|
||||
}
|
||||
curDownload_.reset();
|
||||
}
|
||||
@@ -251,7 +251,7 @@ bool GameManager::InstallGame(std::string zipfile, bool deleteAfter) {
|
||||
buffer = 0;
|
||||
fclose(f);
|
||||
zip_fclose(zf);
|
||||
deleteFile(outFilename.c_str());
|
||||
File::Delete(outFilename.c_str());
|
||||
// Yes it's a goto. Sue me. I think it's appropriate here.
|
||||
goto bail;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ bool GameManager::InstallGame(std::string zipfile, bool deleteAfter) {
|
||||
installInProgress_ = false;
|
||||
installError_ = "";
|
||||
if (deleteAfter) {
|
||||
deleteFile(zipfile.c_str());
|
||||
File::Delete(zipfile.c_str());
|
||||
}
|
||||
InstallDone();
|
||||
return true;
|
||||
@@ -290,13 +290,13 @@ bail:
|
||||
installInProgress_ = false;
|
||||
installError_ = sy->T("Storage full");
|
||||
if (deleteAfter) {
|
||||
deleteFile(zipfile.c_str());
|
||||
File::Delete(zipfile.c_str());
|
||||
}
|
||||
for (size_t i = 0; i < createdFiles.size(); i++) {
|
||||
deleteFile(createdFiles[i].c_str());
|
||||
File::Delete(createdFiles[i].c_str());
|
||||
}
|
||||
for (auto iter = createdDirs.begin(); iter != createdDirs.end(); ++iter) {
|
||||
deleteDir(iter->c_str());
|
||||
File::DeleteDir(iter->c_str());
|
||||
}
|
||||
InstallDone();
|
||||
return false;
|
||||
|
||||
@@ -55,7 +55,7 @@ bool GameInfo::Delete() {
|
||||
{
|
||||
// Just delete the one file (TODO: handle two-disk games as well somehow).
|
||||
const char *fileToRemove = filePath_.c_str();
|
||||
deleteFile(fileToRemove);
|
||||
File::Delete(fileToRemove);
|
||||
auto i = std::find(g_Config.recentIsos.begin(), g_Config.recentIsos.end(), fileToRemove);
|
||||
if (i != g_Config.recentIsos.end()) {
|
||||
g_Config.recentIsos.erase(i);
|
||||
@@ -84,7 +84,7 @@ bool GameInfo::Delete() {
|
||||
case FILETYPE_ARCHIVE_7Z:
|
||||
{
|
||||
const char *fileToRemove = filePath_.c_str();
|
||||
deleteFile(fileToRemove);
|
||||
File::Delete(fileToRemove);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -227,10 +227,10 @@ bool GameInfo::DeleteAllSaveData() {
|
||||
|
||||
u64 totalSize = 0;
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
deleteFile(fileInfo[i].fullName.c_str());
|
||||
File::Delete(fileInfo[i].fullName.c_str());
|
||||
}
|
||||
|
||||
deleteDir(saveDataDir[j].c_str());
|
||||
File::DeleteDir(saveDataDir[j].c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,36 +150,6 @@ bool readDataFromFile(bool text_file, unsigned char* &data, const unsigned int s
|
||||
|
||||
#ifndef METRO
|
||||
|
||||
// Remove any ending forward slashes from directory paths
|
||||
// Modifies argument.
|
||||
static void stripTailDirSlashes(std::string &fname)
|
||||
{
|
||||
if (fname.length() > 1)
|
||||
{
|
||||
size_t i = fname.length() - 1;
|
||||
while (fname[i] == DIR_SEP_CHR)
|
||||
fname[i--] = '\0';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Returns true if file filename exists
|
||||
bool exists(const std::string &filename) {
|
||||
#ifdef _WIN32
|
||||
std::wstring wstr = ConvertUTF8ToWString(filename);
|
||||
return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
|
||||
std::string copy(filename);
|
||||
stripTailDirSlashes(copy);
|
||||
|
||||
int result = stat64(copy.c_str(), &file_info);
|
||||
|
||||
return (result == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns true if filename is a directory
|
||||
bool isDirectory(const std::string &filename) {
|
||||
FileInfo info;
|
||||
@@ -346,31 +316,6 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
|
||||
return foundEntries;
|
||||
}
|
||||
|
||||
void deleteFile(const char *file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!DeleteFile(ConvertUTF8ToWString(file).c_str())) {
|
||||
ELOG("Error deleting %s: %i", file, GetLastError());
|
||||
}
|
||||
#else
|
||||
int err = unlink(file);
|
||||
if (err) {
|
||||
ELOG("Error unlinking %s: %i", file, err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void deleteDir(const char *dir)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!RemoveDirectory(ConvertUTF8ToWString(dir).c_str())) {
|
||||
ELOG("Error deleting directory %s: %i", dir, GetLastError());
|
||||
}
|
||||
#else
|
||||
rmdir(dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::string getDir(const std::string &path)
|
||||
@@ -401,15 +346,6 @@ std::string getFilename(std::string path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
void mkDir(const std::string &path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
mkdir(path.c_str());
|
||||
#else
|
||||
mkdir(path.c_str(), 0777);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Returns a vector with the device names
|
||||
std::vector<std::string> getWindowsDrives()
|
||||
|
||||
@@ -37,10 +37,6 @@ enum {
|
||||
GETFILES_GETHIDDEN = 1
|
||||
};
|
||||
size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const char *filter = 0, int flags = 0);
|
||||
void deleteFile(const char *file);
|
||||
void deleteDir(const char *file);
|
||||
bool exists(const std::string &filename);
|
||||
void mkDir(const std::string &path);
|
||||
std::string getDir(const std::string &path);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Reference in new issue
Block a user