diff options
author | Jani Nikula <jani@nikula.org> | 2017-09-01 18:53:07 +0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2017-09-13 08:49:11 -0300 |
commit | f2ed177e6260d835b8a13d2a53e1c8d5fa76edf2 (patch) | |
tree | 269f54569c49d8579d90d613cd1fc46f0a525b24 /notmuch-new.c | |
parent | f8e9d29533250af5f575d63fae4f2f60b4e0bad6 (diff) |
cli/new: abstract special directory check
Add an abstraction for . and .. directory checks. No functional
changes.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r-- | notmuch-new.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/notmuch-new.c b/notmuch-new.c index c6a741fe..faeb8f0a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -234,6 +234,12 @@ _entries_resemble_maildir (const char *path, struct dirent **entries, int count) return 0; } +static notmuch_bool_t +_special_directory (const char *entry) +{ + return strcmp (entry, ".") == 0 || strcmp (entry, "..") == 0; +} + /* Test if the file/directory is to be ignored. */ static notmuch_bool_t @@ -475,8 +481,7 @@ add_files (notmuch_database_t *notmuch, * Also ignore the .notmuch directory and any "tmp" directory * that appears within a maildir. */ - if (strcmp (entry->d_name, ".") == 0 || - strcmp (entry->d_name, "..") == 0 || + if (_special_directory (entry->d_name) || (is_maildir && strcmp (entry->d_name, "tmp") == 0) || strcmp (entry->d_name, ".notmuch") == 0) continue; @@ -738,8 +743,7 @@ count_files (const char *path, int *count, add_files_state_t *state) /* Ignore special directories to avoid infinite recursion. * Also ignore the .notmuch directory. */ - if (strcmp (entry->d_name, ".") == 0 || - strcmp (entry->d_name, "..") == 0 || + if (_special_directory (entry->d_name) || strcmp (entry->d_name, ".notmuch") == 0) continue; |