Handle directory errors independently

This commit is contained in:
Lázaro Vieira
2017-04-09 13:28:10 -03:00
parent 6b752a6965
commit 135cd563d1
2 changed files with 4 additions and 13 deletions

View File

@@ -135,10 +135,7 @@ Title* loadWiiTitles() {
DIR* dir = NULL;
dir = opendir("slccmpt01:/title/00010000");
if (dir == NULL) {
promptError("Failed to open directory.");
return NULL;
}
if (dir == NULL) return NULL;
while ((dirent = readdir(dir)) != 0) {
if(strcmp(dirent->d_name, "..")==0 || strcmp(dirent->d_name, ".")==0) continue;

View File

@@ -106,10 +106,7 @@ int DumpDir(char* pPath, const char* target_path) {
DIR* dir = NULL;
dir = opendir(pPath);
if (dir == NULL) {
promptError("Failed to open directory.");
return -1;
}
if (dir == NULL) return -1;
CreateSubfolder(target_path);
@@ -173,10 +170,7 @@ int DeleteDir(char* pPath) {
DIR* dir = NULL;
dir = opendir(pPath);
if (dir == NULL) {
promptError("Failed to open directory.");
return -1;
}
if (dir == NULL) return -1;
while ((dirent = readdir(dir)) != 0) {
@@ -404,7 +398,7 @@ void wipeSavedata(Title* title, bool allusers, bool common) {
getUserID(usrPath);
sprintf(srcPath + offset, "/%s", usrPath);
}
DeleteDir(srcPath);
if (DeleteDir(srcPath)!=0) promptError("Failed to delete savefile.");
}