]> diplodocus.org Git - nmh/commitdiff
Simplify folder_exists() to just testing stat(2)'s return value.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 29 Oct 2016 22:11:52 +0000 (23:11 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 30 Oct 2016 15:17:27 +0000 (15:17 +0000)
sbr/utils.c

index d6a96d8..ff14467 100644 (file)
@@ -179,22 +179,10 @@ addlist (char *list, const char *item)
 int folder_exists(const char *folder)
 {
     struct stat st;
 int folder_exists(const char *folder)
 {
     struct stat st;
-    int exists = 0;
 
 
-    if (stat (folder, &st) == -1) {
-        /* The folder either doesn't exist, or we hit an error.  Either way
-         * return a failure.
-         */
-        exists = 0;
-    } else {
-        /* We can see a folder with the right name */
-        exists = 1;
-    }
-
-    return exists;
+    return stat(folder, &st) != -1;
 }
 
 }
 
-
 /*
  * create_folder
  *      Check to see if a folder exists, if not, prompt the user to create
 /*
  * create_folder
  *      Check to see if a folder exists, if not, prompt the user to create