From: markus schnalke Date: Sat, 24 Mar 2012 14:47:11 +0000 (+0100) Subject: Replaced folder_exists() by a call to create_folder(). X-Git-Tag: mmh-thesis-end~204 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=d4f5f9d551c05931478fcdfb5cd4ac06b419eeda Replaced folder_exists() by a call to create_folder(). Changed inc(1) to create non-existing folders with -silent, instead of silently failing in this case. I consider the new behavior to follow the POLS. --- diff --git a/h/utils.h b/h/utils.h index 7ee6046..a8059ea 100644 --- a/h/utils.h +++ b/h/utils.h @@ -6,7 +6,6 @@ void *mh_xmalloc(size_t); void *mh_xrealloc(void *, size_t); char *pwd(void); char *add(char *, char *); -int folder_exists(char *); void create_folder(char *, int, void (*)(int)); int num_digits(int); diff --git a/man/inc.man1 b/man/inc.man1 index eb51bc1..26ec56e 100644 --- a/man/inc.man1 +++ b/man/inc.man1 @@ -40,7 +40,9 @@ will use either the folder given by a (non\-empty) entry in the user's profile, or the folder named .RI \*(lq inbox \*(rq. If the specified (or default) folder doesn't -exist, the user will be queried prior to its creation. +exist, the user will (in +.B \-nosilent +mode) be queried prior to its creation. .PP When the new messages are incorporated into the folder, they are assigned numbers starting with the next highest number for the folder. As the diff --git a/sbr/utils.c b/sbr/utils.c index 5c5b0f5..297ad45 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -125,30 +125,6 @@ add(char *s2, char *s1) return cp; } -/* -** folder_exists -** Check to see if a folder exists. -*/ -int -folder_exists(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; -} - /* ** create_folder diff --git a/uip/inc.c b/uip/inc.c index 05df0f0..be6be22 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -294,16 +294,7 @@ main(int argc, char **argv) if ((maildir_copy = strdup(maildir)) == NULL) adios(maildir, "error allocating memory to copy maildir"); - if (!folder_exists(maildir)) { - /* - ** If the folder doesn't exist, and we're given the -silent - ** flag, just fail. - */ - if (noisy) - create_folder(maildir, 0, done); - else - done(1); - } + create_folder(maildir, noisy ? 0 : 1, done); if (chdir(maildir) == NOTOK) adios(maildir, "unable to change directory to");