Alien-uv

 view release on metacpan or  search on metacpan

libuv/ChangeLog  view on Meta::CPAN

1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
Changes since version 1.10.0:
 
* Now working on version 1.10.1 (cjihrig)
 
* win: fix anonymous union syntax (Brad King)
 
* unix: use uv__is_closing everywhere (Santiago Gimeno)
 
* win: add missing break statement (cjihrig)
 
* doc: fix wrong man page link for uv_fs_lstat() (Michele Caini)
 
* win, tty: handle empty buffer in uv_tty_write_bufs (Hitesh Kanwathirtha)
 
* doc: add cjihrig alternative GPG ID (cjihrig)
 
* Revert "win,tty: add support for ANSI codes in win10 v1511" (Ben Noordhuis)
 
 
2016.10.25, Version 1.10.0 (Stable), c8a373c729b4c9392e0e14fc53cd6b67b3051ab9

libuv/docs/src/fs.rst  view on Meta::CPAN

274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    get `ent` populated with the next directory entry data. When there are no
    more entries ``UV_EOF`` will be returned.
 
    .. note::
        Unlike `scandir(3)`, this function does not return the "." and ".." entries.
 
    .. note::
        On Linux, getting the type of an entry is only supported by some file systems (btrfs, ext2,
        ext3 and ext4 at the time of this writing), check the :man:`getdents(2)` man page.
 
.. c:function:: int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
.. c:function:: int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
.. c:function:: int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
 
    Equivalent to :man:`stat(2)`, :man:`fstat(2)` and :man:`lstat(2)` respectively.
 
.. c:function:: int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb)
 
    Equivalent to :man:`rename(2)`.
 
.. c:function:: int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
 
    Equivalent to :man:`fsync(2)`.
 
    .. note::

libuv/docs/src/fs_event.rst  view on Meta::CPAN

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
* By default, if the fs event watcher is given a directory name, we will
* watch for all events in that directory. This flags overrides this behavior
* and makes fs_event report only changes to the directory entry itself. This
* flag does not affect individual files watched.
* This flag is currently not implemented yet on any backend.
*/
UV_FS_EVENT_WATCH_ENTRY = 1,
/*
* By default uv_fs_event will try to use a kernel interface such as inotify
* or kqueue to detect events. This may not work on remote file systems such
* as NFS mounts. This flag makes fs_event fall back to calling stat() on a
* regular interval.
* This flag is currently not implemented yet on any backend.
*/
UV_FS_EVENT_STAT = 2,
/*
* By default, event watcher, when watching directory, is not registering
* (is ignoring) changes in its subdirectories.
* This flag will override this behaviour on platforms that support it.
*/
UV_FS_EVENT_RECURSIVE = 4

libuv/include/uv.h  view on Meta::CPAN

1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
/* uv_fs_t is a subclass of uv_req_t. */
struct uv_fs_s {
  UV_REQ_FIELDS
  uv_fs_type fs_type;
  uv_loop_t* loop;
  uv_fs_cb cb;
  ssize_t result;
  void* ptr;
  const char* path;
  uv_stat_t statbuf;  /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */
  UV_FS_PRIVATE_FIELDS
};
 
UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
 
UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);

libuv/include/uv.h  view on Meta::CPAN

1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
                            const char* path,
                            uv_fs_cb cb);
UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
                            uv_fs_t* req,
                            uv_dir_t* dir,
                            uv_fs_cb cb);
UV_EXTERN int uv_fs_closedir(uv_loop_t* loop,
                             uv_fs_t* req,
                             uv_dir_t* dir,
                             uv_fs_cb cb);
UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
                         uv_fs_t* req,
                         const char* path,
                         uv_fs_cb cb);
UV_EXTERN int uv_fs_fstat(uv_loop_t* loop,
                          uv_fs_t* req,
                          uv_file file,
                          uv_fs_cb cb);
UV_EXTERN int uv_fs_rename(uv_loop_t* loop,
                           uv_fs_t* req,
                           const char* path,
                           const char* new_path,
                           uv_fs_cb cb);
UV_EXTERN int uv_fs_fsync(uv_loop_t* loop,
                          uv_fs_t* req,

libuv/include/uv.h  view on Meta::CPAN

1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
                          const char* path,
                          double atime,
                          double mtime,
                          uv_fs_cb cb);
UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
                           uv_fs_t* req,
                           uv_file file,
                           double atime,
                           double mtime,
                           uv_fs_cb cb);
UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
                          uv_fs_t* req,
                          const char* path,
                          uv_fs_cb cb);
UV_EXTERN int uv_fs_link(uv_loop_t* loop,
                         uv_fs_t* req,
                         const char* path,
                         const char* new_path,
                         uv_fs_cb cb);
 
/*

libuv/include/uv.h  view on Meta::CPAN

1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
struct uv_fs_event_s {
  UV_HANDLE_FIELDS
  /* private */
  char* path;
  UV_FS_EVENT_PRIVATE_FIELDS
};
 
 
/*
 * uv_fs_stat() based polling file watcher.
 */
struct uv_fs_poll_s {
  UV_HANDLE_FIELDS
  /* Private, don't touch. */
  void* poll_ctx;
};
 
UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
                               uv_fs_poll_cb poll_cb,

libuv/include/uv.h  view on Meta::CPAN

1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
* watch for all events in that directory. This flags overrides this behavior
 * and makes fs_event report only changes to the directory entry itself. This
 * flag does not affect individual files watched.
 * This flag is currently not implemented yet on any backend.
 */
UV_FS_EVENT_WATCH_ENTRY = 1,
 
/*
 * By default uv_fs_event will try to use a kernel interface such as inotify
 * or kqueue to detect events. This may not work on remote filesystems such
 * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
 * regular interval.
 * This flag is currently not implemented yet on any backend.
 */
UV_FS_EVENT_STAT = 2,
 
/*
 * By default, event watcher, when watching directory, is not registering
 * (is ignoring) changes in it's subdirectories.
 * This flag will override this behaviour on platforms that support it.
 */

libuv/src/fs-poll.c  view on Meta::CPAN

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
ctx->parent_handle = handle;
memcpy(ctx->path, path, len + 1);
 
err = uv_timer_init(loop, &ctx->timer_handle);
if (err < 0)
  goto error;
 
ctx->timer_handle.flags |= UV_HANDLE_INTERNAL;
uv__handle_unref(&ctx->timer_handle);
 
err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
if (err < 0)
  goto error;
 
if (handle->poll_ctx != NULL)
  ctx->previous = handle->poll_ctx;
handle->poll_ctx = ctx;
uv__handle_start(handle);
 
return 0;

libuv/src/fs-poll.c  view on Meta::CPAN

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
 
static void timer_cb(uv_timer_t* timer) {
  struct poll_ctx* ctx;
 
  ctx = container_of(timer, struct poll_ctx, timer_handle);
  assert(ctx->parent_handle != NULL);
  assert(ctx->parent_handle->poll_ctx == ctx);
  ctx->start_time = uv_now(ctx->loop);
 
  if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb))
    abort();
}
 
 
static void poll_cb(uv_fs_t* req) {
  uv_stat_t* statbuf;
  struct poll_ctx* ctx;
  uint64_t interval;
  uv_fs_poll_t* handle;

libuv/src/fs-poll.c  view on Meta::CPAN

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
  ctx->busy_polling = 1;
 
out:
  uv_fs_req_cleanup(req);
 
  if (!uv_is_active((uv_handle_t*)handle) || uv__is_closing(handle)) {
    uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
    return;
  }
 
  /* Reschedule timer, subtract the delay from doing the stat(). */
  interval = ctx->interval;
  interval -= (uv_now(ctx->loop) - ctx->start_time) % interval;
 
  if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0))
    abort();
}
 
 
static void timer_close_cb(uv_handle_t* timer) {
  struct poll_ctx* ctx;

libuv/src/unix/aix.c  view on Meta::CPAN

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/*
 * Determine whether given pathname is a directory
 * Returns 0 if the path is a directory, -1 if not
 *
 * Note: Opportunity here for more detailed error information but
 *       that requires changing callers of this function as well
 */
static int uv__path_is_a_directory(char* filename) {
  struct stat statbuf;
 
  if (stat(filename, &statbuf) < 0)
    return -1;  /* failed: not a directory, assume it is a file */
 
  if (statbuf.st_type == VDIR)
    return 0;
 
  return -1;
}
 
 
/*

libuv/src/unix/fs.c  view on Meta::CPAN

326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
    uv__free(req->bufs);
 
  req->bufs = NULL;
  req->nbufs = 0;
 
#ifdef __PASE__
  /* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */
  if (result == -1 && errno == EOPNOTSUPP) {
    struct stat buf;
    ssize_t rc;
    rc = fstat(req->file, &buf);
    if (rc == 0 && S_ISDIR(buf.st_mode)) {
      errno = EISDIR;
    }
  }
#endif
 
  return result;
}

libuv/src/unix/fs.c  view on Meta::CPAN

490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
static ssize_t uv__fs_readlink(uv_fs_t* req) {
  ssize_t maxlen;
  ssize_t len;
  char* buf;
  char* newbuf;
 
#if defined(UV__FS_PATH_MAX_FALLBACK)
  /* We may not have a real PATH_MAX.  Read size of link.  */
  struct stat st;
  int ret;
  ret = lstat(req->path, &st);
  if (ret != 0)
    return -1;
  if (!S_ISLNK(st.st_mode)) {
    errno = EINVAL;
    return -1;
  }
 
  maxlen = st.st_size;
 
  /* According to readlink(2) lstat can report st_size == 0

libuv/src/unix/fs.c  view on Meta::CPAN

914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
err = 0;
 
/* Open the source file. */
srcfd = uv_fs_open(NULL, &fs_req, req->path, O_RDONLY, 0, NULL);
uv_fs_req_cleanup(&fs_req);
 
if (srcfd < 0)
  return srcfd;
 
/* Get the source file's mode. */
if (fstat(srcfd, &statsbuf)) {
  err = UV__ERR(errno);
  goto out;
}
 
dst_flags = O_WRONLY | O_CREAT | O_TRUNC;
 
if (req->flags & UV_FS_COPYFILE_EXCL)
  dst_flags |= O_EXCL;
 
/* Open the destination file. */

libuv/src/unix/fs.c  view on Meta::CPAN

1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
    }
  }
 
  if (result == 0)
    return 0;
 
  errno = UV__ERR(result);
  return -1;
}
 
static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
  dst->st_dev = src->st_dev;
  dst->st_mode = src->st_mode;
  dst->st_nlink = src->st_nlink;
  dst->st_uid = src->st_uid;
  dst->st_gid = src->st_gid;
  dst->st_rdev = src->st_rdev;
  dst->st_ino = src->st_ino;
  dst->st_size = src->st_size;
  dst->st_blksize = src->st_blksize;
  dst->st_blocks = src->st_blocks;

libuv/src/unix/fs.c  view on Meta::CPAN

1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
  buf->st_birthtim.tv_sec = statxbuf.stx_btime.tv_sec;
  buf->st_birthtim.tv_nsec = statxbuf.stx_btime.tv_nsec;
 
  return 0;
#else
  return UV_ENOSYS;
#endif /* __linux__ */
}
 
 
static int uv__fs_stat(const char *path, uv_stat_t *buf) {
  struct stat pbuf;
  int ret;
 
  ret = uv__fs_statx(-1, path, /* is_fstat */ 0, /* is_lstat */ 0, buf);
  if (ret != UV_ENOSYS)
    return ret;
 
  ret = stat(path, &pbuf);
  if (ret == 0)
    uv__to_stat(&pbuf, buf);
 
  return ret;
}
 
 
static int uv__fs_lstat(const char *path, uv_stat_t *buf) {
  struct stat pbuf;
  int ret;
 
  ret = uv__fs_statx(-1, path, /* is_fstat */ 0, /* is_lstat */ 1, buf);
  if (ret != UV_ENOSYS)
    return ret;
 
  ret = lstat(path, &pbuf);
  if (ret == 0)
    uv__to_stat(&pbuf, buf);
 
  return ret;
}
 
 
static int uv__fs_fstat(int fd, uv_stat_t *buf) {
  struct stat pbuf;
  int ret;
 
  ret = uv__fs_statx(fd, "", /* is_fstat */ 1, /* is_lstat */ 0, buf);
  if (ret != UV_ENOSYS)
    return ret;
 
  ret = fstat(fd, &pbuf);
  if (ret == 0)
    uv__to_stat(&pbuf, buf);
 
  return ret;
}
 
static size_t uv__fs_buf_offset(uv_buf_t* bufs, size_t size) {
  size_t offset;
  /* Figure out which bufs are done */
  for (offset = 0; size > 0 && bufs[offset].len <= size; ++offset)
    size -= bufs[offset].len;

libuv/src/unix/fs.c  view on Meta::CPAN

1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
    switch (req->fs_type) {
    X(ACCESS, access(req->path, req->flags));
    X(CHMOD, chmod(req->path, req->mode));
    X(CHOWN, chown(req->path, req->uid, req->gid));
    X(CLOSE, uv__fs_close(req->file));
    X(COPYFILE, uv__fs_copyfile(req));
    X(FCHMOD, fchmod(req->file, req->mode));
    X(FCHOWN, fchown(req->file, req->uid, req->gid));
    X(LCHOWN, lchown(req->path, req->uid, req->gid));
    X(FDATASYNC, uv__fs_fdatasync(req));
    X(FSTAT, uv__fs_fstat(req->file, &req->statbuf));
    X(FSYNC, uv__fs_fsync(req));
    X(FTRUNCATE, ftruncate(req->file, req->off));
    X(FUTIME, uv__fs_futime(req));
    X(LSTAT, uv__fs_lstat(req->path, &req->statbuf));
    X(LINK, link(req->path, req->new_path));
    X(MKDIR, mkdir(req->path, req->mode));
    X(MKDTEMP, uv__fs_mkdtemp(req));
    X(OPEN, uv__fs_open(req));
    X(READ, uv__fs_read(req));
    X(SCANDIR, uv__fs_scandir(req));
    X(OPENDIR, uv__fs_opendir(req));
    X(READDIR, uv__fs_readdir(req));
    X(CLOSEDIR, uv__fs_closedir(req));
    X(READLINK, uv__fs_readlink(req));
    X(REALPATH, uv__fs_realpath(req));
    X(RENAME, rename(req->path, req->new_path));
    X(RMDIR, rmdir(req->path));
    X(SENDFILE, uv__fs_sendfile(req));
    X(STAT, uv__fs_stat(req->path, &req->statbuf));
    X(SYMLINK, symlink(req->path, req->new_path));
    X(UNLINK, unlink(req->path));
    X(UTIME, uv__fs_utime(req));
    X(WRITE, uv__fs_write_all(req));
    default: abort();
    }
#undef X
  } while (r == -1 && errno == EINTR && retry_on_eintr);
 
  if (r == -1)

libuv/src/unix/fs.c  view on Meta::CPAN

1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
}
 
 
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
  INIT(FDATASYNC);
  req->file = file;
  POST;
}
 
 
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
  INIT(FSTAT);
  req->file = file;
  POST;
}
 
 
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
  INIT(FSYNC);
  req->file = file;
  POST;

libuv/src/unix/fs.c  view on Meta::CPAN

1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
                 double mtime,
                 uv_fs_cb cb) {
  INIT(FUTIME);
  req->file = file;
  req->atime = atime;
  req->mtime = mtime;
  POST;
}
 
 
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
  INIT(LSTAT);
  PATH;
  POST;
}
 
 
int uv_fs_link(uv_loop_t* loop,
               uv_fs_t* req,
               const char* path,
               const char* new_path,

libuv/src/unix/fs.c  view on Meta::CPAN

1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
                   uv_fs_cb cb) {
  INIT(SENDFILE);
  req->flags = in_fd; /* hack */
  req->file = out_fd;
  req->off = off;
  req->bufsml[0].len = len;
  POST;
}
 
 
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
  INIT(STAT);
  PATH;
  POST;
}
 
 
int uv_fs_symlink(uv_loop_t* loop,
                  uv_fs_t* req,
                  const char* path,
                  const char* new_path,

libuv/src/unix/pipe.c  view on Meta::CPAN

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
if (name_buffer == NULL)
  return UV_ENOMEM;
 
r = uv_pipe_getsockname(handle, name_buffer, &name_len);
if (r != 0) {
  uv__free(name_buffer);
  return r;
}
 
/* stat must be used as fstat has a bug on Darwin */
if (stat(name_buffer, &pipe_stat) == -1) {
  uv__free(name_buffer);
  return -errno;
}
 
desired_mode = 0;
if (mode & UV_READABLE)
  desired_mode |= S_IRUSR | S_IRGRP | S_IROTH;
if (mode & UV_WRITABLE)
  desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH;

libuv/src/unix/tty.c  view on Meta::CPAN

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Lookup device's major for the pts driver and cache it. */
static devmajor_t pts = NODEVMAJOR;
 
if (pts == NODEVMAJOR) {
  pts = getdevmajor("pts", S_IFCHR);
  if (pts == NODEVMAJOR)
    abort();
}
 
/* Lookup stat structure behind the file descriptor. */
if (fstat(fd, &sb) != 0)
  abort();
 
/* Assert character device. */
if (!S_ISCHR(sb.st_mode))
  abort();
 
/* Assert valid major. */
if (major(sb.st_rdev) == NODEVMAJOR)
  abort();

libuv/src/unix/tty.c  view on Meta::CPAN

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
struct stat s;
socklen_t len;
int type;
 
if (file < 0)
  return UV_UNKNOWN_HANDLE;
 
if (isatty(file))
  return UV_TTY;
 
if (fstat(file, &s))
  return UV_UNKNOWN_HANDLE;
 
if (S_ISREG(s.st_mode))
  return UV_FILE;
 
if (S_ISCHR(s.st_mode))
  return UV_FILE;  /* XXX UV_NAMED_PIPE? */
 
if (S_ISFIFO(s.st_mode))
  return UV_NAMED_PIPE;

libuv/src/win/fs.c  view on Meta::CPAN

1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
    CloseHandle(handle);
    return;
  }
 
  req->ptr = &req->statbuf;
  req->result = 0;
  CloseHandle(handle);
}
 
 
static void fs__stat(uv_fs_t* req) {
  fs__stat_prepare_path(req->file.pathw);
  fs__stat_impl(req, 0);
}
 
 
static void fs__lstat(uv_fs_t* req) {
  fs__stat_prepare_path(req->file.pathw);
  fs__stat_impl(req, 1);
}
 
 
static void fs__fstat(uv_fs_t* req) {
  int fd = req->file.fd;
  HANDLE handle;
 
  VERIFY_FD(fd, req);
 
  handle = uv__get_osfhandle(fd);
 
  if (handle == INVALID_HANDLE_VALUE) {
    SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE);
    return;

libuv/src/win/fs.c  view on Meta::CPAN

2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
  INIT(UV_FS_LCHOWN);
  err = fs__capture_path(req, path, NULL, cb != NULL);
  if (err) {
    return uv_translate_sys_error(err);
  }
  POST;
}
 
 
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
  int err;
 
  INIT(UV_FS_STAT);
  err = fs__capture_path(req, path, NULL, cb != NULL);
  if (err) {
    return uv_translate_sys_error(err);
  }
 
  POST;
}
 
 
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
  int err;
 
  INIT(UV_FS_LSTAT);
  err = fs__capture_path(req, path, NULL, cb != NULL);
  if (err) {
    return uv_translate_sys_error(err);
  }
 
  POST;
}
 
 
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) {
  INIT(UV_FS_FSTAT);
  req->file.fd = fd;
  POST;
}
 
 
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
    const char* new_path, uv_fs_cb cb) {
  int err;

libuv/test/benchmark-fs-stat.c  view on Meta::CPAN

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "task.h"
#include "uv.h"
 
#include <stdio.h>
#include <stdlib.h>
 
#define NUM_SYNC_REQS         (10 * 1e5)
#define NUM_ASYNC_REQS        (1 * (int) 1e5)
#define MAX_CONCURRENT_REQS   32
 
#define sync_stat(req, path)                                                  \
  do {                                                                        \
    uv_fs_stat(NULL, (req), (path), NULL);                                    \
    uv_fs_req_cleanup((req));                                                 \
  }                                                                           \
  while (0)
 
struct async_req {
  const char* path;
  uv_fs_t fs_req;
  int* count;
};
 
 
static void warmup(const char* path) {
  uv_fs_t reqs[MAX_CONCURRENT_REQS];
  unsigned int i;
 
  /* warm up the thread pool */
  for (i = 0; i < ARRAY_SIZE(reqs); i++)
    uv_fs_stat(uv_default_loop(), reqs + i, path, uv_fs_req_cleanup);
 
  uv_run(uv_default_loop(), UV_RUN_DEFAULT);
 
  /* warm up the OS dirent cache */
  for (i = 0; i < 16; i++)
    sync_stat(reqs + 0, path);
}
 
 
static void sync_bench(const char* path) {
  uint64_t before;
  uint64_t after;
  uv_fs_t req;
  int i;
 
  /* do the sync benchmark */
  before = uv_hrtime();
 
  for (i = 0; i < NUM_SYNC_REQS; i++)
    sync_stat(&req, path);
 
  after = uv_hrtime();
 
  printf("%s stats (sync): %.2fs (%s/s)\n",
         fmt(1.0 * NUM_SYNC_REQS),
         (after - before) / 1e9,
         fmt((1.0 * NUM_SYNC_REQS) / ((after - before) / 1e9)));
  fflush(stdout);
}
 
 
static void stat_cb(uv_fs_t* fs_req) {
  struct async_req* req = container_of(fs_req, struct async_req, fs_req);
  uv_fs_req_cleanup(&req->fs_req);
  if (*req->count == 0) return;
  uv_fs_stat(uv_default_loop(), &req->fs_req, req->path, stat_cb);
  (*req->count)--;
}
 
 
static void async_bench(const char* path) {
  struct async_req reqs[MAX_CONCURRENT_REQS];
  struct async_req* req;
  uint64_t before;
  uint64_t after;
  int count;
  int i;
 
  for (i = 1; i <= MAX_CONCURRENT_REQS; i++) {
    count = NUM_ASYNC_REQS;
 
    for (req = reqs; req < reqs + i; req++) {
      req->path = path;
      req->count = &count;
      uv_fs_stat(uv_default_loop(), &req->fs_req, req->path, stat_cb);
    }
 
    before = uv_hrtime();
    uv_run(uv_default_loop(), UV_RUN_DEFAULT);
    after = uv_hrtime();
 
    printf("%s stats (%d concurrent): %.2fs (%s/s)\n",
           fmt(1.0 * NUM_ASYNC_REQS),
           i,
           (after - before) / 1e9,
           fmt((1.0 * NUM_ASYNC_REQS) / ((after - before) / 1e9)));
    fflush(stdout);
  }
}
 
 
/* This benchmark aims to measure the overhead of doing I/O syscalls from
 * the thread pool. The stat() syscall was chosen because its results are
 * easy for the operating system to cache, taking the actual I/O overhead
 * out of the equation.
 */
BENCHMARK_IMPL(fs_stat) {
  const char path[] = ".";
  warmup(path);
  sync_bench(path);
  async_bench(path);
  MAKE_VALGRIND_HAPPY();
  return 0;

libuv/test/runner-unix.c  view on Meta::CPAN

343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
  close(args.pipe[1]);
  return retval;
}
 
 
/* Returns the number of bytes in the stdio output buffer for process `p`. */
long int process_output_size(process_info_t *p) {
  /* Size of the p->stdout_file */
  struct stat buf;
 
  int r = fstat(fileno(p->stdout_file), &buf);
  if (r < 0) {
    return -1;
  }
 
  return (long)buf.st_size;
}
 
 
/* Copy the contents of the stdio output buffer to `fd`. */
int process_copy_output(process_info_t* p, FILE* stream) {

libuv/test/test-fs-copyfile.c  view on Meta::CPAN

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
static void handle_result(uv_fs_t* req) {
  uv_fs_t stat_req;
  uint64_t size;
  uint64_t mode;
  int r;
 
  ASSERT(req->fs_type == UV_FS_COPYFILE);
  ASSERT(req->result == 0);
 
  /* Verify that the file size and mode are the same. */
  r = uv_fs_stat(NULL, &stat_req, req->path, NULL);
  ASSERT(r == 0);
  size = stat_req.statbuf.st_size;
  mode = stat_req.statbuf.st_mode;
  uv_fs_req_cleanup(&stat_req);
  r = uv_fs_stat(NULL, &stat_req, dst, NULL);
  ASSERT(r == 0);
  ASSERT(stat_req.statbuf.st_size == size);
  ASSERT(stat_req.statbuf.st_mode == mode);
  uv_fs_req_cleanup(&stat_req);
  uv_fs_req_cleanup(req);
  result_check_count++;
}
 
 
static void touch_file(const char* name, unsigned int size) {

libuv/test/test-fs-copyfile.c  view on Meta::CPAN

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
uv_fs_req_cleanup(&req);
 
/* Fails with ENOENT if source does not exist. */
unlink(src);
unlink(dst);
r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL);
ASSERT(req.result == UV_ENOENT);
ASSERT(r == UV_ENOENT);
uv_fs_req_cleanup(&req);
/* The destination should not exist. */
r = uv_fs_stat(NULL, &req, dst, NULL);
ASSERT(r != 0);
uv_fs_req_cleanup(&req);
 
/* Copies file synchronously. Creates new file. */
unlink(dst);
r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL);
ASSERT(r == 0);
handle_result(&req);
 
/* Copies a file of size zero. */

libuv/test/test-fs-event.c  view on Meta::CPAN

488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
loop = uv_default_loop();
remove("watch_dir/file1");
remove("watch_dir/");
create_dir("watch_dir");
create_file("watch_dir/file1");
 
/* Newer version of Windows ship with
   HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation
   not equal to 0. So we verify the files we created are addressable by a 8.3
   short name */
has_shortnames = uv_fs_stat(NULL, &req, "watch_~1", NULL) != UV_ENOENT;
if (has_shortnames) {
  r = uv_fs_event_init(loop, &fs_event);
  ASSERT(r == 0);
  r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_~1", 0);
  ASSERT(r == 0);
  r = uv_timer_init(loop, &timer);
  ASSERT(r == 0);
  r = uv_timer_start(&timer, timer_cb_file, 100, 0);
  ASSERT(r == 0);

libuv/test/test-fs.c  view on Meta::CPAN

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
static GUID REPARSE_GUID = {
  0x1bf6205f, 0x46ae, 0x4527,
  { 0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }};
#endif
 
static void check_permission(const char* filename, unsigned int mode) {
  int r;
  uv_fs_t req;
  uv_stat_t* s;
 
  r = uv_fs_stat(NULL, &req, filename, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
 
  s = &req.statbuf;
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MSYS__)
  /*
   * On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit,
   * so only testing for the specified flags.
   */
  ASSERT((s->st_mode & 0777) & mode);

libuv/test/test-fs.c  view on Meta::CPAN

483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
  ASSERT(req->fs_type == UV_FS_MKDTEMP);
  ASSERT(req->result == 0);
  ASSERT(req->path);
  ASSERT(strlen(req->path) == 15);
  ASSERT(memcmp(req->path, "test_dir_", 9) == 0);
  ASSERT(memcmp(req->path + 9, "XXXXXX", 6) != 0);
  check_permission(req->path, 0700);
 
  /* Check if req->path is actually a directory */
  r = uv_fs_stat(NULL, &stat_req, req->path, NULL);
  ASSERT(r == 0);
  ASSERT(((uv_stat_t*)stat_req.ptr)->st_mode & S_IFDIR);
  uv_fs_req_cleanup(&stat_req);
}
 
 
static void mkdtemp_cb(uv_fs_t* req) {
  ASSERT(req == &mkdtemp_req1);
  check_mkdtemp_result(req);
  mkdtemp_cb_count++;

libuv/test/test-fs.c  view on Meta::CPAN

724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
  MAKE_VALGRIND_HAPPY();
  return 0;
}
 
static void check_utime(const char* path, double atime, double mtime) {
  uv_stat_t* s;
  uv_fs_t req;
  int r;
 
  r = uv_fs_stat(loop, &req, path, NULL);
  ASSERT(r == 0);
 
  ASSERT(req.result == 0);
  s = &req.statbuf;
 
  ASSERT(s->st_atim.tv_sec + (s->st_atim.tv_nsec / 1000000000.0) == atime);
  ASSERT(s->st_mtim.tv_sec + (s->st_mtim.tv_nsec / 1000000000.0) == mtime);
 
  uv_fs_req_cleanup(&req);
}

libuv/test/test-fs.c  view on Meta::CPAN

999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
ASSERT(r == 2);
ASSERT(scandir_req.result == 2);
ASSERT(scandir_req.ptr);
while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) {
  ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
  assert_is_file_type(dent);
}
uv_fs_req_cleanup(&scandir_req);
ASSERT(!scandir_req.ptr);
 
r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
 
r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
 
r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
 
r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
 
ASSERT(stat_cb_count == 4);
 
r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(unlink_cb_count == 1);

libuv/test/test-fs.c  view on Meta::CPAN

1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
  ASSERT(sendfile_cb_count == 1);
 
  r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&close_req);
  r = uv_fs_close(NULL, &close_req, open_req2.result, NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&close_req);
 
  stat("test_file", &s1);
  stat("test_file2", &s2);
  ASSERT(65546 == s2.st_size && s1.st_size == s2.st_size);
 
  /* Cleanup. */
  unlink("test_file");
  unlink("test_file2");
 
  MAKE_VALGRIND_HAPPY();
  return 0;
}

libuv/test/test-fs.c  view on Meta::CPAN

1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
  ASSERT(req.result >= 0);
  file = req.result;
  uv_fs_req_cleanup(&req);
 
  iov = uv_buf_init(test_buf, sizeof(test_buf));
  r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
  ASSERT(r == sizeof(test_buf));
  ASSERT(req.result == sizeof(test_buf));
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_fstat(NULL, &req, file, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  s = req.ptr;
  ASSERT(s->st_size == sizeof(test_buf));
 
#ifndef _WIN32
  r = fstat(file, &t);
  ASSERT(r == 0);
 
  ASSERT(s->st_dev == (uint64_t) t.st_dev);
  ASSERT(s->st_mode == (uint64_t) t.st_mode);
  ASSERT(s->st_nlink == (uint64_t) t.st_nlink);
  ASSERT(s->st_uid == (uint64_t) t.st_uid);
  ASSERT(s->st_gid == (uint64_t) t.st_gid);
  ASSERT(s->st_rdev == (uint64_t) t.st_rdev);
  ASSERT(s->st_ino == (uint64_t) t.st_ino);
  ASSERT(s->st_size == (uint64_t) t.st_size);

libuv/test/test-fs.c  view on Meta::CPAN

1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
   */
  ASSERT(s->st_birthtim.tv_sec == 0 ||
         s->st_birthtim.tv_sec == t.st_ctim.tv_sec);
  ASSERT(s->st_birthtim.tv_nsec == 0 ||
         s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec);
#endif
 
  uv_fs_req_cleanup(&req);
 
  /* Now do the uv_fs_fstat call asynchronously */
  r = uv_fs_fstat(loop, &req, file, fstat_cb);
  ASSERT(r == 0);
  uv_run(loop, UV_RUN_DEFAULT);
  ASSERT(fstat_cb_count == 1);
 
 
  r = uv_fs_close(NULL, &req, file, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  uv_fs_req_cleanup(&req);

libuv/test/test-fs.c  view on Meta::CPAN

2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
  if (type == UV_FS_SYMLINK_DIR && (r == UV_ENOTSUP || r == UV_EPERM)) {
    uv_fs_req_cleanup(&req);
    RETURN_SKIP("this version of Windows doesn't support unprivileged "
                "creation of directory symlinks");
  }
  fprintf(stderr, "r == %i\n", r);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_stat(NULL, &req, "test_dir_symlink", NULL);
  ASSERT(r == 0);
  ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFDIR);
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_lstat(NULL, &req, "test_dir_symlink", NULL);
  ASSERT(r == 0);
#if defined(__MSYS__)
  RETURN_SKIP("symlink reading is not supported on MSYS2");
#endif
  ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFLNK);
#ifdef _WIN32
  ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir + 4));
#else
  ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir));
#endif

libuv/test/test-fs.c  view on Meta::CPAN

2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
  r = uv_fs_readlink(NULL, &req, "test_dir/test_file", NULL);
  ASSERT(r == UV_EINVAL && GetLastError() == ERROR_SYMLINK_NOT_SUPPORTED);
  uv_fs_req_cleanup(&req);
 
/*
  Placeholder tests for exercising the behavior fixed in issue #995.
  To run, update the path with the IP address of a Mac with the hard drive
  shared via SMB as "Macintosh HD".
 
  r = uv_fs_stat(NULL, &req, "\\\\<mac_ip>\\Macintosh HD\\.DS_Store", NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_lstat(NULL, &req, "\\\\<mac_ip>\\Macintosh HD\\.DS_Store", NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&req);
*/
 
/*
  uv_fs_stat and uv_fs_lstat can only work on non-symlink reparse
  points when a minifilter driver is registered which intercepts
  associated filesystem requests. Installing a driver is beyond
  the scope of this test.
 
  r = uv_fs_stat(NULL, &req, "test_dir/test_file", NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_lstat(NULL, &req, "test_dir/test_file", NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&req);
*/
 
  r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL);
  ASSERT(r == 1);
  ASSERT(scandir_req.result == 1);
  ASSERT(scandir_req.ptr);
  while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) {
    ASSERT(strcmp(dent.name, "test_file") == 0);

libuv/test/test-fs.c  view on Meta::CPAN

2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
   */
#ifdef _WIN32
  mtime += 0.444;            /* 1982-09-10 11:22:33.444 */
#endif
 
  r = uv_fs_utime(NULL, &req, path, atime, mtime, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_stat(NULL, &req, path, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  check_utime(path, atime, mtime);
  uv_fs_req_cleanup(&req);
 
  atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */
  checkme.path = path;
  checkme.atime = atime;
  checkme.mtime = mtime;

libuv/test/test-fs.c  view on Meta::CPAN

2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
  MAKE_VALGRIND_HAPPY();
  return 0;
}
 
 
#ifdef _WIN32
TEST_IMPL(fs_stat_root) {
  int r;
 
  r = uv_fs_stat(NULL, &stat_req, "\\", NULL);
  ASSERT(r == 0);
 
  r = uv_fs_stat(NULL, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL);
  ASSERT(r == 0);
 
  r = uv_fs_stat(NULL, &stat_req, "..", NULL);
  ASSERT(r == 0);
 
  r = uv_fs_stat(NULL, &stat_req, "..\\", NULL);
  ASSERT(r == 0);
 
  /* stats the current directory on c: */
  r = uv_fs_stat(NULL, &stat_req, "c:", NULL);
  ASSERT(r == 0);
 
  r = uv_fs_stat(NULL, &stat_req, "c:\\", NULL);
  ASSERT(r == 0);
 
  r = uv_fs_stat(NULL, &stat_req, "\\\\?\\C:\\", NULL);
  ASSERT(r == 0);
 
  MAKE_VALGRIND_HAPPY();
  return 0;
}
#endif
 
 
TEST_IMPL(fs_futime) {
  utime_check_t checkme;

libuv/test/test-fs.c  view on Meta::CPAN

2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
  r = uv_fs_futime(NULL, &req, file, atime, mtime, NULL);
#if defined(__CYGWIN__) || defined(__MSYS__)
  ASSERT(r == UV_ENOSYS);
  RETURN_SKIP("futime not supported on Cygwin");
#else
  ASSERT(r == 0);
  ASSERT(req.result == 0);
#endif
  uv_fs_req_cleanup(&req);
 
  r = uv_fs_stat(NULL, &req, path, NULL);
  ASSERT(r == 0);
  ASSERT(req.result == 0);
  check_utime(path, atime, mtime);
  uv_fs_req_cleanup(&req);
 
  atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */
 
  checkme.atime = atime;
  checkme.mtime = mtime;
  checkme.path = path;

libuv/test/test-fs.c  view on Meta::CPAN

2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
  return 0;
}
 
 
TEST_IMPL(fs_stat_missing_path) {
  uv_fs_t req;
  int r;
 
  loop = uv_default_loop();
 
  r = uv_fs_stat(NULL, &req, "non_existent_file", NULL);
  ASSERT(r == UV_ENOENT);
  ASSERT(req.result == UV_ENOENT);
  uv_fs_req_cleanup(&req);
 
  MAKE_VALGRIND_HAPPY();
  return 0;
}
 
 
TEST_IMPL(fs_scandir_empty_dir) {

libuv/test/test-fs.c  view on Meta::CPAN

3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount);
 
for (index = 0; index < iovcount; ++index)
  ASSERT(strncmp(buffer + index * sizeof(test_buf),
                 test_buf,
                 sizeof(test_buf)) == 0);
 
uv_fs_req_cleanup(&read_req);
free(buffer);
 
r = uv_fs_stat(NULL, &stat_req, "test_file", NULL);
ASSERT(r == 0);
ASSERT((int64_t)((uv_stat_t*)stat_req.ptr)->st_size ==
       offset + (int64_t)write_req.result);
uv_fs_req_cleanup(&stat_req);
 
iov = uv_buf_init(buf, sizeof(buf));
r = uv_fs_read(NULL,
               &read_req,
               open_req1.result,
               &iov,

libuv/test/test-fs.c  view on Meta::CPAN

3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
r = uv_fs_realpath(NULL, NULL, NULL, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_chown(NULL, NULL, NULL, 0, 0, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_fchown(NULL, NULL, 0, 0, 0, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_stat(NULL, NULL, NULL, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_lstat(NULL, NULL, NULL, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_fstat(NULL, NULL, 0, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_rename(NULL, NULL, NULL, NULL, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_fsync(NULL, NULL, 0, NULL);
ASSERT(r == UV_EINVAL);
 
r = uv_fs_fdatasync(NULL, NULL, 0, NULL);
ASSERT(r == UV_EINVAL);

libuv/test/test-getters-setters.c  view on Meta::CPAN

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 0);
pipe->write_queue_size++;
ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 1);
pipe->write_queue_size--;
uv_close((uv_handle_t*)pipe, NULL);
 
r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
 
fs = malloc(uv_req_size(UV_FS));
uv_fs_stat(loop, fs, ".", NULL);
 
r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
 
ASSERT(uv_fs_get_type(fs) == UV_FS_STAT);
ASSERT(uv_fs_get_result(fs) == 0);
ASSERT(uv_fs_get_ptr(fs) == uv_fs_get_statbuf(fs));
ASSERT(uv_fs_get_statbuf(fs)->st_mode & S_IFDIR);
ASSERT(strcmp(uv_fs_get_path(fs), ".") == 0);
uv_fs_req_cleanup(fs);

libuv/test/test-pipe-set-fchmod.c  view on Meta::CPAN

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  /* No easy way to test if this works, we will only make sure that the call is
   * successful. */
  r = uv_pipe_chmod(&pipe_handle, UV_READABLE);
  if (r == UV_EPERM) {
    MAKE_VALGRIND_HAPPY();
    RETURN_SKIP("Insufficient privileges to alter pipe fmode");
  }
  ASSERT(r == 0);
#ifndef _WIN32
  stat(TEST_PIPENAME, &stat_buf);
  ASSERT(stat_buf.st_mode & S_IRUSR);
  ASSERT(stat_buf.st_mode & S_IRGRP);
  ASSERT(stat_buf.st_mode & S_IROTH);
#endif
 
  r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE);
  ASSERT(r == 0);
#ifndef _WIN32
  stat(TEST_PIPENAME, &stat_buf);
  ASSERT(stat_buf.st_mode & S_IWUSR);
  ASSERT(stat_buf.st_mode & S_IWGRP);
  ASSERT(stat_buf.st_mode & S_IWOTH);
#endif
 
  r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE | UV_READABLE);
  ASSERT(r == 0);
#ifndef _WIN32
  stat(TEST_PIPENAME, &stat_buf);
  ASSERT(stat_buf.st_mode & S_IRUSR);
  ASSERT(stat_buf.st_mode & S_IRGRP);
  ASSERT(stat_buf.st_mode & S_IROTH);
  ASSERT(stat_buf.st_mode & S_IWUSR);
  ASSERT(stat_buf.st_mode & S_IWGRP);
  ASSERT(stat_buf.st_mode & S_IWOTH);
#endif
 
  r = uv_pipe_chmod(NULL, UV_WRITABLE | UV_READABLE);
  ASSERT(r == UV_EBADF);

libuv/test/test-thread.c  view on Meta::CPAN

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  uv_freeaddrinfo(res);
 
  if (--req->counter)
    getaddrinfo_do(req);
}
 
 
static void fs_do(struct fs_req* req) {
  int r;
 
  r = uv_fs_stat(req->loop, &req->handle, ".", fs_cb);
  ASSERT(r == 0);
}
 
 
static void fs_cb(uv_fs_t* handle) {
  struct fs_req* req = container_of(handle, struct fs_req, handle);
 
  uv_fs_req_cleanup(handle);
 
  if (--req->counter)

libuv/test/test-threadpool-cancel.c  view on Meta::CPAN

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
iov = uv_buf_init(NULL, 0);
 
/* Needs to match ARRAY_SIZE(fs_reqs). */
n = 0;
ASSERT(0 == uv_fs_chmod(loop, reqs + n++, "/", 0, fs_cb));
ASSERT(0 == uv_fs_chown(loop, reqs + n++, "/", 0, 0, fs_cb));
ASSERT(0 == uv_fs_close(loop, reqs + n++, 0, fs_cb));
ASSERT(0 == uv_fs_fchmod(loop, reqs + n++, 0, 0, fs_cb));
ASSERT(0 == uv_fs_fchown(loop, reqs + n++, 0, 0, 0, fs_cb));
ASSERT(0 == uv_fs_fdatasync(loop, reqs + n++, 0, fs_cb));
ASSERT(0 == uv_fs_fstat(loop, reqs + n++, 0, fs_cb));
ASSERT(0 == uv_fs_fsync(loop, reqs + n++, 0, fs_cb));
ASSERT(0 == uv_fs_ftruncate(loop, reqs + n++, 0, 0, fs_cb));
ASSERT(0 == uv_fs_futime(loop, reqs + n++, 0, 0, 0, fs_cb));
ASSERT(0 == uv_fs_link(loop, reqs + n++, "/", "/", fs_cb));
ASSERT(0 == uv_fs_lstat(loop, reqs + n++, "/", fs_cb));
ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb));
ASSERT(0 == uv_fs_open(loop, reqs + n++, "/", 0, 0, fs_cb));
ASSERT(0 == uv_fs_read(loop, reqs + n++, 0, &iov, 1, 0, fs_cb));
ASSERT(0 == uv_fs_scandir(loop, reqs + n++, "/", 0, fs_cb));
ASSERT(0 == uv_fs_readlink(loop, reqs + n++, "/", fs_cb));
ASSERT(0 == uv_fs_realpath(loop, reqs + n++, "/", fs_cb));
ASSERT(0 == uv_fs_rename(loop, reqs + n++, "/", "/", fs_cb));
ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb));
ASSERT(0 == uv_fs_sendfile(loop, reqs + n++, 0, 0, 0, 0, fs_cb));
ASSERT(0 == uv_fs_stat(loop, reqs + n++, "/", fs_cb));
ASSERT(0 == uv_fs_symlink(loop, reqs + n++, "/", "/", 0, fs_cb));
ASSERT(0 == uv_fs_unlink(loop, reqs + n++, "/", fs_cb));
ASSERT(0 == uv_fs_utime(loop, reqs + n++, "/", 0, 0, fs_cb));
ASSERT(0 == uv_fs_write(loop, reqs + n++, 0, &iov, 1, 0, fs_cb));
ASSERT(n == ARRAY_SIZE(reqs));
 
ASSERT(0 == uv_timer_init(loop, &ci.timer_handle));
ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(n == fs_cb_called);



( run in 0.422 second using v1.01-cache-2.11-cpan-00829025b61 )