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

Added uv_fs_req_result method #1307

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,9 @@ UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,
UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);

/* this method is only useful for binding libraries (just return req->result) */
UV_EXTERN int uv_fs_req_result(uv_fs_t* req);
UV_EXTERN uv_stat_t* uv_fs_req_stat(uv_fs_t* req);

enum uv_fs_event {
UV_RENAME = 1,
Expand Down
8 changes: 8 additions & 0 deletions src/uv-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,11 @@ int uv_fs_event_getpath(uv_fs_event_t* handle, char* buf, size_t* len) {

return 0;
}

int uv_fs_req_result(uv_fs_t* req) {
return req->result;
}

uv_stat_t* uv_fs_req_stat(uv_fs_t* req) {
return &(req->statbuf);
}
46 changes: 27 additions & 19 deletions test/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,33 +181,41 @@ enum test_status {
#endif


#if defined _WIN32 && ! defined __GNUC__
#ifdef _MSC_VER

#include <stdarg.h>

/* Emulate snprintf() on Windows, _snprintf() doesn't zero-terminate the buffer
* on overflow...
*/
static int snprintf(char* buf, size_t len, const char* fmt, ...) {
va_list ap;
int n;

va_start(ap, fmt);
n = _vsprintf_p(buf, len, fmt, ap);
va_end(ap);

/* It's a sad fact of life that no one ever checks the return value of
* snprintf(). Zero-terminating the buffer hopefully reduces the risk
* of gaping security holes.
*/
if (n < 0)
if (len > 0)
buf[0] = '\0';

return n;

#define snprintf c99_snprintf

inline int c99_snprintf(char* str, size_t size, const char* format, ...)
{
int count;
va_list ap;

va_start(ap, format);
count = c99_vsnprintf(str, size, format, ap);
va_end(ap);

return count;
}

#endif
inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
{
int count = -1;

if (size != 0)
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);

return count;
}

#endif // _MSC_VER

#if defined(__clang__) || \
defined(__GNUC__) || \
Expand Down