mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
basic/dirent-util: do not call hidden_file_allow_backup from dirent_is_file_with_suffix
If the file name is supposed to end in a suffix, there's not need to check the name against a list of "special" file names, which is slow. Instead, just check that the name doens't start with a period.
This commit is contained in:
parent
b1e02ee7cf
commit
ddb3706d26
@ -55,9 +55,7 @@ bool dirent_is_file(const struct dirent *de) {
|
|||||||
if (hidden_file(de->d_name))
|
if (hidden_file(de->d_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (de->d_type != DT_REG &&
|
if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
|
||||||
de->d_type != DT_LNK &&
|
|
||||||
de->d_type != DT_UNKNOWN)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -66,12 +64,10 @@ bool dirent_is_file(const struct dirent *de) {
|
|||||||
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
|
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
|
||||||
assert(de);
|
assert(de);
|
||||||
|
|
||||||
if (de->d_type != DT_REG &&
|
if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
|
||||||
de->d_type != DT_LNK &&
|
|
||||||
de->d_type != DT_UNKNOWN)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (hidden_file_allow_backup(de->d_name))
|
if (de->d_name[0] == '.')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return endswith(de->d_name, suffix);
|
return endswith(de->d_name, suffix);
|
||||||
|
Loading…
Reference in New Issue
Block a user