From: Ralph Corderoy Date: Sat, 29 Oct 2016 22:11:52 +0000 (+0100) Subject: Simplify folder_exists() to just testing stat(2)'s return value. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/5774466bc16c2e12e36b6f050fbec8bc60913eb7 Simplify folder_exists() to just testing stat(2)'s return value. --- diff --git a/sbr/utils.c b/sbr/utils.c index d6a96d84..ff144673 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -179,22 +179,10 @@ addlist (char *list, const char *item) 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