mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-26 20:02:24 +01:00
cli/new: abstract special directory check
Add an abstraction for . and .. directory checks. No functional changes.
This commit is contained in:
parent
f8e9d29533
commit
f2ed177e62
1 changed files with 8 additions and 4 deletions
|
@ -234,6 +234,12 @@ _entries_resemble_maildir (const char *path, struct dirent **entries, int count)
|
||||||
return 0;
|
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.
|
/* Test if the file/directory is to be ignored.
|
||||||
*/
|
*/
|
||||||
static notmuch_bool_t
|
static notmuch_bool_t
|
||||||
|
@ -475,8 +481,7 @@ add_files (notmuch_database_t *notmuch,
|
||||||
* Also ignore the .notmuch directory and any "tmp" directory
|
* Also ignore the .notmuch directory and any "tmp" directory
|
||||||
* that appears within a maildir.
|
* that appears within a maildir.
|
||||||
*/
|
*/
|
||||||
if (strcmp (entry->d_name, ".") == 0 ||
|
if (_special_directory (entry->d_name) ||
|
||||||
strcmp (entry->d_name, "..") == 0 ||
|
|
||||||
(is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
|
(is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
|
||||||
strcmp (entry->d_name, ".notmuch") == 0)
|
strcmp (entry->d_name, ".notmuch") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -738,8 +743,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
|
||||||
/* Ignore special directories to avoid infinite recursion.
|
/* Ignore special directories to avoid infinite recursion.
|
||||||
* Also ignore the .notmuch directory.
|
* Also ignore the .notmuch directory.
|
||||||
*/
|
*/
|
||||||
if (strcmp (entry->d_name, ".") == 0 ||
|
if (_special_directory (entry->d_name) ||
|
||||||
strcmp (entry->d_name, "..") == 0 ||
|
|
||||||
strcmp (entry->d_name, ".notmuch") == 0)
|
strcmp (entry->d_name, ".notmuch") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue