bare-fs 4.5.3 → 4.5.5
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 +1 -1
- package/index.js +166 -71
- 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
|
@@ -290,7 +290,7 @@ bare_fs_request_result_stat(js_env_t *env, js_callback_info_t *info) {
|
|
|
290
290
|
uv_timespec_t time = req->handle.statbuf.st_##property; \
|
|
291
291
|
\
|
|
292
292
|
js_value_t *value; \
|
|
293
|
-
err = js_create_int64(env, time.tv_sec *
|
|
293
|
+
err = js_create_int64(env, time.tv_sec * 1000 + time.tv_nsec / 1000000, &value); \
|
|
294
294
|
assert(err == 0); \
|
|
295
295
|
\
|
|
296
296
|
err = js_set_element(env, result, i++, value); \
|
package/index.js
CHANGED
|
@@ -12,8 +12,6 @@ const isWindows = Bare.platform === 'win32'
|
|
|
12
12
|
exports.constants = constants
|
|
13
13
|
|
|
14
14
|
class FileRequest {
|
|
15
|
-
static _free = []
|
|
16
|
-
|
|
17
15
|
static borrow() {
|
|
18
16
|
if (this._free.length > 0) return this._free.pop()
|
|
19
17
|
return new FileRequest()
|
|
@@ -70,16 +68,11 @@ class FileRequest {
|
|
|
70
68
|
return this
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
[Symbol.dispose]() {
|
|
74
|
-
this.return()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
71
|
_reset() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this._reject = reject
|
|
72
|
+
this._promise = new Promise((resolve, reject) => {
|
|
73
|
+
this._resolve = resolve
|
|
74
|
+
this._reject = reject
|
|
75
|
+
})
|
|
83
76
|
this._retain = null
|
|
84
77
|
}
|
|
85
78
|
|
|
@@ -89,6 +82,8 @@ class FileRequest {
|
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
84
|
|
|
85
|
+
FileRequest._free = []
|
|
86
|
+
|
|
92
87
|
function ok(result, cb) {
|
|
93
88
|
if (typeof result === 'function') {
|
|
94
89
|
cb = result
|
|
@@ -129,7 +124,7 @@ async function open(filepath, flags = 'r', mode = 0o666, cb) {
|
|
|
129
124
|
|
|
130
125
|
filepath = toNamespacedPath(filepath)
|
|
131
126
|
|
|
132
|
-
|
|
127
|
+
const req = FileRequest.borrow()
|
|
133
128
|
|
|
134
129
|
let fd
|
|
135
130
|
let err = null
|
|
@@ -143,6 +138,8 @@ async function open(filepath, flags = 'r', mode = 0o666, cb) {
|
|
|
143
138
|
code: e.code,
|
|
144
139
|
path: filepath
|
|
145
140
|
})
|
|
141
|
+
} finally {
|
|
142
|
+
req.return()
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
return done(err, fd, cb)
|
|
@@ -154,7 +151,7 @@ function openSync(filepath, flags = 'r', mode = 0o666) {
|
|
|
154
151
|
|
|
155
152
|
filepath = toNamespacedPath(filepath)
|
|
156
153
|
|
|
157
|
-
|
|
154
|
+
const req = FileRequest.borrow()
|
|
158
155
|
|
|
159
156
|
try {
|
|
160
157
|
return binding.openSync(req.handle, filepath, flags, mode)
|
|
@@ -164,11 +161,13 @@ function openSync(filepath, flags = 'r', mode = 0o666) {
|
|
|
164
161
|
code: e.code,
|
|
165
162
|
path: filepath
|
|
166
163
|
})
|
|
164
|
+
} finally {
|
|
165
|
+
req.return()
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
168
|
|
|
170
169
|
async function close(fd, cb) {
|
|
171
|
-
|
|
170
|
+
const req = FileRequest.borrow()
|
|
172
171
|
|
|
173
172
|
let err = null
|
|
174
173
|
try {
|
|
@@ -177,18 +176,22 @@ async function close(fd, cb) {
|
|
|
177
176
|
await req
|
|
178
177
|
} catch (e) {
|
|
179
178
|
err = new FileError(e.message, { operation: 'close', code: e.code, fd })
|
|
179
|
+
} finally {
|
|
180
|
+
req.return()
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
return done(err, cb)
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
function closeSync(fd) {
|
|
186
|
-
|
|
187
|
+
const req = FileRequest.borrow()
|
|
187
188
|
|
|
188
189
|
try {
|
|
189
190
|
binding.closeSync(req.handle, fd)
|
|
190
191
|
} catch (e) {
|
|
191
192
|
throw new FileError(e.message, { operation: 'close', code: e.code, fd })
|
|
193
|
+
} finally {
|
|
194
|
+
req.return()
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
|
|
@@ -200,7 +203,7 @@ async function access(filepath, mode = constants.F_OK, cb) {
|
|
|
200
203
|
|
|
201
204
|
filepath = toNamespacedPath(filepath)
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
const req = FileRequest.borrow()
|
|
204
207
|
|
|
205
208
|
let err = null
|
|
206
209
|
try {
|
|
@@ -213,6 +216,8 @@ async function access(filepath, mode = constants.F_OK, cb) {
|
|
|
213
216
|
code: e.code,
|
|
214
217
|
path: filepath
|
|
215
218
|
})
|
|
219
|
+
} finally {
|
|
220
|
+
req.return()
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
return done(err, cb)
|
|
@@ -221,7 +226,7 @@ async function access(filepath, mode = constants.F_OK, cb) {
|
|
|
221
226
|
function accessSync(filepath, mode = constants.F_OK) {
|
|
222
227
|
filepath = toNamespacedPath(filepath)
|
|
223
228
|
|
|
224
|
-
|
|
229
|
+
const req = FileRequest.borrow()
|
|
225
230
|
|
|
226
231
|
try {
|
|
227
232
|
binding.accessSync(req.handle, filepath, mode)
|
|
@@ -231,6 +236,8 @@ function accessSync(filepath, mode = constants.F_OK) {
|
|
|
231
236
|
code: e.code,
|
|
232
237
|
path: filepath
|
|
233
238
|
})
|
|
239
|
+
} finally {
|
|
240
|
+
req.return()
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
243
|
|
|
@@ -272,7 +279,7 @@ async function read(fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
272
279
|
|
|
273
280
|
if (typeof pos !== 'number') pos = -1
|
|
274
281
|
|
|
275
|
-
|
|
282
|
+
const req = FileRequest.borrow()
|
|
276
283
|
|
|
277
284
|
let bytes
|
|
278
285
|
let err = null
|
|
@@ -282,18 +289,22 @@ async function read(fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
282
289
|
bytes = await req
|
|
283
290
|
} catch (e) {
|
|
284
291
|
err = new FileError(e.message, { operation: 'read', code: e.code, fd })
|
|
292
|
+
} finally {
|
|
293
|
+
req.return()
|
|
285
294
|
}
|
|
286
295
|
|
|
287
296
|
return done(err, bytes, cb)
|
|
288
297
|
}
|
|
289
298
|
|
|
290
299
|
function readSync(fd, buffer, offset = 0, len = buffer.byteLength - offset, pos = -1) {
|
|
291
|
-
|
|
300
|
+
const req = FileRequest.borrow()
|
|
292
301
|
|
|
293
302
|
try {
|
|
294
303
|
return binding.readSync(req.handle, fd, buffer, offset, len, pos)
|
|
295
304
|
} catch (e) {
|
|
296
305
|
throw new FileError(e.message, { operation: 'read', code: e.code, fd })
|
|
306
|
+
} finally {
|
|
307
|
+
req.return()
|
|
297
308
|
}
|
|
298
309
|
}
|
|
299
310
|
|
|
@@ -305,7 +316,7 @@ async function readv(fd, buffers, pos = -1, cb) {
|
|
|
305
316
|
|
|
306
317
|
if (typeof pos !== 'number') pos = -1
|
|
307
318
|
|
|
308
|
-
|
|
319
|
+
const req = FileRequest.borrow()
|
|
309
320
|
|
|
310
321
|
let bytes
|
|
311
322
|
let err = null
|
|
@@ -315,6 +326,8 @@ async function readv(fd, buffers, pos = -1, cb) {
|
|
|
315
326
|
bytes = await req
|
|
316
327
|
} catch (e) {
|
|
317
328
|
err = new FileError(e.message, { operation: 'readv', code: e.code, fd })
|
|
329
|
+
} finally {
|
|
330
|
+
req.return()
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
return done(err, bytes, cb)
|
|
@@ -323,16 +336,18 @@ async function readv(fd, buffers, pos = -1, cb) {
|
|
|
323
336
|
function readvSync(fd, buffers, pos = -1) {
|
|
324
337
|
if (typeof pos !== 'number') pos = -1
|
|
325
338
|
|
|
326
|
-
|
|
339
|
+
const req = FileRequest.borrow()
|
|
327
340
|
|
|
328
341
|
try {
|
|
329
342
|
return binding.readvSync(req.handle, fd, buffers, pos)
|
|
330
343
|
} catch (e) {
|
|
331
344
|
throw new FileError(e.message, { operation: 'readv', code: e.code, fd })
|
|
345
|
+
} finally {
|
|
346
|
+
req.return()
|
|
332
347
|
}
|
|
333
348
|
}
|
|
334
349
|
|
|
335
|
-
async function write(fd, data, offset
|
|
350
|
+
async function write(fd, data, offset, len, pos = -1, cb) {
|
|
336
351
|
if (typeof data === 'string') {
|
|
337
352
|
let encoding = len
|
|
338
353
|
cb = pos
|
|
@@ -369,10 +384,11 @@ async function write(fd, data, offset = 0, len, pos = -1, cb) {
|
|
|
369
384
|
pos = -1
|
|
370
385
|
}
|
|
371
386
|
|
|
387
|
+
if (typeof offset !== 'number') offset = 0
|
|
372
388
|
if (typeof len !== 'number') len = data.byteLength - offset
|
|
373
389
|
if (typeof pos !== 'number') pos = -1
|
|
374
390
|
|
|
375
|
-
|
|
391
|
+
const req = FileRequest.borrow()
|
|
376
392
|
|
|
377
393
|
let bytes
|
|
378
394
|
let err = null
|
|
@@ -382,12 +398,14 @@ async function write(fd, data, offset = 0, len, pos = -1, cb) {
|
|
|
382
398
|
bytes = await req
|
|
383
399
|
} catch (e) {
|
|
384
400
|
err = new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
401
|
+
} finally {
|
|
402
|
+
req.return()
|
|
385
403
|
}
|
|
386
404
|
|
|
387
405
|
return done(err, bytes, cb)
|
|
388
406
|
}
|
|
389
407
|
|
|
390
|
-
function writeSync(fd, data, offset
|
|
408
|
+
function writeSync(fd, data, offset, len, pos = -1) {
|
|
391
409
|
if (typeof data === 'string') {
|
|
392
410
|
let encoding = len
|
|
393
411
|
pos = offset
|
|
@@ -402,15 +420,18 @@ function writeSync(fd, data, offset = 0, len, pos = -1) {
|
|
|
402
420
|
len = data.byteLength
|
|
403
421
|
}
|
|
404
422
|
|
|
423
|
+
if (typeof offset !== 'number') offset = 0
|
|
405
424
|
if (typeof len !== 'number') len = data.byteLength - offset
|
|
406
425
|
if (typeof pos !== 'number') pos = -1
|
|
407
426
|
|
|
408
|
-
|
|
427
|
+
const req = FileRequest.borrow()
|
|
409
428
|
|
|
410
429
|
try {
|
|
411
430
|
return binding.writeSync(req.handle, fd, data, offset, len, pos)
|
|
412
431
|
} catch (e) {
|
|
413
432
|
throw new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
433
|
+
} finally {
|
|
434
|
+
req.return()
|
|
414
435
|
}
|
|
415
436
|
}
|
|
416
437
|
|
|
@@ -422,7 +443,7 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
422
443
|
|
|
423
444
|
if (typeof pos !== 'number') pos = -1
|
|
424
445
|
|
|
425
|
-
|
|
446
|
+
const req = FileRequest.borrow()
|
|
426
447
|
|
|
427
448
|
let bytes
|
|
428
449
|
let err = null
|
|
@@ -432,6 +453,8 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
432
453
|
bytes = await req
|
|
433
454
|
} catch (e) {
|
|
434
455
|
err = new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
456
|
+
} finally {
|
|
457
|
+
req.return()
|
|
435
458
|
}
|
|
436
459
|
|
|
437
460
|
return done(err, bytes, cb)
|
|
@@ -440,19 +463,21 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
440
463
|
function writevSync(fd, buffers, pos = -1) {
|
|
441
464
|
if (typeof pos !== 'number') pos = -1
|
|
442
465
|
|
|
443
|
-
|
|
466
|
+
const req = FileRequest.borrow()
|
|
444
467
|
|
|
445
468
|
try {
|
|
446
469
|
return binding.writevSync(req.handle, fd, buffers, pos)
|
|
447
470
|
} catch (e) {
|
|
448
471
|
throw new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
472
|
+
} finally {
|
|
473
|
+
req.return()
|
|
449
474
|
}
|
|
450
475
|
}
|
|
451
476
|
|
|
452
477
|
async function stat(filepath, cb) {
|
|
453
478
|
filepath = toNamespacedPath(filepath)
|
|
454
479
|
|
|
455
|
-
|
|
480
|
+
const req = FileRequest.borrow()
|
|
456
481
|
|
|
457
482
|
let st
|
|
458
483
|
let err = null
|
|
@@ -468,6 +493,8 @@ async function stat(filepath, cb) {
|
|
|
468
493
|
code: e.code,
|
|
469
494
|
path: filepath
|
|
470
495
|
})
|
|
496
|
+
} finally {
|
|
497
|
+
req.return()
|
|
471
498
|
}
|
|
472
499
|
|
|
473
500
|
return done(err, st, cb)
|
|
@@ -476,7 +503,7 @@ async function stat(filepath, cb) {
|
|
|
476
503
|
function statSync(filepath) {
|
|
477
504
|
filepath = toNamespacedPath(filepath)
|
|
478
505
|
|
|
479
|
-
|
|
506
|
+
const req = FileRequest.borrow()
|
|
480
507
|
|
|
481
508
|
try {
|
|
482
509
|
binding.statSync(req.handle, filepath)
|
|
@@ -488,13 +515,15 @@ function statSync(filepath) {
|
|
|
488
515
|
code: e.code,
|
|
489
516
|
path: filepath
|
|
490
517
|
})
|
|
518
|
+
} finally {
|
|
519
|
+
req.return()
|
|
491
520
|
}
|
|
492
521
|
}
|
|
493
522
|
|
|
494
523
|
async function lstat(filepath, cb) {
|
|
495
524
|
filepath = toNamespacedPath(filepath)
|
|
496
525
|
|
|
497
|
-
|
|
526
|
+
const req = FileRequest.borrow()
|
|
498
527
|
|
|
499
528
|
let st
|
|
500
529
|
let err = null
|
|
@@ -510,6 +539,8 @@ async function lstat(filepath, cb) {
|
|
|
510
539
|
code: e.code,
|
|
511
540
|
path: filepath
|
|
512
541
|
})
|
|
542
|
+
} finally {
|
|
543
|
+
req.return()
|
|
513
544
|
}
|
|
514
545
|
|
|
515
546
|
return done(err, st, cb)
|
|
@@ -518,7 +549,7 @@ async function lstat(filepath, cb) {
|
|
|
518
549
|
function lstatSync(filepath) {
|
|
519
550
|
filepath = toNamespacedPath(filepath)
|
|
520
551
|
|
|
521
|
-
|
|
552
|
+
const req = FileRequest.borrow()
|
|
522
553
|
|
|
523
554
|
try {
|
|
524
555
|
binding.lstatSync(req.handle, filepath)
|
|
@@ -530,11 +561,13 @@ function lstatSync(filepath) {
|
|
|
530
561
|
code: e.code,
|
|
531
562
|
path: filepath
|
|
532
563
|
})
|
|
564
|
+
} finally {
|
|
565
|
+
req.return()
|
|
533
566
|
}
|
|
534
567
|
}
|
|
535
568
|
|
|
536
569
|
async function fstat(fd, cb) {
|
|
537
|
-
|
|
570
|
+
const req = FileRequest.borrow()
|
|
538
571
|
|
|
539
572
|
let st
|
|
540
573
|
let err = null
|
|
@@ -546,13 +579,15 @@ async function fstat(fd, cb) {
|
|
|
546
579
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
547
580
|
} catch (e) {
|
|
548
581
|
err = new FileError(e.message, { operation: 'fstat', code: e.code, fd })
|
|
582
|
+
} finally {
|
|
583
|
+
req.return()
|
|
549
584
|
}
|
|
550
585
|
|
|
551
586
|
return done(err, st, cb)
|
|
552
587
|
}
|
|
553
588
|
|
|
554
589
|
function fstatSync(fd) {
|
|
555
|
-
|
|
590
|
+
const req = FileRequest.borrow()
|
|
556
591
|
|
|
557
592
|
try {
|
|
558
593
|
binding.fstatSync(req.handle, fd)
|
|
@@ -560,6 +595,8 @@ function fstatSync(fd) {
|
|
|
560
595
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
561
596
|
} catch (e) {
|
|
562
597
|
throw new FileError(e.message, { operation: 'fstat', code: e.code, fd })
|
|
598
|
+
} finally {
|
|
599
|
+
req.return()
|
|
563
600
|
}
|
|
564
601
|
}
|
|
565
602
|
|
|
@@ -571,7 +608,7 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
571
608
|
|
|
572
609
|
if (typeof len !== 'number') len = 0
|
|
573
610
|
|
|
574
|
-
|
|
611
|
+
const req = FileRequest.borrow()
|
|
575
612
|
|
|
576
613
|
let err = null
|
|
577
614
|
try {
|
|
@@ -580,6 +617,8 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
580
617
|
await req
|
|
581
618
|
} catch (e) {
|
|
582
619
|
err = new FileError(e.message, { operation: 'ftruncate', code: e.code, fd })
|
|
620
|
+
} finally {
|
|
621
|
+
req.return()
|
|
583
622
|
}
|
|
584
623
|
|
|
585
624
|
return done(err, cb)
|
|
@@ -588,12 +627,14 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
588
627
|
function ftruncateSync(fd, len = 0) {
|
|
589
628
|
if (typeof len !== 'number') len = 0
|
|
590
629
|
|
|
591
|
-
|
|
630
|
+
const req = FileRequest.borrow()
|
|
592
631
|
|
|
593
632
|
try {
|
|
594
633
|
binding.ftruncateSync(req.handle, fd, len)
|
|
595
634
|
} catch (e) {
|
|
596
635
|
throw new FileError(e.message, { operation: 'ftruncate', code: e.code, fd })
|
|
636
|
+
} finally {
|
|
637
|
+
req.return()
|
|
597
638
|
}
|
|
598
639
|
}
|
|
599
640
|
|
|
@@ -602,7 +643,7 @@ async function chmod(filepath, mode, cb) {
|
|
|
602
643
|
|
|
603
644
|
filepath = toNamespacedPath(filepath)
|
|
604
645
|
|
|
605
|
-
|
|
646
|
+
const req = FileRequest.borrow()
|
|
606
647
|
|
|
607
648
|
let err = null
|
|
608
649
|
try {
|
|
@@ -615,6 +656,8 @@ async function chmod(filepath, mode, cb) {
|
|
|
615
656
|
code: e.code,
|
|
616
657
|
path: filepath
|
|
617
658
|
})
|
|
659
|
+
} finally {
|
|
660
|
+
req.return()
|
|
618
661
|
}
|
|
619
662
|
|
|
620
663
|
return done(err, cb)
|
|
@@ -625,7 +668,7 @@ function chmodSync(filepath, mode) {
|
|
|
625
668
|
|
|
626
669
|
filepath = toNamespacedPath(filepath)
|
|
627
670
|
|
|
628
|
-
|
|
671
|
+
const req = FileRequest.borrow()
|
|
629
672
|
|
|
630
673
|
try {
|
|
631
674
|
binding.chmodSync(req.handle, filepath, mode)
|
|
@@ -635,13 +678,15 @@ function chmodSync(filepath, mode) {
|
|
|
635
678
|
code: e.code,
|
|
636
679
|
path: filepath
|
|
637
680
|
})
|
|
681
|
+
} finally {
|
|
682
|
+
req.return()
|
|
638
683
|
}
|
|
639
684
|
}
|
|
640
685
|
|
|
641
686
|
async function fchmod(fd, mode, cb) {
|
|
642
687
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
643
688
|
|
|
644
|
-
|
|
689
|
+
const req = FileRequest.borrow()
|
|
645
690
|
|
|
646
691
|
let err = null
|
|
647
692
|
try {
|
|
@@ -650,6 +695,8 @@ async function fchmod(fd, mode, cb) {
|
|
|
650
695
|
await req
|
|
651
696
|
} catch (e) {
|
|
652
697
|
err = new FileError(e.message, { operation: 'fchmod', code: e.code, fd })
|
|
698
|
+
} finally {
|
|
699
|
+
req.return()
|
|
653
700
|
}
|
|
654
701
|
|
|
655
702
|
return done(err, cb)
|
|
@@ -658,12 +705,14 @@ async function fchmod(fd, mode, cb) {
|
|
|
658
705
|
function fchmodSync(fd, mode) {
|
|
659
706
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
660
707
|
|
|
661
|
-
|
|
708
|
+
const req = FileRequest.borrow()
|
|
662
709
|
|
|
663
710
|
try {
|
|
664
711
|
binding.fchmodSync(req.handle, fd, mode)
|
|
665
712
|
} catch (e) {
|
|
666
713
|
throw new FileError(e.message, { operation: 'fchmod', code: e.code, fd })
|
|
714
|
+
} finally {
|
|
715
|
+
req.return()
|
|
667
716
|
}
|
|
668
717
|
}
|
|
669
718
|
|
|
@@ -673,7 +722,7 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
673
722
|
|
|
674
723
|
filepath = toNamespacedPath(filepath)
|
|
675
724
|
|
|
676
|
-
|
|
725
|
+
const req = FileRequest.borrow()
|
|
677
726
|
|
|
678
727
|
let err = null
|
|
679
728
|
try {
|
|
@@ -686,6 +735,8 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
686
735
|
code: e.code,
|
|
687
736
|
path: filepath
|
|
688
737
|
})
|
|
738
|
+
} finally {
|
|
739
|
+
req.return()
|
|
689
740
|
}
|
|
690
741
|
|
|
691
742
|
return done(err, cb)
|
|
@@ -697,7 +748,7 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
697
748
|
|
|
698
749
|
filepath = toNamespacedPath(filepath)
|
|
699
750
|
|
|
700
|
-
|
|
751
|
+
const req = FileRequest.borrow()
|
|
701
752
|
|
|
702
753
|
try {
|
|
703
754
|
binding.utimesSync(req.handle, filepath, atime, mtime)
|
|
@@ -707,6 +758,8 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
707
758
|
code: e.code,
|
|
708
759
|
path: filepath
|
|
709
760
|
})
|
|
761
|
+
} finally {
|
|
762
|
+
req.return()
|
|
710
763
|
}
|
|
711
764
|
}
|
|
712
765
|
|
|
@@ -752,7 +805,7 @@ async function mkdir(filepath, opts, cb) {
|
|
|
752
805
|
return done(err, cb)
|
|
753
806
|
}
|
|
754
807
|
|
|
755
|
-
|
|
808
|
+
const req = FileRequest.borrow()
|
|
756
809
|
|
|
757
810
|
let err = null
|
|
758
811
|
try {
|
|
@@ -765,6 +818,8 @@ async function mkdir(filepath, opts, cb) {
|
|
|
765
818
|
code: e.code,
|
|
766
819
|
path: filepath
|
|
767
820
|
})
|
|
821
|
+
} finally {
|
|
822
|
+
req.return()
|
|
768
823
|
}
|
|
769
824
|
|
|
770
825
|
return done(err, cb)
|
|
@@ -802,7 +857,7 @@ function mkdirSync(filepath, opts) {
|
|
|
802
857
|
return
|
|
803
858
|
}
|
|
804
859
|
|
|
805
|
-
|
|
860
|
+
const req = FileRequest.borrow()
|
|
806
861
|
|
|
807
862
|
try {
|
|
808
863
|
binding.mkdirSync(req.handle, filepath, mode)
|
|
@@ -812,13 +867,15 @@ function mkdirSync(filepath, opts) {
|
|
|
812
867
|
code: e.code,
|
|
813
868
|
path: filepath
|
|
814
869
|
})
|
|
870
|
+
} finally {
|
|
871
|
+
req.return()
|
|
815
872
|
}
|
|
816
873
|
}
|
|
817
874
|
|
|
818
875
|
async function rmdir(filepath, cb) {
|
|
819
876
|
filepath = toNamespacedPath(filepath)
|
|
820
877
|
|
|
821
|
-
|
|
878
|
+
const req = FileRequest.borrow()
|
|
822
879
|
|
|
823
880
|
let err = null
|
|
824
881
|
try {
|
|
@@ -831,6 +888,8 @@ async function rmdir(filepath, cb) {
|
|
|
831
888
|
code: e.code,
|
|
832
889
|
path: filepath
|
|
833
890
|
})
|
|
891
|
+
} finally {
|
|
892
|
+
req.return()
|
|
834
893
|
}
|
|
835
894
|
|
|
836
895
|
return done(err, cb)
|
|
@@ -839,7 +898,7 @@ async function rmdir(filepath, cb) {
|
|
|
839
898
|
function rmdirSync(filepath) {
|
|
840
899
|
filepath = toNamespacedPath(filepath)
|
|
841
900
|
|
|
842
|
-
|
|
901
|
+
const req = FileRequest.borrow()
|
|
843
902
|
|
|
844
903
|
try {
|
|
845
904
|
binding.rmdirSync(req.handle, filepath)
|
|
@@ -849,6 +908,8 @@ function rmdirSync(filepath) {
|
|
|
849
908
|
code: e.code,
|
|
850
909
|
path: filepath
|
|
851
910
|
})
|
|
911
|
+
} finally {
|
|
912
|
+
req.return()
|
|
852
913
|
}
|
|
853
914
|
}
|
|
854
915
|
|
|
@@ -939,7 +1000,7 @@ function rmSync(filepath, opts) {
|
|
|
939
1000
|
async function unlink(filepath, cb) {
|
|
940
1001
|
filepath = toNamespacedPath(filepath)
|
|
941
1002
|
|
|
942
|
-
|
|
1003
|
+
const req = FileRequest.borrow()
|
|
943
1004
|
|
|
944
1005
|
let err = null
|
|
945
1006
|
try {
|
|
@@ -952,6 +1013,8 @@ async function unlink(filepath, cb) {
|
|
|
952
1013
|
code: e.code,
|
|
953
1014
|
path: filepath
|
|
954
1015
|
})
|
|
1016
|
+
} finally {
|
|
1017
|
+
req.return()
|
|
955
1018
|
}
|
|
956
1019
|
|
|
957
1020
|
return done(err, cb)
|
|
@@ -960,7 +1023,7 @@ async function unlink(filepath, cb) {
|
|
|
960
1023
|
function unlinkSync(filepath) {
|
|
961
1024
|
filepath = toNamespacedPath(filepath)
|
|
962
1025
|
|
|
963
|
-
|
|
1026
|
+
const req = FileRequest.borrow()
|
|
964
1027
|
|
|
965
1028
|
try {
|
|
966
1029
|
binding.unlinkSync(req.handle, filepath)
|
|
@@ -970,6 +1033,8 @@ function unlinkSync(filepath) {
|
|
|
970
1033
|
code: e.code,
|
|
971
1034
|
path: filepath
|
|
972
1035
|
})
|
|
1036
|
+
} finally {
|
|
1037
|
+
req.return()
|
|
973
1038
|
}
|
|
974
1039
|
}
|
|
975
1040
|
|
|
@@ -977,7 +1042,7 @@ async function rename(src, dst, cb) {
|
|
|
977
1042
|
src = toNamespacedPath(src)
|
|
978
1043
|
dst = toNamespacedPath(dst)
|
|
979
1044
|
|
|
980
|
-
|
|
1045
|
+
const req = FileRequest.borrow()
|
|
981
1046
|
|
|
982
1047
|
let err = null
|
|
983
1048
|
try {
|
|
@@ -991,6 +1056,8 @@ async function rename(src, dst, cb) {
|
|
|
991
1056
|
path: src,
|
|
992
1057
|
destination: dst
|
|
993
1058
|
})
|
|
1059
|
+
} finally {
|
|
1060
|
+
req.return()
|
|
994
1061
|
}
|
|
995
1062
|
|
|
996
1063
|
return done(err, cb)
|
|
@@ -1000,7 +1067,7 @@ function renameSync(src, dst) {
|
|
|
1000
1067
|
src = toNamespacedPath(src)
|
|
1001
1068
|
dst = toNamespacedPath(dst)
|
|
1002
1069
|
|
|
1003
|
-
|
|
1070
|
+
const req = FileRequest.borrow()
|
|
1004
1071
|
|
|
1005
1072
|
try {
|
|
1006
1073
|
binding.renameSync(req.handle, src, dst)
|
|
@@ -1011,6 +1078,8 @@ function renameSync(src, dst) {
|
|
|
1011
1078
|
path: src,
|
|
1012
1079
|
destination: dst
|
|
1013
1080
|
})
|
|
1081
|
+
} finally {
|
|
1082
|
+
req.return()
|
|
1014
1083
|
}
|
|
1015
1084
|
}
|
|
1016
1085
|
|
|
@@ -1023,7 +1092,7 @@ async function copyFile(src, dst, mode = 0, cb) {
|
|
|
1023
1092
|
src = toNamespacedPath(src)
|
|
1024
1093
|
dst = toNamespacedPath(dst)
|
|
1025
1094
|
|
|
1026
|
-
|
|
1095
|
+
const req = FileRequest.borrow()
|
|
1027
1096
|
|
|
1028
1097
|
let err = null
|
|
1029
1098
|
try {
|
|
@@ -1037,6 +1106,8 @@ async function copyFile(src, dst, mode = 0, cb) {
|
|
|
1037
1106
|
path: src,
|
|
1038
1107
|
destination: dst
|
|
1039
1108
|
})
|
|
1109
|
+
} finally {
|
|
1110
|
+
req.return()
|
|
1040
1111
|
}
|
|
1041
1112
|
|
|
1042
1113
|
return done(err, cb)
|
|
@@ -1046,7 +1117,7 @@ function copyFileSync(src, dst, mode = 0) {
|
|
|
1046
1117
|
src = toNamespacedPath(src)
|
|
1047
1118
|
dst = toNamespacedPath(dst)
|
|
1048
1119
|
|
|
1049
|
-
|
|
1120
|
+
const req = FileRequest.borrow()
|
|
1050
1121
|
|
|
1051
1122
|
try {
|
|
1052
1123
|
binding.copyfileSync(req.handle, src, dst, mode)
|
|
@@ -1057,6 +1128,8 @@ function copyFileSync(src, dst, mode = 0) {
|
|
|
1057
1128
|
path: src,
|
|
1058
1129
|
destination: dst
|
|
1059
1130
|
})
|
|
1131
|
+
} finally {
|
|
1132
|
+
req.return()
|
|
1060
1133
|
}
|
|
1061
1134
|
}
|
|
1062
1135
|
|
|
@@ -1122,7 +1195,7 @@ async function realpath(filepath, opts, cb) {
|
|
|
1122
1195
|
|
|
1123
1196
|
filepath = toNamespacedPath(filepath)
|
|
1124
1197
|
|
|
1125
|
-
|
|
1198
|
+
const req = FileRequest.borrow()
|
|
1126
1199
|
|
|
1127
1200
|
let res
|
|
1128
1201
|
let err = null
|
|
@@ -1140,6 +1213,8 @@ async function realpath(filepath, opts, cb) {
|
|
|
1140
1213
|
code: e.code,
|
|
1141
1214
|
path: filepath
|
|
1142
1215
|
})
|
|
1216
|
+
} finally {
|
|
1217
|
+
req.return()
|
|
1143
1218
|
}
|
|
1144
1219
|
|
|
1145
1220
|
return done(err, res, cb)
|
|
@@ -1153,7 +1228,7 @@ function realpathSync(filepath, opts) {
|
|
|
1153
1228
|
|
|
1154
1229
|
filepath = toNamespacedPath(filepath)
|
|
1155
1230
|
|
|
1156
|
-
|
|
1231
|
+
const req = FileRequest.borrow()
|
|
1157
1232
|
|
|
1158
1233
|
try {
|
|
1159
1234
|
binding.realpathSync(req.handle, filepath)
|
|
@@ -1169,6 +1244,8 @@ function realpathSync(filepath, opts) {
|
|
|
1169
1244
|
code: e.code,
|
|
1170
1245
|
path: filepath
|
|
1171
1246
|
})
|
|
1247
|
+
} finally {
|
|
1248
|
+
req.return()
|
|
1172
1249
|
}
|
|
1173
1250
|
}
|
|
1174
1251
|
|
|
@@ -1185,7 +1262,7 @@ async function readlink(filepath, opts, cb) {
|
|
|
1185
1262
|
|
|
1186
1263
|
filepath = toNamespacedPath(filepath)
|
|
1187
1264
|
|
|
1188
|
-
|
|
1265
|
+
const req = FileRequest.borrow()
|
|
1189
1266
|
|
|
1190
1267
|
let res
|
|
1191
1268
|
let err = null
|
|
@@ -1203,6 +1280,8 @@ async function readlink(filepath, opts, cb) {
|
|
|
1203
1280
|
code: e.code,
|
|
1204
1281
|
path: filepath
|
|
1205
1282
|
})
|
|
1283
|
+
} finally {
|
|
1284
|
+
req.return()
|
|
1206
1285
|
}
|
|
1207
1286
|
|
|
1208
1287
|
return done(err, res, cb)
|
|
@@ -1216,7 +1295,7 @@ function readlinkSync(filepath, opts) {
|
|
|
1216
1295
|
|
|
1217
1296
|
filepath = toNamespacedPath(filepath)
|
|
1218
1297
|
|
|
1219
|
-
|
|
1298
|
+
const req = FileRequest.borrow()
|
|
1220
1299
|
|
|
1221
1300
|
try {
|
|
1222
1301
|
binding.readlinkSync(req.handle, filepath)
|
|
@@ -1232,12 +1311,14 @@ function readlinkSync(filepath, opts) {
|
|
|
1232
1311
|
code: e.code,
|
|
1233
1312
|
path: filepath
|
|
1234
1313
|
})
|
|
1314
|
+
} finally {
|
|
1315
|
+
req.return()
|
|
1235
1316
|
}
|
|
1236
1317
|
}
|
|
1237
1318
|
|
|
1238
1319
|
function normalizeSymlinkTarget(target, type, filepath) {
|
|
1239
1320
|
if (isWindows) {
|
|
1240
|
-
if (type ===
|
|
1321
|
+
if (type === constants.UV_FS_SYMLINK_JUNCTION) target = path.resolve(filepath, '..', target)
|
|
1241
1322
|
|
|
1242
1323
|
if (path.isAbsolute(target)) return path.toNamespacedPath(target)
|
|
1243
1324
|
|
|
@@ -1284,9 +1365,9 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1284
1365
|
}
|
|
1285
1366
|
}
|
|
1286
1367
|
|
|
1287
|
-
target = normalizeSymlinkTarget(target)
|
|
1368
|
+
target = normalizeSymlinkTarget(target, type, filepath)
|
|
1288
1369
|
|
|
1289
|
-
|
|
1370
|
+
const req = FileRequest.borrow()
|
|
1290
1371
|
|
|
1291
1372
|
let err = null
|
|
1292
1373
|
try {
|
|
@@ -1300,6 +1381,8 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1300
1381
|
path: target,
|
|
1301
1382
|
destination: filepath
|
|
1302
1383
|
})
|
|
1384
|
+
} finally {
|
|
1385
|
+
req.return()
|
|
1303
1386
|
}
|
|
1304
1387
|
|
|
1305
1388
|
return done(err, cb)
|
|
@@ -1337,9 +1420,9 @@ function symlinkSync(target, filepath, type) {
|
|
|
1337
1420
|
}
|
|
1338
1421
|
}
|
|
1339
1422
|
|
|
1340
|
-
target = normalizeSymlinkTarget(target)
|
|
1423
|
+
target = normalizeSymlinkTarget(target, type, filepath)
|
|
1341
1424
|
|
|
1342
|
-
|
|
1425
|
+
const req = FileRequest.borrow()
|
|
1343
1426
|
|
|
1344
1427
|
try {
|
|
1345
1428
|
binding.symlinkSync(req.handle, target, filepath, type)
|
|
@@ -1350,6 +1433,8 @@ function symlinkSync(target, filepath, type) {
|
|
|
1350
1433
|
path: target,
|
|
1351
1434
|
destination: filepath
|
|
1352
1435
|
})
|
|
1436
|
+
} finally {
|
|
1437
|
+
req.return()
|
|
1353
1438
|
}
|
|
1354
1439
|
}
|
|
1355
1440
|
|
|
@@ -1364,7 +1449,7 @@ async function opendir(filepath, opts, cb) {
|
|
|
1364
1449
|
|
|
1365
1450
|
filepath = toNamespacedPath(filepath)
|
|
1366
1451
|
|
|
1367
|
-
|
|
1452
|
+
const req = FileRequest.borrow()
|
|
1368
1453
|
|
|
1369
1454
|
let dir
|
|
1370
1455
|
let err = null
|
|
@@ -1380,6 +1465,8 @@ async function opendir(filepath, opts, cb) {
|
|
|
1380
1465
|
code: e.code,
|
|
1381
1466
|
path: filepath
|
|
1382
1467
|
})
|
|
1468
|
+
} finally {
|
|
1469
|
+
req.return()
|
|
1383
1470
|
}
|
|
1384
1471
|
|
|
1385
1472
|
return done(err, dir, cb)
|
|
@@ -1391,7 +1478,7 @@ function opendirSync(filepath, opts) {
|
|
|
1391
1478
|
|
|
1392
1479
|
filepath = toNamespacedPath(filepath)
|
|
1393
1480
|
|
|
1394
|
-
|
|
1481
|
+
const req = FileRequest.borrow()
|
|
1395
1482
|
|
|
1396
1483
|
try {
|
|
1397
1484
|
binding.opendirSync(req.handle, filepath)
|
|
@@ -1403,6 +1490,8 @@ function opendirSync(filepath, opts) {
|
|
|
1403
1490
|
code: e.code,
|
|
1404
1491
|
path: filepath
|
|
1405
1492
|
})
|
|
1493
|
+
} finally {
|
|
1494
|
+
req.return()
|
|
1406
1495
|
}
|
|
1407
1496
|
}
|
|
1408
1497
|
|
|
@@ -1693,7 +1782,7 @@ class Stats {
|
|
|
1693
1782
|
}
|
|
1694
1783
|
|
|
1695
1784
|
isCharacterDevice() {
|
|
1696
|
-
return (this.mode & constants.
|
|
1785
|
+
return (this.mode & constants.S_IFMT) === constants.S_IFCHR
|
|
1697
1786
|
}
|
|
1698
1787
|
|
|
1699
1788
|
isFIFO() {
|
|
@@ -1726,7 +1815,7 @@ class Dir {
|
|
|
1726
1815
|
if (this._buffer.length) return ok(this._buffer.shift(), cb)
|
|
1727
1816
|
if (this._ended) return ok(null, cb)
|
|
1728
1817
|
|
|
1729
|
-
|
|
1818
|
+
const req = FileRequest.borrow()
|
|
1730
1819
|
|
|
1731
1820
|
let entries
|
|
1732
1821
|
let err = null
|
|
@@ -1742,6 +1831,8 @@ class Dir {
|
|
|
1742
1831
|
code: e.code,
|
|
1743
1832
|
path: this.path
|
|
1744
1833
|
})
|
|
1834
|
+
} finally {
|
|
1835
|
+
req.return()
|
|
1745
1836
|
}
|
|
1746
1837
|
|
|
1747
1838
|
if (err) return fail(err, cb)
|
|
@@ -1767,7 +1858,7 @@ class Dir {
|
|
|
1767
1858
|
if (this._buffer.length) return this._buffer.shift()
|
|
1768
1859
|
if (this._ended) return null
|
|
1769
1860
|
|
|
1770
|
-
|
|
1861
|
+
const req = FileRequest.borrow()
|
|
1771
1862
|
|
|
1772
1863
|
let entries
|
|
1773
1864
|
try {
|
|
@@ -1780,6 +1871,8 @@ class Dir {
|
|
|
1780
1871
|
code: e.code,
|
|
1781
1872
|
path: this.path
|
|
1782
1873
|
})
|
|
1874
|
+
} finally {
|
|
1875
|
+
req.return()
|
|
1783
1876
|
}
|
|
1784
1877
|
|
|
1785
1878
|
if (entries.length === 0) {
|
|
@@ -1800,7 +1893,7 @@ class Dir {
|
|
|
1800
1893
|
}
|
|
1801
1894
|
|
|
1802
1895
|
async close(cb) {
|
|
1803
|
-
|
|
1896
|
+
const req = FileRequest.borrow()
|
|
1804
1897
|
|
|
1805
1898
|
let err = null
|
|
1806
1899
|
try {
|
|
@@ -1813,6 +1906,8 @@ class Dir {
|
|
|
1813
1906
|
code: e.code,
|
|
1814
1907
|
path: this.path
|
|
1815
1908
|
})
|
|
1909
|
+
} finally {
|
|
1910
|
+
req.return()
|
|
1816
1911
|
}
|
|
1817
1912
|
|
|
1818
1913
|
this._handle = null
|
|
@@ -1821,7 +1916,7 @@ class Dir {
|
|
|
1821
1916
|
}
|
|
1822
1917
|
|
|
1823
1918
|
closeSync() {
|
|
1824
|
-
|
|
1919
|
+
const req = FileRequest.borrow()
|
|
1825
1920
|
|
|
1826
1921
|
try {
|
|
1827
1922
|
binding.closedirSync(req.handle, this._handle)
|
|
@@ -1831,6 +1926,8 @@ class Dir {
|
|
|
1831
1926
|
code: e.code,
|
|
1832
1927
|
path: this.path
|
|
1833
1928
|
})
|
|
1929
|
+
} finally {
|
|
1930
|
+
req.return()
|
|
1834
1931
|
}
|
|
1835
1932
|
|
|
1836
1933
|
this._handle = null
|
|
@@ -1988,11 +2085,10 @@ class FileReadStream extends Readable {
|
|
|
1988
2085
|
async _destroy(err, cb) {
|
|
1989
2086
|
if (this.fd === -1) return cb(err)
|
|
1990
2087
|
|
|
1991
|
-
err = null
|
|
1992
2088
|
try {
|
|
1993
2089
|
await close(this.fd)
|
|
1994
2090
|
} catch (e) {
|
|
1995
|
-
err = e
|
|
2091
|
+
err = err || e
|
|
1996
2092
|
}
|
|
1997
2093
|
|
|
1998
2094
|
cb(err)
|
|
@@ -2041,11 +2137,10 @@ class FileWriteStream extends Writable {
|
|
|
2041
2137
|
async _destroy(err, cb) {
|
|
2042
2138
|
if (this.fd === -1) return cb(err)
|
|
2043
2139
|
|
|
2044
|
-
err = null
|
|
2045
2140
|
try {
|
|
2046
2141
|
await close(this.fd)
|
|
2047
2142
|
} catch (e) {
|
|
2048
|
-
err = e
|
|
2143
|
+
err = err || e
|
|
2049
2144
|
}
|
|
2050
2145
|
|
|
2051
2146
|
cb(err)
|
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
|