bare-fs 3.0.1 → 3.0.2
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 +43 -1
- package/index.js +6 -2
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include <assert.h>
|
|
2
2
|
#include <bare.h>
|
|
3
3
|
#include <js.h>
|
|
4
|
+
#include <stdbool.h>
|
|
4
5
|
#include <stdint.h>
|
|
5
6
|
#include <stdlib.h>
|
|
6
7
|
#include <string.h>
|
|
@@ -50,12 +51,19 @@ typedef struct {
|
|
|
50
51
|
|
|
51
52
|
typedef uv_dirent_t bare_fs_dirent_t;
|
|
52
53
|
|
|
54
|
+
static inline bool
|
|
55
|
+
bare_fs__is_cancelled (bare_fs_req_t *req) {
|
|
56
|
+
return req->ctx == NULL || req->req.result == UV_ECANCELED;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
static inline void
|
|
54
60
|
bare_fs__on_response (uv_fs_t *uv_req) {
|
|
55
61
|
int err;
|
|
56
62
|
|
|
57
63
|
bare_fs_req_t *req = (bare_fs_req_t *) uv_req;
|
|
58
64
|
|
|
65
|
+
if (bare_fs__is_cancelled(req)) return;
|
|
66
|
+
|
|
59
67
|
js_env_t *env = req->env;
|
|
60
68
|
|
|
61
69
|
js_handle_scope_t *scope;
|
|
@@ -115,6 +123,8 @@ bare_fs__on_stat_response (uv_fs_t *uv_req) {
|
|
|
115
123
|
|
|
116
124
|
bare_fs_req_t *req = (bare_fs_req_t *) uv_req;
|
|
117
125
|
|
|
126
|
+
if (bare_fs__is_cancelled(req)) return;
|
|
127
|
+
|
|
118
128
|
js_env_t *env = req->env;
|
|
119
129
|
|
|
120
130
|
if (uv_req->result == 0) {
|
|
@@ -179,6 +189,8 @@ bare_fs__on_realpath_response (uv_fs_t *uv_req) {
|
|
|
179
189
|
|
|
180
190
|
bare_fs_req_t *req = (bare_fs_req_t *) uv_req;
|
|
181
191
|
|
|
192
|
+
if (bare_fs__is_cancelled(req)) return;
|
|
193
|
+
|
|
182
194
|
js_env_t *env = req->env;
|
|
183
195
|
|
|
184
196
|
if (uv_req->result == 0) {
|
|
@@ -209,6 +221,8 @@ bare_fs__on_readlink_response (uv_fs_t *uv_req) {
|
|
|
209
221
|
|
|
210
222
|
bare_fs_req_t *req = (bare_fs_req_t *) uv_req;
|
|
211
223
|
|
|
224
|
+
if (bare_fs__is_cancelled(req)) return;
|
|
225
|
+
|
|
212
226
|
js_env_t *env = req->env;
|
|
213
227
|
|
|
214
228
|
if (uv_req->result == 0) {
|
|
@@ -239,6 +253,8 @@ bare_fs__on_opendir_response (uv_fs_t *uv_req) {
|
|
|
239
253
|
|
|
240
254
|
bare_fs_req_t *req = (bare_fs_req_t *) uv_req;
|
|
241
255
|
|
|
256
|
+
if (bare_fs__is_cancelled(req)) return;
|
|
257
|
+
|
|
242
258
|
js_env_t *env = req->env;
|
|
243
259
|
|
|
244
260
|
if (uv_req->result == 0) {
|
|
@@ -495,6 +511,31 @@ bare_fs_req_init (js_env_t *env, js_callback_info_t *info) {
|
|
|
495
511
|
return NULL;
|
|
496
512
|
}
|
|
497
513
|
|
|
514
|
+
static js_value_t *
|
|
515
|
+
bare_fs_req_cancel (js_env_t *env, js_callback_info_t *info) {
|
|
516
|
+
int err;
|
|
517
|
+
|
|
518
|
+
size_t argc = 1;
|
|
519
|
+
js_value_t *argv[1];
|
|
520
|
+
|
|
521
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
522
|
+
assert(err == 0);
|
|
523
|
+
|
|
524
|
+
assert(argc == 1);
|
|
525
|
+
|
|
526
|
+
bare_fs_req_t *req;
|
|
527
|
+
err = js_get_typedarray_info(env, argv[0], NULL, (void **) &req, NULL, NULL, NULL);
|
|
528
|
+
assert(err == 0);
|
|
529
|
+
|
|
530
|
+
uv_cancel((uv_req_t *) req);
|
|
531
|
+
|
|
532
|
+
req->env = NULL;
|
|
533
|
+
req->ctx = NULL;
|
|
534
|
+
req->on_response = NULL;
|
|
535
|
+
|
|
536
|
+
return NULL;
|
|
537
|
+
}
|
|
538
|
+
|
|
498
539
|
static js_value_t *
|
|
499
540
|
bare_fs_open (js_env_t *env, js_callback_info_t *info) {
|
|
500
541
|
int err;
|
|
@@ -2379,7 +2420,8 @@ bare_fs_exports (js_env_t *env, js_value_t *exports) {
|
|
|
2379
2420
|
|
|
2380
2421
|
V("init", bare_fs_init)
|
|
2381
2422
|
V("destroy", bare_fs_destroy)
|
|
2382
|
-
V("
|
|
2423
|
+
V("reqInit", bare_fs_req_init)
|
|
2424
|
+
V("reqCancel", bare_fs_req_cancel)
|
|
2383
2425
|
V("open", bare_fs_open)
|
|
2384
2426
|
V("openSync", bare_fs_open_sync)
|
|
2385
2427
|
V("close", bare_fs_close)
|
package/index.js
CHANGED
|
@@ -60,7 +60,11 @@ const fs = {
|
|
|
60
60
|
|
|
61
61
|
binding.init(fs.handle, fs, onresponse)
|
|
62
62
|
|
|
63
|
-
Bare.on('exit', () =>
|
|
63
|
+
Bare.on('exit', () => {
|
|
64
|
+
for (const req of reqs) binding.reqCancel(req.handle)
|
|
65
|
+
|
|
66
|
+
binding.destroy(fs.handle)
|
|
67
|
+
})
|
|
64
68
|
|
|
65
69
|
// Lightly-modified from the Node FS internal utils.
|
|
66
70
|
function flagsToNumber (flags) {
|
|
@@ -105,7 +109,7 @@ function modeToNumber (mode) {
|
|
|
105
109
|
function alloc () {
|
|
106
110
|
const handle = Buffer.alloc(binding.sizeofFSReq)
|
|
107
111
|
|
|
108
|
-
binding.
|
|
112
|
+
binding.reqInit(fs.handle, handle)
|
|
109
113
|
|
|
110
114
|
const view = new Uint32Array(handle.buffer, handle.byteOffset + binding.offsetofFSReqID, 1)
|
|
111
115
|
|
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
|