Showing with 82 additions and 83 deletions.
  1. +6 −6 docs/src/fs.rst
  2. +3 −3 include/uv.h
  3. +9 −10 src/unix/fs.c
  4. +2 −2 src/uv-common.c
  5. +1 −1 src/uv-common.h
  6. +5 −5 src/win/fs.c
  7. +51 −51 test/test-fs.c
  8. +4 −4 test/test-list.h
  9. +1 −1 test/test-threadpool-cancel.c
@@ -74,7 +74,7 @@ Data types
UV_FS_MKDIR,
UV_FS_MKDTEMP,
UV_FS_RENAME,
UV_FS_READDIR,
UV_FS_SCANDIR,
UV_FS_LINK,
UV_FS_SYMLINK,
UV_FS_READLINK,
@@ -85,7 +85,7 @@ Data types
.. c:type:: uv_dirent_t
Cross platform (reduced) equivalent of ``struct dirent``.
Used in :c:func:`uv_fs_readdir_next`.
Used in :c:func:`uv_fs_scandir_next`.

::

@@ -183,11 +183,11 @@ API
Equivalent to ``rmdir(2)``.
.. c:function:: int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb)
.. c:function:: int uv_fs_readdir_next(uv_fs_t* req, uv_dirent_t* ent)
.. c:function:: int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb)
.. c:function:: int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent)
Equivalent to ``readdir(2)``, with a slightly different API. Once the callback
for the request is called, the user can use :c:func:`uv_fs_readdir_next` to
Equivalent to ``scandir(3)``, with a slightly different API. Once the callback
for the request is called, the user can use :c:func:`uv_fs_scandir_next` to
get `ent` populated with the next directory entry data. When there are no
more entries ``UV_EOF`` will be returned.
@@ -1031,7 +1031,7 @@ typedef enum {
UV_FS_MKDIR,
UV_FS_MKDTEMP,
UV_FS_RENAME,
UV_FS_READDIR,
UV_FS_SCANDIR,
UV_FS_LINK,
UV_FS_SYMLINK,
UV_FS_READLINK,
@@ -1094,12 +1094,12 @@ UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
uv_fs_cb cb);
UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
int flags,
uv_fs_cb cb);
UV_EXTERN int uv_fs_readdir_next(uv_fs_t* req,
UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
uv_dirent_t* ent);
UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
uv_fs_t* req,
@@ -295,22 +295,21 @@ static ssize_t uv__fs_read(uv_fs_t* req) {


#if defined(__OpenBSD__) || (defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8))
static int uv__fs_readdir_filter(uv__dirent_t* dent) {
static int uv__fs_scandir_filter(uv__dirent_t* dent) {
#else
static int uv__fs_readdir_filter(const uv__dirent_t* dent) {
static int uv__fs_scandir_filter(const uv__dirent_t* dent) {
#endif
return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0;
}


/* This should have been called uv__fs_scandir(). */
static ssize_t uv__fs_readdir(uv_fs_t* req) {
static ssize_t uv__fs_scandir(uv_fs_t* req) {
uv__dirent_t **dents;
int saved_errno;
int n;

dents = NULL;
n = scandir(req->path, &dents, uv__fs_readdir_filter, alphasort);
n = scandir(req->path, &dents, uv__fs_scandir_filter, alphasort);

/* NOTE: We will use nbufs as an index field */
req->nbufs = 0;
@@ -779,7 +778,7 @@ static void uv__fs_work(struct uv__work* w) {
X(MKDIR, mkdir(req->path, req->mode));
X(MKDTEMP, uv__fs_mkdtemp(req));
X(READ, uv__fs_read(req));
X(READDIR, uv__fs_readdir(req));
X(SCANDIR, uv__fs_scandir(req));
X(READLINK, uv__fs_readlink(req));
X(RENAME, rename(req->path, req->new_path));
X(RMDIR, rmdir(req->path));
@@ -1040,12 +1039,12 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
}


int uv_fs_readdir(uv_loop_t* loop,
int uv_fs_scandir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
int flags,
uv_fs_cb cb) {
INIT(READDIR);
INIT(SCANDIR);
PATH;
req->flags = flags;
POST;
@@ -1167,8 +1166,8 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
req->path = NULL;
req->new_path = NULL;

if (req->fs_type == UV_FS_READDIR && req->ptr != NULL)
uv__fs_readdir_cleanup(req);
if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL)
uv__fs_scandir_cleanup(req);

if (req->ptr != &req->statbuf)
free(req->ptr);
@@ -437,7 +437,7 @@ int uv_fs_event_getpath(uv_fs_event_t* handle, char* buf, size_t* len) {
}


void uv__fs_readdir_cleanup(uv_fs_t* req) {
void uv__fs_scandir_cleanup(uv_fs_t* req) {
uv__dirent_t** dents;

dents = req->ptr;
@@ -448,7 +448,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
}


int uv_fs_readdir_next(uv_fs_t* req, uv_dirent_t* ent) {
int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) {
uv__dirent_t** dents;
uv__dirent_t* dent;

@@ -109,7 +109,7 @@ size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs);

int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value);

void uv__fs_readdir_cleanup(uv_fs_t* req);
void uv__fs_scandir_cleanup(uv_fs_t* req);

#define uv__has_active_reqs(loop) \
(QUEUE_EMPTY(&(loop)->active_reqs) == 0)
@@ -783,7 +783,7 @@ void fs__mkdtemp(uv_fs_t* req) {
}


void fs__readdir(uv_fs_t* req) {
void fs__scandir(uv_fs_t* req) {
WCHAR* pathw = req->pathw;
size_t len = wcslen(pathw);
int result;
@@ -1604,7 +1604,7 @@ static void uv__fs_work(struct uv__work* w) {
XX(MKDIR, mkdir)
XX(MKDTEMP, mkdtemp)
XX(RENAME, rename)
XX(READDIR, readdir)
XX(SCANDIR, scandir)
XX(LINK, link)
XX(SYMLINK, symlink)
XX(READLINK, readlink)
@@ -1839,11 +1839,11 @@ int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
}


int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
uv_fs_cb cb) {
int err;

uv_fs_req_init(loop, req, UV_FS_READDIR, cb);
uv_fs_req_init(loop, req, UV_FS_SCANDIR, cb);

err = fs__capture_path(loop, req, path, NULL, cb != NULL);
if (err) {
@@ -1856,7 +1856,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
QUEUE_FS_TP_JOB(loop, req);
return 0;
} else {
fs__readdir(req);
fs__scandir(req);
return req->result;
}
}