summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c26
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);