chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: rename cg_unified() → cg_unified_controller()
[elogind.git]
/
src
/
basic
/
dirent-util.c
diff --git
a/src/basic/dirent-util.c
b/src/basic/dirent-util.c
index c433d5844aa15b236a9a6a343f0ea192a3eb1dfe..6b9d26773ea78868a50fdb662bb6ba8ea559bd64 100644
(file)
--- a/
src/basic/dirent-util.c
+++ b/
src/basic/dirent-util.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-21,10
+19,9
@@
#include <fcntl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
#include "dirent-util.h"
#include "dirent-util.h"
+#include "path-util.h"
#include "string-util.h"
int dirent_ensure_type(DIR *d, struct dirent *de) {
#include "string-util.h"
int dirent_ensure_type(DIR *d, struct dirent *de) {
@@
-55,12
+52,10
@@
int dirent_ensure_type(DIR *d, struct dirent *de) {
bool dirent_is_file(const struct dirent *de) {
assert(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;
return false;
- if (de->d_type != DT_REG &&
- de->d_type != DT_LNK &&
- de->d_type != DT_UNKNOWN)
+ if (hidden_or_backup_file(de->d_name))
return false;
return true;
return false;
return true;
@@
-69,13
+64,14
@@
bool dirent_is_file(const struct dirent *de) {
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
assert(de);
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
assert(de);
- if (de->d_type != DT_REG &&
- de->d_type != DT_LNK &&
- de->d_type != DT_UNKNOWN)
+ if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
return false;
return false;
- if (
hidden_file_allow_backup(de->d_name)
)
+ if (
de->d_name[0] == '.'
)
return false;
return false;
+ if (!suffix)
+ return true;
+
return endswith(de->d_name, suffix);
}
return endswith(de->d_name, suffix);
}