[notmuch] [PATCH] notmuch-new: Test if directory looks like Maildir before skipping tmp.

Scott Robinson scott at quadhome.com
Wed Nov 25 12:12:25 PST 2009


Excerpts from Jan Janak's message of Wed Nov 25 11:43:15 -0800 2009:
> +/* Test if the directory looks like a Maildir directory.
> + *
> + * Search through the array of directory entries to see if we can find all
> + * three subdirectories typical for Maildir, that is "new", "cur", and "tmp".
> + *
> + * Return 1 if the directory looks like a Maildir and 0 otherwise.
> + */
> +static int is_maildir (struct dirent **entries, int count)
> +{
> +    int i, found = 0;
> +
> +    for (i = 0; i < count; i++) {
> +    if (entries[i]->d_type != DT_DIR) continue;
> +    if (strcmp(entries[i]->d_name, "new") == 0 ||
> +        strcmp(entries[i]->d_name, "cur") == 0 ||
> +        strcmp(entries[i]->d_name, "tmp") == 0)
> +    {
> +        found++;
> +    }
> +    }
> +
> +    return found >= 3;
> +}

Maybe put the "found >= 3" in the for loop's stop-condition?
-- 
Scott Robinson | http://quadhome.com/

Q: Why are my replies five sentences or less?
A: http://five.sentenc.es/


More information about the notmuch mailing list