From 135cd563d1676d854e7835d03e52b76f0e7f6276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1zaro=20Vieira?= Date: Sun, 9 Apr 2017 13:28:10 -0300 Subject: [PATCH] Handle directory errors independently --- src/main.c | 5 +---- src/savemng.c | 12 +++--------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main.c b/src/main.c index 00042d3..f5b4b1d 100644 --- a/src/main.c +++ b/src/main.c @@ -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; diff --git a/src/savemng.c b/src/savemng.c index 35f0122..9757ae6 100644 --- a/src/savemng.c +++ b/src/savemng.c @@ -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."); }