|
|
@ -49,7 +49,18 @@ using namespace v8; |
|
|
|
#define THROW_BAD_ARGS \ |
|
|
|
ThrowException(Exception::TypeError(String::New("Bad argument"))) |
|
|
|
|
|
|
|
typedef class ReqWrap<uv_fs_t> FSReqWrap; |
|
|
|
class FSReqWrap: public ReqWrap<uv_fs_t> { |
|
|
|
public: |
|
|
|
FSReqWrap(const char* syscall) |
|
|
|
: syscall_(syscall) { |
|
|
|
} |
|
|
|
|
|
|
|
const char* syscall() { return syscall_; } |
|
|
|
|
|
|
|
private: |
|
|
|
const char* syscall_; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static Persistent<String> encoding_symbol; |
|
|
|
static Persistent<String> errno_symbol; |
|
|
@ -86,11 +97,13 @@ static void After(uv_fs_t *req) { |
|
|
|
// If the request doesn't have a path parameter set.
|
|
|
|
|
|
|
|
if (!req->path) { |
|
|
|
argv[0] = UVException(req->errorno); |
|
|
|
} else { |
|
|
|
argv[0] = UVException(req->errorno, |
|
|
|
NULL, |
|
|
|
req_wrap->syscall()); |
|
|
|
} else { |
|
|
|
argv[0] = UVException(req->errorno, |
|
|
|
NULL, |
|
|
|
req_wrap->syscall(), |
|
|
|
static_cast<const char*>(req->path)); |
|
|
|
} |
|
|
|
} else { |
|
|
@ -206,7 +219,7 @@ struct fs_req_wrap { |
|
|
|
|
|
|
|
|
|
|
|
#define ASYNC_CALL(func, callback, ...) \ |
|
|
|
FSReqWrap* req_wrap = new FSReqWrap(); \ |
|
|
|
FSReqWrap* req_wrap = new FSReqWrap(#func); \ |
|
|
|
int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \ |
|
|
|
__VA_ARGS__, After); \ |
|
|
|
assert(r == 0); \ |
|
|
|