-silent flag, don't exit(1) for no apparent reason.
+2007-08-21 Josh Bressers <josh@bress.net>
+
+ * Red Hat Bug #253342: inc.c, utils.c, utils.h: When inc is run with
+ the -silent flag, don't exit(1) for no apparent reason.
+
2007-03-12 Peter Maydell <pmaydell@chiark.greenend.org.uk>
* bug #18630, #18631, #18632, #18634: various patches from
void *mh_xrealloc(void *, size_t);
char *pwd(void);
char *add(char *, char *);
+int folder_exists(char *);
void create_folder(char *, int, void (*)());
int num_digits(int);
}
/*
+ * 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
* Check to see if a folder exists, if not, prompt the user to create
* it.
if ((maildir_copy = strdup(maildir)) == (char *)0)
adios (maildir, "error allocating memory to copy maildir");
- if (noisy)
- create_folder(maildir, 0, done);
- else
- done (1);
+ 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);
+ }
if (chdir (maildir) == NOTOK)
adios (maildir, "unable to change directory to");