From: Zbigniew Jędrzejewski-Szmek Date: Wed, 27 Apr 2016 13:24:59 +0000 (-0400) Subject: tree-wide: rename hidden_file to hidden_or_backup_file and optimize X-Git-Tag: v231.3~171 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=da2520e2ee5a89643c3178c94813548de7f6e3d7;ds=sidebyside tree-wide: rename hidden_file to hidden_or_backup_file and optimize In standard linux parlance, "hidden" usually means that the file name starts with ".", and nothing else. Rename the function to convey what the function does better to casual readers. Stop exposing hidden_file_allow_backup which is rather ugly and rewrite hidden_file to extract the suffix first. Note that hidden_file_allow_backup excluded files with "~" at the end, which is quite confusing. Let's get rid of it before it gets used in the wrong place. --- diff --git a/src/basic/dirent-util.c b/src/basic/dirent-util.c index 5019882a0..59067121b 100644 --- a/src/basic/dirent-util.c +++ b/src/basic/dirent-util.c @@ -52,10 +52,10 @@ int dirent_ensure_type(DIR *d, struct dirent *de) { bool dirent_is_file(const struct dirent *de) { assert(de); - if (hidden_file(de->d_name)) + if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN)) return false; - if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN)) + if (hidden_or_backup_file(de->d_name)) return false; return true; diff --git a/src/basic/dirent-util.h b/src/basic/dirent-util.h index 6bf099b46..b91d04908 100644 --- a/src/basic/dirent-util.h +++ b/src/basic/dirent-util.h @@ -38,7 +38,7 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pu on_error; \ } \ break; \ - } else if (hidden_file((de)->d_name)) \ + } else if (hidden_or_backup_file((de)->d_name)) \ continue; \ else diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 6c3063298..9c15b91c3 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -231,7 +231,7 @@ int close_all_fds(const int except[], unsigned n_except) { while ((de = readdir(d))) { int fd = -1; - if (hidden_file(de->d_name)) + if (hidden_or_backup_file(de->d_name)) continue; if (safe_atoi(de->d_name, &fd) < 0) diff --git a/src/basic/util.c b/src/basic/util.c index c6d3442c9..68097b46a 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -527,7 +527,7 @@ int on_ac_power(void) { if (!de) break; - if (hidden_file(de->d_name)) + if (hidden_or_backup_file(de->d_name)) continue; device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY);