diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-05-27 13:59:39 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-27 14:02:37 +0900 |
commit | 1df046bcff6085f3800088c51e344594f822df57 (patch) | |
tree | 1bb0c3c0aca95201393debdba3b58602f1167027 /dir.c | |
parent | b548f0f1568f6b01e55ca69c24d3cb19489f92aa (diff) |
Revert "dir: introduce readdir_skip_dot_and_dotdot() helper"
This reverts commit b548f0f1568f6b01e55ca69c24d3cb19489f92aa, to be replaced with a reworked version.
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/dir.c b/dir.c index e47b4c507f..ff004b298b 100644 --- a/dir.c +++ b/dir.c @@ -59,18 +59,6 @@ void dir_init(struct dir_struct *dir) memset(dir, 0, sizeof(*dir)); } -struct dirent * -readdir_skip_dot_and_dotdot(DIR *dirp) -{ - struct dirent *e; - - while ((e = readdir(dirp)) != NULL) { - if (!is_dot_or_dotdot(e->d_name)) - break; - } - return e; -} - int count_slashes(const char *s) { int cnt = 0; @@ -2344,7 +2332,7 @@ static int read_cached_dir(struct cached_dir *cdir) struct dirent *de; if (cdir->fdir) { - de = readdir_skip_dot_and_dotdot(cdir->fdir); + de = readdir(cdir->fdir); if (!de) { cdir->d_name = NULL; cdir->d_type = DT_UNKNOWN; @@ -2943,9 +2931,11 @@ int is_empty_dir(const char *path) if (!dir) return 0; - e = readdir_skip_dot_and_dotdot(dir); - if (e) - ret = 0; + while ((e = readdir(dir)) != NULL) + if (!is_dot_or_dotdot(e->d_name)) { + ret = 0; + break; + } closedir(dir); return ret; @@ -2985,8 +2975,10 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up) strbuf_complete(path, '/'); len = path->len; - while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL) { + while ((e = readdir(dir)) != NULL) { struct stat st; + if (is_dot_or_dotdot(e->d_name)) + continue; strbuf_setlen(path, len); strbuf_addstr(path, e->d_name); |