Example #1
0
/* Create the given maildir folder, i.e. dir and its subdirectories
 * 'cur', 'new', 'tmp'. */
static notmuch_bool_t
maildir_create_folder (void *ctx, const char *dir)
{
    const int mode = 0700;
    char *subdir;
    char *tail;

    /* Create 'cur' directory, including parent directories. */
    subdir = talloc_asprintf (ctx, "%s/cur", dir);
    if (! subdir) {
	fprintf (stderr, "Out of memory.\n");
	return FALSE;
    }
    if (! make_directory_and_parents (subdir, mode))
	return FALSE;

    tail = subdir + strlen (subdir) - 3;

    /* Create 'new' directory. */
    strcpy (tail, "new");
    if (! make_directory (subdir, mode))
	return FALSE;

    /* Create 'tmp' directory. */
    strcpy (tail, "tmp");
    if (! make_directory (subdir, mode))
	return FALSE;

    talloc_free (subdir);
    return TRUE;
}
void make_directory_and_parents(const std::string &dirname) {
  if (dirname == "") return;
  make_directory_and_parents(filename_directory(dirname));
  make_directory(dirname);
}