summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-27 09:24:59 -0400
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:58 +0200
commitda2520e2ee5a89643c3178c94813548de7f6e3d7 (patch)
tree1c86b661808ac240c188e57ba05fbe409bede11b /src
parent792902f968872bb5dd8639bc7c6bbfc7831817f5 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/basic/dirent-util.c4
-rw-r--r--src/basic/dirent-util.h2
-rw-r--r--src/basic/fd-util.c2
-rw-r--r--src/basic/util.c2
4 files changed, 5 insertions, 5 deletions
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);