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);
struct dirent *d;
if (!dir)
return;
- while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
+ while ((d = readdir(dir)) != NULL) {
char *path;
+ if (is_dot_or_dotdot(d->d_name))
+ continue;
strbuf_reset(&reason);
if (should_prune_worktree(d->d_name, &reason, &path, expire))
prune_worktree(d->d_name, reason.buf);
if (!(dir = opendir(path)))
return error("Could not open directory %s", path);
- while ((e = readdir_skip_dot_and_dotdot(dir)))
- string_list_insert(list, e->d_name);
+ while ((e = readdir(dir)))
+ if (!is_dot_or_dotdot(e->d_name))
+ string_list_insert(list, e->d_name);
closedir(dir);
return 0;
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;
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;
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;
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);
unsigned visited_directories;
};
-struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp);
-
/*Count the number of slashes for string s*/
int count_slashes(const char *s);
if (!dir)
die_errno("cannot opendir '%s'", path->buf);
- while ((de = readdir_skip_dot_and_dotdot(dir)) != NULL) {
+ while ((de = readdir(dir)) != NULL) {
struct stat st;
+ if (is_dot_or_dotdot(de->d_name))
+ continue;
+
strbuf_addch(path, '/');
strbuf_addstr(path, de->d_name);
if (lstat(path->buf, &st))
strbuf_addch(&path, '/');
baselen = path.len;
- while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL) {
+ while ((e = readdir(dir)) != NULL) {
struct stat st;
struct object_id obj_oid, blob_oid;
+ if (is_dot_or_dotdot(e->d_name))
+ continue;
+
if (get_oid_hex(e->d_name, &obj_oid)) {
if (o->verbosity >= 3)
printf("Skipping non-SHA1 entry '%s%s'\n",
strbuf_addch(path, '/');
baselen = path->len;
- while ((de = readdir_skip_dot_and_dotdot(dir))) {
+ while ((de = readdir(dir))) {
size_t namelen;
+ if (is_dot_or_dotdot(de->d_name))
+ continue;
namelen = strlen(de->d_name);
strbuf_setlen(path, baselen);
}
strbuf_addch(&path, '/');
dirnamelen = path.len;
- while ((de = readdir_skip_dot_and_dotdot(dir)) != NULL) {
+ while ((de = readdir(dir)) != NULL) {
+ if (is_dot_or_dotdot(de->d_name))
+ continue;
+
strbuf_setlen(&path, dirnamelen);
strbuf_addstr(&path, de->d_name);
if (!dir)
die_errno(_("unable to open rr-cache directory"));
/* Collect stale conflict IDs ... */
- while ((e = readdir_skip_dot_and_dotdot(dir))) {
+ while ((e = readdir(dir))) {
struct rerere_dir *rr_dir;
struct rerere_id id;
int now_empty;
+ if (is_dot_or_dotdot(e->d_name))
+ continue;
if (!is_rr_cache_dirname(e->d_name))
continue; /* or should we remove e->d_name? */
dir = opendir(path.buf);
strbuf_release(&path);
if (dir) {
- while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
+ while ((d = readdir(dir)) != NULL) {
struct worktree *linked = NULL;
+ if (is_dot_or_dotdot(d->d_name))
+ continue;
if ((linked = get_linked_worktree(d->d_name))) {
ALLOC_GROW(list, counter + 1, alloc);
if (!dir)
return 0;
- d = readdir_skip_dot_and_dotdot(dir);
- if (d != NULL)
+ while ((d = readdir(dir)) != NULL) {
+ if (is_dot_or_dotdot(d->d_name))
+ continue;
+
ret = 1;
+ break;
+ }
closedir(dir);
return ret;
}