bare-fs 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.c +94 -53
- package/index.js +55 -38
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-fs.bare +0 -0
- package/prebuilds/android-arm64/bare-fs.bare +0 -0
- package/prebuilds/android-ia32/bare-fs.bare +0 -0
- package/prebuilds/android-x64/bare-fs.bare +0 -0
- package/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/prebuilds/darwin-x64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
- package/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/prebuilds/win32-arm64/bare-fs.bare +0 -0
- package/prebuilds/win32-x64/bare-fs.bare +0 -0
package/binding.c
CHANGED
|
@@ -42,6 +42,7 @@ typedef struct {
|
|
|
42
42
|
js_ref_t *on_close;
|
|
43
43
|
|
|
44
44
|
js_deferred_teardown_t *teardown;
|
|
45
|
+
bool closing;
|
|
45
46
|
bool exiting;
|
|
46
47
|
} bare_fs_watcher_t;
|
|
47
48
|
|
|
@@ -141,9 +142,9 @@ bare_fs__on_response(uv_fs_t *handle) {
|
|
|
141
142
|
req->data = NULL;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
js_call_function(
|
|
145
|
+
js_call_function(env, ctx, on_response, 2, args, NULL);
|
|
145
146
|
|
|
146
|
-
err = js_close_handle_scope(
|
|
147
|
+
err = js_close_handle_scope(env, scope);
|
|
147
148
|
assert(err == 0);
|
|
148
149
|
}
|
|
149
150
|
|
|
@@ -205,7 +206,7 @@ bare_fs__on_stat_response(uv_fs_t *handle) {
|
|
|
205
206
|
V(birthtim)
|
|
206
207
|
#undef V
|
|
207
208
|
|
|
208
|
-
err = js_close_handle_scope(
|
|
209
|
+
err = js_close_handle_scope(env, scope);
|
|
209
210
|
assert(err == 0);
|
|
210
211
|
}
|
|
211
212
|
|
|
@@ -237,7 +238,7 @@ bare_fs__on_realpath_response(uv_fs_t *handle) {
|
|
|
237
238
|
|
|
238
239
|
strncpy(path, handle->ptr, sizeof(bare_fs_path_t));
|
|
239
240
|
|
|
240
|
-
err = js_close_handle_scope(
|
|
241
|
+
err = js_close_handle_scope(env, scope);
|
|
241
242
|
assert(err == 0);
|
|
242
243
|
}
|
|
243
244
|
|
|
@@ -269,7 +270,7 @@ bare_fs__on_readlink_response(uv_fs_t *handle) {
|
|
|
269
270
|
|
|
270
271
|
strncpy(path, handle->ptr, sizeof(bare_fs_path_t));
|
|
271
272
|
|
|
272
|
-
err = js_close_handle_scope(
|
|
273
|
+
err = js_close_handle_scope(env, scope);
|
|
273
274
|
assert(err == 0);
|
|
274
275
|
}
|
|
275
276
|
|
|
@@ -301,7 +302,7 @@ bare_fs__on_opendir_response(uv_fs_t *handle) {
|
|
|
301
302
|
|
|
302
303
|
dir->dir = handle->ptr;
|
|
303
304
|
|
|
304
|
-
err = js_close_handle_scope(
|
|
305
|
+
err = js_close_handle_scope(env, scope);
|
|
305
306
|
assert(err == 0);
|
|
306
307
|
}
|
|
307
308
|
|
|
@@ -359,7 +360,7 @@ bare_fs__on_readdir_response(uv_fs_t *handle) {
|
|
|
359
360
|
assert(err == 0);
|
|
360
361
|
}
|
|
361
362
|
|
|
362
|
-
err = js_close_handle_scope(
|
|
363
|
+
err = js_close_handle_scope(env, scope);
|
|
363
364
|
assert(err == 0);
|
|
364
365
|
}
|
|
365
366
|
|
|
@@ -385,6 +386,7 @@ bare_fs_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
385
386
|
assert(err == 0);
|
|
386
387
|
|
|
387
388
|
req->env = env;
|
|
389
|
+
req->data = NULL;
|
|
388
390
|
req->active = false;
|
|
389
391
|
req->exiting = false;
|
|
390
392
|
|
|
@@ -473,7 +475,8 @@ bare_fs_open_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
473
475
|
js_value_t *res = NULL;
|
|
474
476
|
|
|
475
477
|
if (req.result < 0) {
|
|
476
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
478
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
479
|
+
assert(err == 0);
|
|
477
480
|
} else {
|
|
478
481
|
err = js_create_int32(env, req.result, &res);
|
|
479
482
|
assert(err == 0);
|
|
@@ -539,7 +542,8 @@ bare_fs_close_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
539
542
|
uv_fs_close(loop, &req, fd, NULL);
|
|
540
543
|
|
|
541
544
|
if (req.result < 0) {
|
|
542
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
545
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
546
|
+
assert(err == 0);
|
|
543
547
|
}
|
|
544
548
|
|
|
545
549
|
uv_fs_req_cleanup(&req);
|
|
@@ -610,7 +614,8 @@ bare_fs_access_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
610
614
|
uv_fs_access(loop, &req, (char *) path, mode, NULL);
|
|
611
615
|
|
|
612
616
|
if (req.result < 0) {
|
|
613
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
617
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
618
|
+
assert(err == 0);
|
|
614
619
|
}
|
|
615
620
|
|
|
616
621
|
uv_fs_req_cleanup(&req);
|
|
@@ -1023,7 +1028,8 @@ bare_fs_ftruncate_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1023
1028
|
uv_fs_ftruncate(loop, &req, fd, len, NULL);
|
|
1024
1029
|
|
|
1025
1030
|
if (req.result < 0) {
|
|
1026
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1031
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1032
|
+
assert(err == 0);
|
|
1027
1033
|
}
|
|
1028
1034
|
|
|
1029
1035
|
uv_fs_req_cleanup(&req);
|
|
@@ -1094,7 +1100,8 @@ bare_fs_chmod_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1094
1100
|
uv_fs_chmod(loop, &req, (char *) path, mode, NULL);
|
|
1095
1101
|
|
|
1096
1102
|
if (req.result < 0) {
|
|
1097
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1103
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1104
|
+
assert(err == 0);
|
|
1098
1105
|
}
|
|
1099
1106
|
|
|
1100
1107
|
uv_fs_req_cleanup(&req);
|
|
@@ -1165,7 +1172,8 @@ bare_fs_fchmod_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1165
1172
|
uv_fs_fchmod(loop, &req, fd, mode, NULL);
|
|
1166
1173
|
|
|
1167
1174
|
if (req.result < 0) {
|
|
1168
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1175
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1176
|
+
assert(err == 0);
|
|
1169
1177
|
}
|
|
1170
1178
|
|
|
1171
1179
|
uv_fs_req_cleanup(&req);
|
|
@@ -1236,7 +1244,8 @@ bare_fs_rename_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1236
1244
|
uv_fs_rename(loop, &req, (char *) src, (char *) dest, NULL);
|
|
1237
1245
|
|
|
1238
1246
|
if (req.result < 0) {
|
|
1239
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1247
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1248
|
+
assert(err == 0);
|
|
1240
1249
|
}
|
|
1241
1250
|
|
|
1242
1251
|
uv_fs_req_cleanup(&req);
|
|
@@ -1315,7 +1324,8 @@ bare_fs_copyfile_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1315
1324
|
uv_fs_copyfile(loop, &req, (char *) src, (char *) dest, mode, NULL);
|
|
1316
1325
|
|
|
1317
1326
|
if (req.result < 0) {
|
|
1318
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1327
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1328
|
+
assert(err == 0);
|
|
1319
1329
|
}
|
|
1320
1330
|
|
|
1321
1331
|
uv_fs_req_cleanup(&req);
|
|
@@ -1386,7 +1396,8 @@ bare_fs_mkdir_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1386
1396
|
uv_fs_mkdir(loop, &req, (char *) path, mode, NULL);
|
|
1387
1397
|
|
|
1388
1398
|
if (req.result < 0) {
|
|
1389
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1399
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1400
|
+
assert(err == 0);
|
|
1390
1401
|
}
|
|
1391
1402
|
|
|
1392
1403
|
uv_fs_req_cleanup(&req);
|
|
@@ -1449,7 +1460,8 @@ bare_fs_rmdir_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1449
1460
|
uv_fs_rmdir(loop, &req, (char *) path, NULL);
|
|
1450
1461
|
|
|
1451
1462
|
if (req.result < 0) {
|
|
1452
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1463
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1464
|
+
assert(err == 0);
|
|
1453
1465
|
}
|
|
1454
1466
|
|
|
1455
1467
|
uv_fs_req_cleanup(&req);
|
|
@@ -1517,7 +1529,8 @@ bare_fs_stat_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1517
1529
|
js_value_t *res = NULL;
|
|
1518
1530
|
|
|
1519
1531
|
if (req.result < 0) {
|
|
1520
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1532
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1533
|
+
assert(err == 0);
|
|
1521
1534
|
} else {
|
|
1522
1535
|
err = js_create_array_with_length(env, 14, &res);
|
|
1523
1536
|
assert(err == 0);
|
|
@@ -1628,7 +1641,8 @@ bare_fs_lstat_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1628
1641
|
js_value_t *res = NULL;
|
|
1629
1642
|
|
|
1630
1643
|
if (req.result < 0) {
|
|
1631
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1644
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1645
|
+
assert(err == 0);
|
|
1632
1646
|
} else {
|
|
1633
1647
|
err = js_create_array_with_length(env, 14, &res);
|
|
1634
1648
|
assert(err == 0);
|
|
@@ -1739,7 +1753,8 @@ bare_fs_fstat_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1739
1753
|
js_value_t *res = NULL;
|
|
1740
1754
|
|
|
1741
1755
|
if (req.result < 0) {
|
|
1742
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1756
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1757
|
+
assert(err == 0);
|
|
1743
1758
|
} else {
|
|
1744
1759
|
err = js_create_array_with_length(env, 14, &res);
|
|
1745
1760
|
assert(err == 0);
|
|
@@ -1845,7 +1860,8 @@ bare_fs_unlink_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1845
1860
|
uv_fs_unlink(loop, &req, (char *) path, NULL);
|
|
1846
1861
|
|
|
1847
1862
|
if (req.result < 0) {
|
|
1848
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1863
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1864
|
+
assert(err == 0);
|
|
1849
1865
|
}
|
|
1850
1866
|
|
|
1851
1867
|
uv_fs_req_cleanup(&req);
|
|
@@ -1913,7 +1929,8 @@ bare_fs_realpath_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1913
1929
|
js_value_t *res = NULL;
|
|
1914
1930
|
|
|
1915
1931
|
if (req.result < 0) {
|
|
1916
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1932
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
1933
|
+
assert(err == 0);
|
|
1917
1934
|
} else {
|
|
1918
1935
|
char *path;
|
|
1919
1936
|
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &path, NULL, NULL, NULL);
|
|
@@ -1985,7 +2002,8 @@ bare_fs_readlink_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
1985
2002
|
uv_fs_readlink(loop, &req, (char *) path, NULL);
|
|
1986
2003
|
|
|
1987
2004
|
if (req.result < 0) {
|
|
1988
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2005
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2006
|
+
assert(err == 0);
|
|
1989
2007
|
} else {
|
|
1990
2008
|
char *path;
|
|
1991
2009
|
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &path, NULL, NULL, NULL);
|
|
@@ -2070,7 +2088,8 @@ bare_fs_symlink_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
2070
2088
|
uv_fs_symlink(loop, &req, (char *) target, (char *) path, flags, NULL);
|
|
2071
2089
|
|
|
2072
2090
|
if (req.result < 0) {
|
|
2073
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2091
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2092
|
+
assert(err == 0);
|
|
2074
2093
|
}
|
|
2075
2094
|
|
|
2076
2095
|
uv_fs_req_cleanup(&req);
|
|
@@ -2138,7 +2157,8 @@ bare_fs_opendir_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
2138
2157
|
uv_fs_opendir(loop, &req, (char *) path, NULL);
|
|
2139
2158
|
|
|
2140
2159
|
if (req.result < 0) {
|
|
2141
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2160
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2161
|
+
assert(err == 0);
|
|
2142
2162
|
} else {
|
|
2143
2163
|
bare_fs_dir_t *dir;
|
|
2144
2164
|
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &dir, NULL, NULL, NULL);
|
|
@@ -2226,7 +2246,8 @@ bare_fs_readdir_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
2226
2246
|
uv_fs_readdir(loop, &req, dir->dir, NULL);
|
|
2227
2247
|
|
|
2228
2248
|
if (req.result < 0) {
|
|
2229
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2249
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2250
|
+
assert(err == 0);
|
|
2230
2251
|
} else {
|
|
2231
2252
|
uv_dir_t *dir = req.ptr;
|
|
2232
2253
|
|
|
@@ -2321,7 +2342,8 @@ bare_fs_closedir_sync(js_env_t *env, js_callback_info_t *info) {
|
|
|
2321
2342
|
uv_fs_closedir(loop, &req, dir->dir, NULL);
|
|
2322
2343
|
|
|
2323
2344
|
if (req.result < 0) {
|
|
2324
|
-
js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2345
|
+
err = js_throw_error(env, uv_err_name(req.result), uv_strerror(req.result));
|
|
2346
|
+
assert(err == 0);
|
|
2325
2347
|
}
|
|
2326
2348
|
|
|
2327
2349
|
uv_fs_req_cleanup(&req);
|
|
@@ -2335,6 +2357,8 @@ bare_fs__on_watcher_event(uv_fs_event_t *handle, const char *filename, int event
|
|
|
2335
2357
|
|
|
2336
2358
|
bare_fs_watcher_t *watcher = (bare_fs_watcher_t *) handle;
|
|
2337
2359
|
|
|
2360
|
+
if (watcher->exiting) return;
|
|
2361
|
+
|
|
2338
2362
|
js_env_t *env = watcher->env;
|
|
2339
2363
|
|
|
2340
2364
|
js_handle_scope_t *scope;
|
|
@@ -2398,36 +2422,46 @@ bare_fs__on_watcher_close(uv_handle_t *handle) {
|
|
|
2398
2422
|
|
|
2399
2423
|
js_env_t *env = watcher->env;
|
|
2400
2424
|
|
|
2401
|
-
|
|
2425
|
+
js_deferred_teardown_t *teardown = watcher->teardown;
|
|
2402
2426
|
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2427
|
+
if (watcher->exiting) {
|
|
2428
|
+
err = js_delete_reference(env, watcher->on_event);
|
|
2429
|
+
assert(err == 0);
|
|
2406
2430
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
assert(err == 0);
|
|
2431
|
+
err = js_delete_reference(env, watcher->on_close);
|
|
2432
|
+
assert(err == 0);
|
|
2410
2433
|
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2434
|
+
err = js_delete_reference(env, watcher->ctx);
|
|
2435
|
+
assert(err == 0);
|
|
2436
|
+
} else {
|
|
2437
|
+
js_handle_scope_t *scope;
|
|
2438
|
+
err = js_open_handle_scope(env, &scope);
|
|
2439
|
+
assert(err == 0);
|
|
2414
2440
|
|
|
2415
|
-
|
|
2441
|
+
js_value_t *ctx;
|
|
2442
|
+
err = js_get_reference_value(env, watcher->ctx, &ctx);
|
|
2443
|
+
assert(err == 0);
|
|
2416
2444
|
|
|
2417
|
-
|
|
2418
|
-
|
|
2445
|
+
js_value_t *on_close;
|
|
2446
|
+
err = js_get_reference_value(env, watcher->on_close, &on_close);
|
|
2447
|
+
assert(err == 0);
|
|
2419
2448
|
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
assert(err == 0);
|
|
2449
|
+
err = js_delete_reference(env, watcher->on_event);
|
|
2450
|
+
assert(err == 0);
|
|
2423
2451
|
|
|
2424
|
-
|
|
2425
|
-
|
|
2452
|
+
err = js_delete_reference(env, watcher->on_close);
|
|
2453
|
+
assert(err == 0);
|
|
2426
2454
|
|
|
2427
|
-
|
|
2428
|
-
|
|
2455
|
+
err = js_delete_reference(env, watcher->ctx);
|
|
2456
|
+
assert(err == 0);
|
|
2429
2457
|
|
|
2430
|
-
|
|
2458
|
+
js_call_function(env, ctx, on_close, 0, NULL, NULL);
|
|
2459
|
+
|
|
2460
|
+
err = js_close_handle_scope(env, scope);
|
|
2461
|
+
assert(err == 0);
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
err = js_finish_deferred_teardown_callback(teardown);
|
|
2431
2465
|
assert(err == 0);
|
|
2432
2466
|
}
|
|
2433
2467
|
|
|
@@ -2437,6 +2471,8 @@ bare_fs__on_watcher_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
|
2437
2471
|
|
|
2438
2472
|
watcher->exiting = true;
|
|
2439
2473
|
|
|
2474
|
+
if (watcher->closing) return;
|
|
2475
|
+
|
|
2440
2476
|
uv_close((uv_handle_t *) &watcher->handle, bare_fs__on_watcher_close);
|
|
2441
2477
|
}
|
|
2442
2478
|
|
|
@@ -2473,7 +2509,8 @@ bare_fs_watcher_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
2473
2509
|
err = uv_fs_event_init(loop, &watcher->handle);
|
|
2474
2510
|
|
|
2475
2511
|
if (err < 0) {
|
|
2476
|
-
js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
2512
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
2513
|
+
assert(err == 0);
|
|
2477
2514
|
|
|
2478
2515
|
return NULL;
|
|
2479
2516
|
}
|
|
@@ -2481,17 +2518,16 @@ bare_fs_watcher_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
2481
2518
|
err = uv_fs_event_start(&watcher->handle, bare_fs__on_watcher_event, (char *) path, recursive ? UV_FS_EVENT_RECURSIVE : 0);
|
|
2482
2519
|
|
|
2483
2520
|
if (err < 0) {
|
|
2484
|
-
js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
2521
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
2522
|
+
assert(err == 0);
|
|
2485
2523
|
|
|
2486
2524
|
return NULL;
|
|
2487
2525
|
}
|
|
2488
2526
|
|
|
2489
2527
|
watcher->env = env;
|
|
2528
|
+
watcher->closing = false;
|
|
2490
2529
|
watcher->exiting = false;
|
|
2491
2530
|
|
|
2492
|
-
err = js_add_deferred_teardown_callback(env, bare_fs__on_watcher_teardown, (void *) watcher, &watcher->teardown);
|
|
2493
|
-
assert(err == 0);
|
|
2494
|
-
|
|
2495
2531
|
err = js_create_reference(env, argv[2], 1, &watcher->ctx);
|
|
2496
2532
|
assert(err == 0);
|
|
2497
2533
|
|
|
@@ -2501,6 +2537,9 @@ bare_fs_watcher_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
2501
2537
|
err = js_create_reference(env, argv[4], 1, &watcher->on_close);
|
|
2502
2538
|
assert(err == 0);
|
|
2503
2539
|
|
|
2540
|
+
err = js_add_deferred_teardown_callback(env, bare_fs__on_watcher_teardown, (void *) watcher, &watcher->teardown);
|
|
2541
|
+
assert(err == 0);
|
|
2542
|
+
|
|
2504
2543
|
return result;
|
|
2505
2544
|
}
|
|
2506
2545
|
|
|
@@ -2523,6 +2562,8 @@ bare_fs_watcher_close(js_env_t *env, js_callback_info_t *info) {
|
|
|
2523
2562
|
err = uv_fs_event_stop(&watcher->handle);
|
|
2524
2563
|
assert(err == 0);
|
|
2525
2564
|
|
|
2565
|
+
watcher->closing = true;
|
|
2566
|
+
|
|
2526
2567
|
uv_close((uv_handle_t *) &watcher->handle, bare_fs__on_watcher_close);
|
|
2527
2568
|
|
|
2528
2569
|
return NULL;
|
package/index.js
CHANGED
|
@@ -153,7 +153,7 @@ function open(filepath, flags, mode, cb) {
|
|
|
153
153
|
|
|
154
154
|
const req = getReq()
|
|
155
155
|
req.callback = cb
|
|
156
|
-
binding.open(req.handle, filepath, flags, mode)
|
|
156
|
+
binding.open(req.handle, toNamespacedPath(filepath), flags, mode)
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
function openSync(filepath, flags = 'r', mode = 0o666) {
|
|
@@ -171,7 +171,7 @@ function openSync(filepath, flags = 'r', mode = 0o666) {
|
|
|
171
171
|
if (typeof flags === 'string') flags = flagsToNumber(flags)
|
|
172
172
|
if (typeof mode === 'string') mode = modeToNumber(mode)
|
|
173
173
|
|
|
174
|
-
return binding.openSync(filepath, flags, mode)
|
|
174
|
+
return binding.openSync(toNamespacedPath(filepath), flags, mode)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
function close(fd, cb = noop) {
|
|
@@ -263,7 +263,7 @@ function access(filepath, mode, cb) {
|
|
|
263
263
|
|
|
264
264
|
const req = getReq()
|
|
265
265
|
req.callback = cb
|
|
266
|
-
binding.access(req.handle, filepath, mode)
|
|
266
|
+
binding.access(req.handle, toNamespacedPath(filepath), mode)
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
function accessSync(filepath, mode = constants.F_OK) {
|
|
@@ -278,7 +278,7 @@ function accessSync(filepath, mode = constants.F_OK) {
|
|
|
278
278
|
)
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
binding.accessSync(filepath, mode)
|
|
281
|
+
binding.accessSync(toNamespacedPath(filepath), mode)
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
function exists(filepath, cb) {
|
|
@@ -304,7 +304,7 @@ function exists(filepath, cb) {
|
|
|
304
304
|
)
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
return access(filepath, (err) => cb(!!err))
|
|
307
|
+
return access(toNamespacedPath(filepath), (err) => cb(!!err))
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
function existsSync(filepath) {
|
|
@@ -320,7 +320,7 @@ function existsSync(filepath) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
try {
|
|
323
|
-
accessSync(filepath)
|
|
323
|
+
accessSync(toNamespacedPath(filepath))
|
|
324
324
|
return true
|
|
325
325
|
} catch {
|
|
326
326
|
return false
|
|
@@ -680,7 +680,7 @@ function stat(filepath, cb) {
|
|
|
680
680
|
else cb(null, new Stats(...data))
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
-
binding.stat(req.handle, filepath, data)
|
|
683
|
+
binding.stat(req.handle, toNamespacedPath(filepath), data)
|
|
684
684
|
}
|
|
685
685
|
|
|
686
686
|
function statSync(filepath) {
|
|
@@ -695,7 +695,7 @@ function statSync(filepath) {
|
|
|
695
695
|
)
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
-
return new Stats(...binding.statSync(filepath))
|
|
698
|
+
return new Stats(...binding.statSync(toNamespacedPath(filepath)))
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
function lstat(filepath, cb) {
|
|
@@ -730,7 +730,7 @@ function lstat(filepath, cb) {
|
|
|
730
730
|
else cb(null, new Stats(...data))
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
binding.lstat(req.handle, filepath, data)
|
|
733
|
+
binding.lstat(req.handle, toNamespacedPath(filepath), data)
|
|
734
734
|
}
|
|
735
735
|
|
|
736
736
|
function lstatSync(filepath) {
|
|
@@ -745,7 +745,7 @@ function lstatSync(filepath) {
|
|
|
745
745
|
)
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
-
return new Stats(...binding.lstatSync(filepath))
|
|
748
|
+
return new Stats(...binding.lstatSync(toNamespacedPath(filepath)))
|
|
749
749
|
}
|
|
750
750
|
|
|
751
751
|
function fstat(fd, cb) {
|
|
@@ -896,7 +896,7 @@ function chmod(filepath, mode, cb) {
|
|
|
896
896
|
|
|
897
897
|
const req = getReq()
|
|
898
898
|
req.callback = cb
|
|
899
|
-
binding.chmod(req.handle, filepath, mode)
|
|
899
|
+
binding.chmod(req.handle, toNamespacedPath(filepath), mode)
|
|
900
900
|
}
|
|
901
901
|
|
|
902
902
|
function chmodSync(filepath, mode) {
|
|
@@ -913,7 +913,7 @@ function chmodSync(filepath, mode) {
|
|
|
913
913
|
|
|
914
914
|
if (typeof mode === 'string') mode = modeToNumber(mode)
|
|
915
915
|
|
|
916
|
-
binding.chmodSync(filepath, mode)
|
|
916
|
+
binding.chmodSync(toNamespacedPath(filepath), mode)
|
|
917
917
|
}
|
|
918
918
|
|
|
919
919
|
function fchmod(fd, mode, cb) {
|
|
@@ -969,6 +969,8 @@ function fchmodSync(fd, mode) {
|
|
|
969
969
|
}
|
|
970
970
|
|
|
971
971
|
function mkdirRecursive(filepath, mode, cb) {
|
|
972
|
+
filepath = toNamespacedPath(filepath)
|
|
973
|
+
|
|
972
974
|
mkdir(filepath, { mode }, function (err) {
|
|
973
975
|
if (err === null) return cb(null, 0, null)
|
|
974
976
|
|
|
@@ -1032,8 +1034,9 @@ function mkdir(filepath, opts, cb) {
|
|
|
1032
1034
|
|
|
1033
1035
|
const mode = typeof opts.mode === 'number' ? opts.mode : 0o777
|
|
1034
1036
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
+
filepath = toNamespacedPath(filepath)
|
|
1038
|
+
|
|
1039
|
+
if (opts.recursive) return mkdirRecursive(filepath, mode, cb)
|
|
1037
1040
|
|
|
1038
1041
|
const req = getReq()
|
|
1039
1042
|
req.callback = cb
|
|
@@ -1041,6 +1044,8 @@ function mkdir(filepath, opts, cb) {
|
|
|
1041
1044
|
}
|
|
1042
1045
|
|
|
1043
1046
|
function mkdirRecursiveSync(filepath, mode) {
|
|
1047
|
+
filepath = toNamespacedPath(filepath)
|
|
1048
|
+
|
|
1044
1049
|
try {
|
|
1045
1050
|
mkdirSync(filepath, { mode })
|
|
1046
1051
|
} catch (err) {
|
|
@@ -1083,8 +1088,9 @@ function mkdirSync(filepath, opts) {
|
|
|
1083
1088
|
|
|
1084
1089
|
const mode = typeof opts.mode === 'number' ? opts.mode : 0o777
|
|
1085
1090
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1091
|
+
filepath = toNamespacedPath(filepath)
|
|
1092
|
+
|
|
1093
|
+
if (opts.recursive) return mkdirRecursiveSync(filepath, mode)
|
|
1088
1094
|
|
|
1089
1095
|
binding.mkdirSync(filepath, mode)
|
|
1090
1096
|
}
|
|
@@ -1114,7 +1120,7 @@ function rmdir(filepath, cb) {
|
|
|
1114
1120
|
|
|
1115
1121
|
const req = getReq()
|
|
1116
1122
|
req.callback = cb
|
|
1117
|
-
binding.rmdir(req.handle, filepath)
|
|
1123
|
+
binding.rmdir(req.handle, toNamespacedPath(filepath))
|
|
1118
1124
|
}
|
|
1119
1125
|
|
|
1120
1126
|
function rmdirSync(filepath) {
|
|
@@ -1129,10 +1135,12 @@ function rmdirSync(filepath) {
|
|
|
1129
1135
|
)
|
|
1130
1136
|
}
|
|
1131
1137
|
|
|
1132
|
-
binding.rmdirSync(filepath)
|
|
1138
|
+
binding.rmdirSync(toNamespacedPath(filepath))
|
|
1133
1139
|
}
|
|
1134
1140
|
|
|
1135
1141
|
function rmRecursive(filepath, opts, cb) {
|
|
1142
|
+
filepath = toNamespacedPath(filepath)
|
|
1143
|
+
|
|
1136
1144
|
rmdir(filepath, function (err) {
|
|
1137
1145
|
if (err === null) return cb(null)
|
|
1138
1146
|
|
|
@@ -1190,6 +1198,8 @@ function rm(filepath, opts, cb) {
|
|
|
1190
1198
|
|
|
1191
1199
|
if (!opts) opts = {}
|
|
1192
1200
|
|
|
1201
|
+
filepath = toNamespacedPath(filepath)
|
|
1202
|
+
|
|
1193
1203
|
lstat(filepath, function (err, st) {
|
|
1194
1204
|
if (err) {
|
|
1195
1205
|
return cb(err.code === 'ENOENT' && opts.force ? null : err)
|
|
@@ -1208,6 +1218,8 @@ function rm(filepath, opts, cb) {
|
|
|
1208
1218
|
}
|
|
1209
1219
|
|
|
1210
1220
|
function rmRecursiveSync(filepath, opts) {
|
|
1221
|
+
filepath = toNamespacedPath(filepath)
|
|
1222
|
+
|
|
1211
1223
|
try {
|
|
1212
1224
|
rmdirSync(filepath)
|
|
1213
1225
|
} catch (err) {
|
|
@@ -1237,6 +1249,8 @@ function rmSync(filepath, opts) {
|
|
|
1237
1249
|
|
|
1238
1250
|
if (!opts) opts = {}
|
|
1239
1251
|
|
|
1252
|
+
filepath = toNamespacedPath(filepath)
|
|
1253
|
+
|
|
1240
1254
|
try {
|
|
1241
1255
|
const st = lstatSync(filepath)
|
|
1242
1256
|
|
|
@@ -1279,7 +1293,7 @@ function unlink(filepath, cb) {
|
|
|
1279
1293
|
|
|
1280
1294
|
const req = getReq()
|
|
1281
1295
|
req.callback = cb
|
|
1282
|
-
binding.unlink(req.handle, filepath)
|
|
1296
|
+
binding.unlink(req.handle, toNamespacedPath(filepath))
|
|
1283
1297
|
}
|
|
1284
1298
|
|
|
1285
1299
|
function unlinkSync(filepath) {
|
|
@@ -1294,7 +1308,7 @@ function unlinkSync(filepath) {
|
|
|
1294
1308
|
)
|
|
1295
1309
|
}
|
|
1296
1310
|
|
|
1297
|
-
binding.unlinkSync(filepath)
|
|
1311
|
+
binding.unlinkSync(toNamespacedPath(filepath))
|
|
1298
1312
|
}
|
|
1299
1313
|
|
|
1300
1314
|
function rename(src, dst, cb) {
|
|
@@ -1431,7 +1445,7 @@ function realpath(filepath, opts, cb) {
|
|
|
1431
1445
|
cb(null, path)
|
|
1432
1446
|
}
|
|
1433
1447
|
|
|
1434
|
-
binding.realpath(req.handle, filepath, data)
|
|
1448
|
+
binding.realpath(req.handle, toNamespacedPath(filepath), data)
|
|
1435
1449
|
}
|
|
1436
1450
|
|
|
1437
1451
|
function realpathSync(filepath, opts) {
|
|
@@ -1453,7 +1467,7 @@ function realpathSync(filepath, opts) {
|
|
|
1453
1467
|
|
|
1454
1468
|
const data = Buffer.allocUnsafe(binding.sizeofFSPath)
|
|
1455
1469
|
|
|
1456
|
-
binding.realpathSync(filepath, data)
|
|
1470
|
+
binding.realpathSync(toNamespacedPath(filepath), data)
|
|
1457
1471
|
|
|
1458
1472
|
filepath = data.subarray(0, data.indexOf(0))
|
|
1459
1473
|
if (encoding !== 'buffer') filepath = filepath.toString(encoding)
|
|
@@ -1502,7 +1516,7 @@ function readlink(filepath, opts, cb) {
|
|
|
1502
1516
|
cb(null, path)
|
|
1503
1517
|
}
|
|
1504
1518
|
|
|
1505
|
-
binding.readlink(req.handle, filepath, data)
|
|
1519
|
+
binding.readlink(req.handle, toNamespacedPath(filepath), data)
|
|
1506
1520
|
}
|
|
1507
1521
|
|
|
1508
1522
|
function readlinkSync(filepath, opts) {
|
|
@@ -1524,7 +1538,7 @@ function readlinkSync(filepath, opts) {
|
|
|
1524
1538
|
|
|
1525
1539
|
const data = Buffer.allocUnsafe(binding.sizeofFSPath)
|
|
1526
1540
|
|
|
1527
|
-
binding.readlinkSync(filepath, data)
|
|
1541
|
+
binding.readlinkSync(toNamespacedPath(filepath), data)
|
|
1528
1542
|
|
|
1529
1543
|
filepath = data.subarray(0, data.indexOf(0))
|
|
1530
1544
|
if (encoding !== 'buffer') filepath = filepath.toString(encoding)
|
|
@@ -1580,6 +1594,8 @@ function symlink(target, filepath, type, cb) {
|
|
|
1580
1594
|
)
|
|
1581
1595
|
}
|
|
1582
1596
|
|
|
1597
|
+
filepath = toNamespacedPath(filepath)
|
|
1598
|
+
|
|
1583
1599
|
if (typeof type === 'string') {
|
|
1584
1600
|
switch (type) {
|
|
1585
1601
|
case 'file':
|
|
@@ -1620,12 +1636,7 @@ function symlink(target, filepath, type, cb) {
|
|
|
1620
1636
|
|
|
1621
1637
|
const req = getReq()
|
|
1622
1638
|
req.callback = cb
|
|
1623
|
-
binding.symlink(
|
|
1624
|
-
req.handle,
|
|
1625
|
-
normalizeSymlinkTarget(target),
|
|
1626
|
-
path.toNamespacedPath(filepath),
|
|
1627
|
-
type
|
|
1628
|
-
)
|
|
1639
|
+
binding.symlink(req.handle, normalizeSymlinkTarget(target), filepath, type)
|
|
1629
1640
|
}
|
|
1630
1641
|
|
|
1631
1642
|
function symlinkSync(target, filepath, type) {
|
|
@@ -1651,6 +1662,8 @@ function symlinkSync(target, filepath, type) {
|
|
|
1651
1662
|
)
|
|
1652
1663
|
}
|
|
1653
1664
|
|
|
1665
|
+
filepath = toNamespacedPath(filepath)
|
|
1666
|
+
|
|
1654
1667
|
if (typeof type === 'string') {
|
|
1655
1668
|
switch (type) {
|
|
1656
1669
|
case 'file':
|
|
@@ -1682,11 +1695,7 @@ function symlinkSync(target, filepath, type) {
|
|
|
1682
1695
|
}
|
|
1683
1696
|
}
|
|
1684
1697
|
|
|
1685
|
-
binding.symlinkSync(
|
|
1686
|
-
normalizeSymlinkTarget(target),
|
|
1687
|
-
path.toNamespacedPath(filepath),
|
|
1688
|
-
type
|
|
1689
|
-
)
|
|
1698
|
+
binding.symlinkSync(normalizeSymlinkTarget(target), filepath, type)
|
|
1690
1699
|
}
|
|
1691
1700
|
|
|
1692
1701
|
function opendir(filepath, opts, cb) {
|
|
@@ -1718,6 +1727,8 @@ function opendir(filepath, opts, cb) {
|
|
|
1718
1727
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1719
1728
|
else if (!opts) opts = {}
|
|
1720
1729
|
|
|
1730
|
+
filepath = toNamespacedPath(filepath)
|
|
1731
|
+
|
|
1721
1732
|
const data = Buffer.allocUnsafe(binding.sizeofFSDir)
|
|
1722
1733
|
|
|
1723
1734
|
const req = getReq()
|
|
@@ -1745,6 +1756,8 @@ function opendirSync(filepath, opts) {
|
|
|
1745
1756
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1746
1757
|
else if (!opts) opts = {}
|
|
1747
1758
|
|
|
1759
|
+
filepath = toNamespacedPath(filepath)
|
|
1760
|
+
|
|
1748
1761
|
const data = Buffer.allocUnsafe(binding.sizeofFSDir)
|
|
1749
1762
|
binding.opendirSync(filepath, data)
|
|
1750
1763
|
return new Dir(filepath, data, opts)
|
|
@@ -1781,7 +1794,7 @@ function readdir(filepath, opts, cb) {
|
|
|
1781
1794
|
|
|
1782
1795
|
const { withFileTypes = false } = opts
|
|
1783
1796
|
|
|
1784
|
-
opendir(filepath, opts, async (err, dir) => {
|
|
1797
|
+
opendir(toNamespacedPath(filepath), opts, async (err, dir) => {
|
|
1785
1798
|
if (err) return cb(err, null)
|
|
1786
1799
|
const result = []
|
|
1787
1800
|
for await (const entry of dir) {
|
|
@@ -1808,7 +1821,7 @@ function readdirSync(filepath, opts) {
|
|
|
1808
1821
|
|
|
1809
1822
|
const { withFileTypes = false } = opts
|
|
1810
1823
|
|
|
1811
|
-
const dir = opendirSync(filepath, opts)
|
|
1824
|
+
const dir = opendirSync(toNamespacedPath(filepath), opts)
|
|
1812
1825
|
const result = []
|
|
1813
1826
|
|
|
1814
1827
|
while (true) {
|
|
@@ -2140,7 +2153,7 @@ function watch(filepath, opts, cb) {
|
|
|
2140
2153
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
2141
2154
|
else if (!opts) opts = {}
|
|
2142
2155
|
|
|
2143
|
-
const watcher = new Watcher(filepath, opts)
|
|
2156
|
+
const watcher = new Watcher(toNamespacedPath(filepath), opts)
|
|
2144
2157
|
if (cb) watcher.on('change', cb)
|
|
2145
2158
|
return watcher
|
|
2146
2159
|
}
|
|
@@ -2714,3 +2727,7 @@ function promisify(fn) {
|
|
|
2714
2727
|
function map(data) {
|
|
2715
2728
|
return typeof data === 'string' ? Buffer.from(data) : data
|
|
2716
2729
|
}
|
|
2730
|
+
|
|
2731
|
+
function toNamespacedPath(filepath) {
|
|
2732
|
+
return path.toNamespacedPath(filepath)
|
|
2733
|
+
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|