label: move is_dir() to util.c
This commit is contained in:
parent
c34255bdb2
commit
be57e297ac
|
@ -58,20 +58,6 @@ int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
|
|||
return mkdir_safe_internal(path, mode, uid, gid, mkdir);
|
||||
}
|
||||
|
||||
int is_dir(const char* path, bool follow) {
|
||||
struct stat st;
|
||||
|
||||
if (follow) {
|
||||
if (stat(path, &st) < 0)
|
||||
return -errno;
|
||||
} else {
|
||||
if (lstat(path, &st) < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir) {
|
||||
const char *p, *e;
|
||||
int r;
|
||||
|
|
|
@ -39,4 +39,3 @@ typedef int (*mkdir_func_t)(const char *pathname, mode_t mode);
|
|||
int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkdir_func_t _mkdir);
|
||||
int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir);
|
||||
int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir);
|
||||
int is_dir(const char *path, bool is_dir);
|
||||
|
|
|
@ -6933,10 +6933,21 @@ int is_symlink(const char *path) {
|
|||
if (lstat(path, &info) < 0)
|
||||
return -errno;
|
||||
|
||||
if (S_ISLNK(info.st_mode))
|
||||
return 1;
|
||||
return !!S_ISLNK(info.st_mode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int is_dir(const char* path, bool follow) {
|
||||
struct stat st;
|
||||
|
||||
if (follow) {
|
||||
if (stat(path, &st) < 0)
|
||||
return -errno;
|
||||
} else {
|
||||
if (lstat(path, &st) < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
return !!S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
int unquote_first_word(const char **p, char **ret) {
|
||||
|
|
|
@ -991,6 +991,7 @@ bool is_localhost(const char *hostname);
|
|||
int take_password_lock(const char *root);
|
||||
|
||||
int is_symlink(const char *path);
|
||||
int is_dir(const char *path, bool follow);
|
||||
|
||||
int unquote_first_word(const char **p, char **ret);
|
||||
int unquote_many_words(const char **p, ...) _sentinel_;
|
||||
|
|
Loading…
Reference in a new issue