Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: uv_fs_readdir sync skips . and ..
Browse files Browse the repository at this point in the history
Fixes test fs_async_dir
  • Loading branch information
ry committed Sep 5, 2011
1 parent 7ccc747 commit b6ede6c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/unix/fs.c
Expand Up @@ -303,15 +303,26 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
return -1;
}

/* req->result stores number of entries */
req->result = 0;

while ((entry = readdir(dir))) {
d_namlen = strlen(entry->d_name);

/* Skip . and .. */
if ((d_namlen == 1 && entry->d_name[0] == '.') ||
(d_namlen == 2 && entry->d_name[0] == '.' &&
entry->d_name[1] == '.')) {
continue;
}

req->ptr = realloc(req->ptr, size + d_namlen + 1);
/* TODO check ENOMEM */
/* TODO skip . and .. */
memcpy((char*)req->ptr + size, entry->d_name, d_namlen);
size += d_namlen;
((char*)req->ptr)[size] = '\0';
size++;
req->result++;
}

r = closedir(dir);
Expand Down

0 comments on commit b6ede6c

Please sign in to comment.