Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Upgrade libuv to b6ede6c

Fixes require('fs').readdirSync on unix.
  • Loading branch information...
ry committed Sep 5, 2011
1 parent e20d0c1 commit 01bf209a3d8e89143739a0a9c5b4c523fb28e383
Showing with 17 additions and 2 deletions.
  1. +12 −1 deps/uv/src/unix/fs.c
  2. +5 −1 deps/uv/test/test-fs.c
@@ -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);
@@ -540,6 +540,10 @@ TEST_IMPL(fs_async_dir) {
uv_run(loop);
ASSERT(readdir_cb_count == 1);

/* sync uv_fs_readdir */
r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, NULL);
readdir_cb(&readdir_req);

r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
uv_run(loop);
@@ -1050,4 +1054,4 @@ TEST_IMPL(fs_symlink) {
unlink("test_file_symlink2_symlink");

return 0;
}
}

0 comments on commit 01bf209

Please sign in to comment.
You can’t perform that action at this time.