bare-fs 4.5.4 → 4.5.6
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 +164 -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const FIFO = require('fast-fifo')
|
|
2
2
|
const EventEmitter = require('bare-events')
|
|
3
3
|
const path = require('bare-path')
|
|
4
|
-
const { fileURLToPath } = require('bare-url')
|
|
4
|
+
const { isURL, fileURLToPath } = require('bare-url')
|
|
5
5
|
const { Readable, Writable } = require('bare-stream')
|
|
6
6
|
const binding = require('./binding')
|
|
7
7
|
const constants = require('./lib/constants')
|
|
@@ -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,12 +336,14 @@ 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
|
|
|
@@ -373,7 +388,7 @@ async function write(fd, data, offset, len, pos = -1, cb) {
|
|
|
373
388
|
if (typeof len !== 'number') len = data.byteLength - offset
|
|
374
389
|
if (typeof pos !== 'number') pos = -1
|
|
375
390
|
|
|
376
|
-
|
|
391
|
+
const req = FileRequest.borrow()
|
|
377
392
|
|
|
378
393
|
let bytes
|
|
379
394
|
let err = null
|
|
@@ -383,6 +398,8 @@ async function write(fd, data, offset, len, pos = -1, cb) {
|
|
|
383
398
|
bytes = await req
|
|
384
399
|
} catch (e) {
|
|
385
400
|
err = new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
401
|
+
} finally {
|
|
402
|
+
req.return()
|
|
386
403
|
}
|
|
387
404
|
|
|
388
405
|
return done(err, bytes, cb)
|
|
@@ -407,12 +424,14 @@ function writeSync(fd, data, offset, len, pos = -1) {
|
|
|
407
424
|
if (typeof len !== 'number') len = data.byteLength - offset
|
|
408
425
|
if (typeof pos !== 'number') pos = -1
|
|
409
426
|
|
|
410
|
-
|
|
427
|
+
const req = FileRequest.borrow()
|
|
411
428
|
|
|
412
429
|
try {
|
|
413
430
|
return binding.writeSync(req.handle, fd, data, offset, len, pos)
|
|
414
431
|
} catch (e) {
|
|
415
432
|
throw new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
433
|
+
} finally {
|
|
434
|
+
req.return()
|
|
416
435
|
}
|
|
417
436
|
}
|
|
418
437
|
|
|
@@ -424,7 +443,7 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
424
443
|
|
|
425
444
|
if (typeof pos !== 'number') pos = -1
|
|
426
445
|
|
|
427
|
-
|
|
446
|
+
const req = FileRequest.borrow()
|
|
428
447
|
|
|
429
448
|
let bytes
|
|
430
449
|
let err = null
|
|
@@ -434,6 +453,8 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
434
453
|
bytes = await req
|
|
435
454
|
} catch (e) {
|
|
436
455
|
err = new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
456
|
+
} finally {
|
|
457
|
+
req.return()
|
|
437
458
|
}
|
|
438
459
|
|
|
439
460
|
return done(err, bytes, cb)
|
|
@@ -442,19 +463,21 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
442
463
|
function writevSync(fd, buffers, pos = -1) {
|
|
443
464
|
if (typeof pos !== 'number') pos = -1
|
|
444
465
|
|
|
445
|
-
|
|
466
|
+
const req = FileRequest.borrow()
|
|
446
467
|
|
|
447
468
|
try {
|
|
448
469
|
return binding.writevSync(req.handle, fd, buffers, pos)
|
|
449
470
|
} catch (e) {
|
|
450
471
|
throw new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
472
|
+
} finally {
|
|
473
|
+
req.return()
|
|
451
474
|
}
|
|
452
475
|
}
|
|
453
476
|
|
|
454
477
|
async function stat(filepath, cb) {
|
|
455
478
|
filepath = toNamespacedPath(filepath)
|
|
456
479
|
|
|
457
|
-
|
|
480
|
+
const req = FileRequest.borrow()
|
|
458
481
|
|
|
459
482
|
let st
|
|
460
483
|
let err = null
|
|
@@ -470,6 +493,8 @@ async function stat(filepath, cb) {
|
|
|
470
493
|
code: e.code,
|
|
471
494
|
path: filepath
|
|
472
495
|
})
|
|
496
|
+
} finally {
|
|
497
|
+
req.return()
|
|
473
498
|
}
|
|
474
499
|
|
|
475
500
|
return done(err, st, cb)
|
|
@@ -478,7 +503,7 @@ async function stat(filepath, cb) {
|
|
|
478
503
|
function statSync(filepath) {
|
|
479
504
|
filepath = toNamespacedPath(filepath)
|
|
480
505
|
|
|
481
|
-
|
|
506
|
+
const req = FileRequest.borrow()
|
|
482
507
|
|
|
483
508
|
try {
|
|
484
509
|
binding.statSync(req.handle, filepath)
|
|
@@ -490,13 +515,15 @@ function statSync(filepath) {
|
|
|
490
515
|
code: e.code,
|
|
491
516
|
path: filepath
|
|
492
517
|
})
|
|
518
|
+
} finally {
|
|
519
|
+
req.return()
|
|
493
520
|
}
|
|
494
521
|
}
|
|
495
522
|
|
|
496
523
|
async function lstat(filepath, cb) {
|
|
497
524
|
filepath = toNamespacedPath(filepath)
|
|
498
525
|
|
|
499
|
-
|
|
526
|
+
const req = FileRequest.borrow()
|
|
500
527
|
|
|
501
528
|
let st
|
|
502
529
|
let err = null
|
|
@@ -512,6 +539,8 @@ async function lstat(filepath, cb) {
|
|
|
512
539
|
code: e.code,
|
|
513
540
|
path: filepath
|
|
514
541
|
})
|
|
542
|
+
} finally {
|
|
543
|
+
req.return()
|
|
515
544
|
}
|
|
516
545
|
|
|
517
546
|
return done(err, st, cb)
|
|
@@ -520,7 +549,7 @@ async function lstat(filepath, cb) {
|
|
|
520
549
|
function lstatSync(filepath) {
|
|
521
550
|
filepath = toNamespacedPath(filepath)
|
|
522
551
|
|
|
523
|
-
|
|
552
|
+
const req = FileRequest.borrow()
|
|
524
553
|
|
|
525
554
|
try {
|
|
526
555
|
binding.lstatSync(req.handle, filepath)
|
|
@@ -532,11 +561,13 @@ function lstatSync(filepath) {
|
|
|
532
561
|
code: e.code,
|
|
533
562
|
path: filepath
|
|
534
563
|
})
|
|
564
|
+
} finally {
|
|
565
|
+
req.return()
|
|
535
566
|
}
|
|
536
567
|
}
|
|
537
568
|
|
|
538
569
|
async function fstat(fd, cb) {
|
|
539
|
-
|
|
570
|
+
const req = FileRequest.borrow()
|
|
540
571
|
|
|
541
572
|
let st
|
|
542
573
|
let err = null
|
|
@@ -548,13 +579,15 @@ async function fstat(fd, cb) {
|
|
|
548
579
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
549
580
|
} catch (e) {
|
|
550
581
|
err = new FileError(e.message, { operation: 'fstat', code: e.code, fd })
|
|
582
|
+
} finally {
|
|
583
|
+
req.return()
|
|
551
584
|
}
|
|
552
585
|
|
|
553
586
|
return done(err, st, cb)
|
|
554
587
|
}
|
|
555
588
|
|
|
556
589
|
function fstatSync(fd) {
|
|
557
|
-
|
|
590
|
+
const req = FileRequest.borrow()
|
|
558
591
|
|
|
559
592
|
try {
|
|
560
593
|
binding.fstatSync(req.handle, fd)
|
|
@@ -562,6 +595,8 @@ function fstatSync(fd) {
|
|
|
562
595
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
563
596
|
} catch (e) {
|
|
564
597
|
throw new FileError(e.message, { operation: 'fstat', code: e.code, fd })
|
|
598
|
+
} finally {
|
|
599
|
+
req.return()
|
|
565
600
|
}
|
|
566
601
|
}
|
|
567
602
|
|
|
@@ -573,7 +608,7 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
573
608
|
|
|
574
609
|
if (typeof len !== 'number') len = 0
|
|
575
610
|
|
|
576
|
-
|
|
611
|
+
const req = FileRequest.borrow()
|
|
577
612
|
|
|
578
613
|
let err = null
|
|
579
614
|
try {
|
|
@@ -582,6 +617,8 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
582
617
|
await req
|
|
583
618
|
} catch (e) {
|
|
584
619
|
err = new FileError(e.message, { operation: 'ftruncate', code: e.code, fd })
|
|
620
|
+
} finally {
|
|
621
|
+
req.return()
|
|
585
622
|
}
|
|
586
623
|
|
|
587
624
|
return done(err, cb)
|
|
@@ -590,12 +627,14 @@ async function ftruncate(fd, len = 0, cb) {
|
|
|
590
627
|
function ftruncateSync(fd, len = 0) {
|
|
591
628
|
if (typeof len !== 'number') len = 0
|
|
592
629
|
|
|
593
|
-
|
|
630
|
+
const req = FileRequest.borrow()
|
|
594
631
|
|
|
595
632
|
try {
|
|
596
633
|
binding.ftruncateSync(req.handle, fd, len)
|
|
597
634
|
} catch (e) {
|
|
598
635
|
throw new FileError(e.message, { operation: 'ftruncate', code: e.code, fd })
|
|
636
|
+
} finally {
|
|
637
|
+
req.return()
|
|
599
638
|
}
|
|
600
639
|
}
|
|
601
640
|
|
|
@@ -604,7 +643,7 @@ async function chmod(filepath, mode, cb) {
|
|
|
604
643
|
|
|
605
644
|
filepath = toNamespacedPath(filepath)
|
|
606
645
|
|
|
607
|
-
|
|
646
|
+
const req = FileRequest.borrow()
|
|
608
647
|
|
|
609
648
|
let err = null
|
|
610
649
|
try {
|
|
@@ -617,6 +656,8 @@ async function chmod(filepath, mode, cb) {
|
|
|
617
656
|
code: e.code,
|
|
618
657
|
path: filepath
|
|
619
658
|
})
|
|
659
|
+
} finally {
|
|
660
|
+
req.return()
|
|
620
661
|
}
|
|
621
662
|
|
|
622
663
|
return done(err, cb)
|
|
@@ -627,7 +668,7 @@ function chmodSync(filepath, mode) {
|
|
|
627
668
|
|
|
628
669
|
filepath = toNamespacedPath(filepath)
|
|
629
670
|
|
|
630
|
-
|
|
671
|
+
const req = FileRequest.borrow()
|
|
631
672
|
|
|
632
673
|
try {
|
|
633
674
|
binding.chmodSync(req.handle, filepath, mode)
|
|
@@ -637,13 +678,15 @@ function chmodSync(filepath, mode) {
|
|
|
637
678
|
code: e.code,
|
|
638
679
|
path: filepath
|
|
639
680
|
})
|
|
681
|
+
} finally {
|
|
682
|
+
req.return()
|
|
640
683
|
}
|
|
641
684
|
}
|
|
642
685
|
|
|
643
686
|
async function fchmod(fd, mode, cb) {
|
|
644
687
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
645
688
|
|
|
646
|
-
|
|
689
|
+
const req = FileRequest.borrow()
|
|
647
690
|
|
|
648
691
|
let err = null
|
|
649
692
|
try {
|
|
@@ -652,6 +695,8 @@ async function fchmod(fd, mode, cb) {
|
|
|
652
695
|
await req
|
|
653
696
|
} catch (e) {
|
|
654
697
|
err = new FileError(e.message, { operation: 'fchmod', code: e.code, fd })
|
|
698
|
+
} finally {
|
|
699
|
+
req.return()
|
|
655
700
|
}
|
|
656
701
|
|
|
657
702
|
return done(err, cb)
|
|
@@ -660,12 +705,14 @@ async function fchmod(fd, mode, cb) {
|
|
|
660
705
|
function fchmodSync(fd, mode) {
|
|
661
706
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
662
707
|
|
|
663
|
-
|
|
708
|
+
const req = FileRequest.borrow()
|
|
664
709
|
|
|
665
710
|
try {
|
|
666
711
|
binding.fchmodSync(req.handle, fd, mode)
|
|
667
712
|
} catch (e) {
|
|
668
713
|
throw new FileError(e.message, { operation: 'fchmod', code: e.code, fd })
|
|
714
|
+
} finally {
|
|
715
|
+
req.return()
|
|
669
716
|
}
|
|
670
717
|
}
|
|
671
718
|
|
|
@@ -675,7 +722,7 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
675
722
|
|
|
676
723
|
filepath = toNamespacedPath(filepath)
|
|
677
724
|
|
|
678
|
-
|
|
725
|
+
const req = FileRequest.borrow()
|
|
679
726
|
|
|
680
727
|
let err = null
|
|
681
728
|
try {
|
|
@@ -688,6 +735,8 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
688
735
|
code: e.code,
|
|
689
736
|
path: filepath
|
|
690
737
|
})
|
|
738
|
+
} finally {
|
|
739
|
+
req.return()
|
|
691
740
|
}
|
|
692
741
|
|
|
693
742
|
return done(err, cb)
|
|
@@ -699,7 +748,7 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
699
748
|
|
|
700
749
|
filepath = toNamespacedPath(filepath)
|
|
701
750
|
|
|
702
|
-
|
|
751
|
+
const req = FileRequest.borrow()
|
|
703
752
|
|
|
704
753
|
try {
|
|
705
754
|
binding.utimesSync(req.handle, filepath, atime, mtime)
|
|
@@ -709,6 +758,8 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
709
758
|
code: e.code,
|
|
710
759
|
path: filepath
|
|
711
760
|
})
|
|
761
|
+
} finally {
|
|
762
|
+
req.return()
|
|
712
763
|
}
|
|
713
764
|
}
|
|
714
765
|
|
|
@@ -754,7 +805,7 @@ async function mkdir(filepath, opts, cb) {
|
|
|
754
805
|
return done(err, cb)
|
|
755
806
|
}
|
|
756
807
|
|
|
757
|
-
|
|
808
|
+
const req = FileRequest.borrow()
|
|
758
809
|
|
|
759
810
|
let err = null
|
|
760
811
|
try {
|
|
@@ -767,6 +818,8 @@ async function mkdir(filepath, opts, cb) {
|
|
|
767
818
|
code: e.code,
|
|
768
819
|
path: filepath
|
|
769
820
|
})
|
|
821
|
+
} finally {
|
|
822
|
+
req.return()
|
|
770
823
|
}
|
|
771
824
|
|
|
772
825
|
return done(err, cb)
|
|
@@ -804,7 +857,7 @@ function mkdirSync(filepath, opts) {
|
|
|
804
857
|
return
|
|
805
858
|
}
|
|
806
859
|
|
|
807
|
-
|
|
860
|
+
const req = FileRequest.borrow()
|
|
808
861
|
|
|
809
862
|
try {
|
|
810
863
|
binding.mkdirSync(req.handle, filepath, mode)
|
|
@@ -814,13 +867,15 @@ function mkdirSync(filepath, opts) {
|
|
|
814
867
|
code: e.code,
|
|
815
868
|
path: filepath
|
|
816
869
|
})
|
|
870
|
+
} finally {
|
|
871
|
+
req.return()
|
|
817
872
|
}
|
|
818
873
|
}
|
|
819
874
|
|
|
820
875
|
async function rmdir(filepath, cb) {
|
|
821
876
|
filepath = toNamespacedPath(filepath)
|
|
822
877
|
|
|
823
|
-
|
|
878
|
+
const req = FileRequest.borrow()
|
|
824
879
|
|
|
825
880
|
let err = null
|
|
826
881
|
try {
|
|
@@ -833,6 +888,8 @@ async function rmdir(filepath, cb) {
|
|
|
833
888
|
code: e.code,
|
|
834
889
|
path: filepath
|
|
835
890
|
})
|
|
891
|
+
} finally {
|
|
892
|
+
req.return()
|
|
836
893
|
}
|
|
837
894
|
|
|
838
895
|
return done(err, cb)
|
|
@@ -841,7 +898,7 @@ async function rmdir(filepath, cb) {
|
|
|
841
898
|
function rmdirSync(filepath) {
|
|
842
899
|
filepath = toNamespacedPath(filepath)
|
|
843
900
|
|
|
844
|
-
|
|
901
|
+
const req = FileRequest.borrow()
|
|
845
902
|
|
|
846
903
|
try {
|
|
847
904
|
binding.rmdirSync(req.handle, filepath)
|
|
@@ -851,6 +908,8 @@ function rmdirSync(filepath) {
|
|
|
851
908
|
code: e.code,
|
|
852
909
|
path: filepath
|
|
853
910
|
})
|
|
911
|
+
} finally {
|
|
912
|
+
req.return()
|
|
854
913
|
}
|
|
855
914
|
}
|
|
856
915
|
|
|
@@ -941,7 +1000,7 @@ function rmSync(filepath, opts) {
|
|
|
941
1000
|
async function unlink(filepath, cb) {
|
|
942
1001
|
filepath = toNamespacedPath(filepath)
|
|
943
1002
|
|
|
944
|
-
|
|
1003
|
+
const req = FileRequest.borrow()
|
|
945
1004
|
|
|
946
1005
|
let err = null
|
|
947
1006
|
try {
|
|
@@ -954,6 +1013,8 @@ async function unlink(filepath, cb) {
|
|
|
954
1013
|
code: e.code,
|
|
955
1014
|
path: filepath
|
|
956
1015
|
})
|
|
1016
|
+
} finally {
|
|
1017
|
+
req.return()
|
|
957
1018
|
}
|
|
958
1019
|
|
|
959
1020
|
return done(err, cb)
|
|
@@ -962,7 +1023,7 @@ async function unlink(filepath, cb) {
|
|
|
962
1023
|
function unlinkSync(filepath) {
|
|
963
1024
|
filepath = toNamespacedPath(filepath)
|
|
964
1025
|
|
|
965
|
-
|
|
1026
|
+
const req = FileRequest.borrow()
|
|
966
1027
|
|
|
967
1028
|
try {
|
|
968
1029
|
binding.unlinkSync(req.handle, filepath)
|
|
@@ -972,6 +1033,8 @@ function unlinkSync(filepath) {
|
|
|
972
1033
|
code: e.code,
|
|
973
1034
|
path: filepath
|
|
974
1035
|
})
|
|
1036
|
+
} finally {
|
|
1037
|
+
req.return()
|
|
975
1038
|
}
|
|
976
1039
|
}
|
|
977
1040
|
|
|
@@ -979,7 +1042,7 @@ async function rename(src, dst, cb) {
|
|
|
979
1042
|
src = toNamespacedPath(src)
|
|
980
1043
|
dst = toNamespacedPath(dst)
|
|
981
1044
|
|
|
982
|
-
|
|
1045
|
+
const req = FileRequest.borrow()
|
|
983
1046
|
|
|
984
1047
|
let err = null
|
|
985
1048
|
try {
|
|
@@ -993,6 +1056,8 @@ async function rename(src, dst, cb) {
|
|
|
993
1056
|
path: src,
|
|
994
1057
|
destination: dst
|
|
995
1058
|
})
|
|
1059
|
+
} finally {
|
|
1060
|
+
req.return()
|
|
996
1061
|
}
|
|
997
1062
|
|
|
998
1063
|
return done(err, cb)
|
|
@@ -1002,7 +1067,7 @@ function renameSync(src, dst) {
|
|
|
1002
1067
|
src = toNamespacedPath(src)
|
|
1003
1068
|
dst = toNamespacedPath(dst)
|
|
1004
1069
|
|
|
1005
|
-
|
|
1070
|
+
const req = FileRequest.borrow()
|
|
1006
1071
|
|
|
1007
1072
|
try {
|
|
1008
1073
|
binding.renameSync(req.handle, src, dst)
|
|
@@ -1013,6 +1078,8 @@ function renameSync(src, dst) {
|
|
|
1013
1078
|
path: src,
|
|
1014
1079
|
destination: dst
|
|
1015
1080
|
})
|
|
1081
|
+
} finally {
|
|
1082
|
+
req.return()
|
|
1016
1083
|
}
|
|
1017
1084
|
}
|
|
1018
1085
|
|
|
@@ -1025,7 +1092,7 @@ async function copyFile(src, dst, mode = 0, cb) {
|
|
|
1025
1092
|
src = toNamespacedPath(src)
|
|
1026
1093
|
dst = toNamespacedPath(dst)
|
|
1027
1094
|
|
|
1028
|
-
|
|
1095
|
+
const req = FileRequest.borrow()
|
|
1029
1096
|
|
|
1030
1097
|
let err = null
|
|
1031
1098
|
try {
|
|
@@ -1039,6 +1106,8 @@ async function copyFile(src, dst, mode = 0, cb) {
|
|
|
1039
1106
|
path: src,
|
|
1040
1107
|
destination: dst
|
|
1041
1108
|
})
|
|
1109
|
+
} finally {
|
|
1110
|
+
req.return()
|
|
1042
1111
|
}
|
|
1043
1112
|
|
|
1044
1113
|
return done(err, cb)
|
|
@@ -1048,7 +1117,7 @@ function copyFileSync(src, dst, mode = 0) {
|
|
|
1048
1117
|
src = toNamespacedPath(src)
|
|
1049
1118
|
dst = toNamespacedPath(dst)
|
|
1050
1119
|
|
|
1051
|
-
|
|
1120
|
+
const req = FileRequest.borrow()
|
|
1052
1121
|
|
|
1053
1122
|
try {
|
|
1054
1123
|
binding.copyfileSync(req.handle, src, dst, mode)
|
|
@@ -1059,6 +1128,8 @@ function copyFileSync(src, dst, mode = 0) {
|
|
|
1059
1128
|
path: src,
|
|
1060
1129
|
destination: dst
|
|
1061
1130
|
})
|
|
1131
|
+
} finally {
|
|
1132
|
+
req.return()
|
|
1062
1133
|
}
|
|
1063
1134
|
}
|
|
1064
1135
|
|
|
@@ -1124,7 +1195,7 @@ async function realpath(filepath, opts, cb) {
|
|
|
1124
1195
|
|
|
1125
1196
|
filepath = toNamespacedPath(filepath)
|
|
1126
1197
|
|
|
1127
|
-
|
|
1198
|
+
const req = FileRequest.borrow()
|
|
1128
1199
|
|
|
1129
1200
|
let res
|
|
1130
1201
|
let err = null
|
|
@@ -1142,6 +1213,8 @@ async function realpath(filepath, opts, cb) {
|
|
|
1142
1213
|
code: e.code,
|
|
1143
1214
|
path: filepath
|
|
1144
1215
|
})
|
|
1216
|
+
} finally {
|
|
1217
|
+
req.return()
|
|
1145
1218
|
}
|
|
1146
1219
|
|
|
1147
1220
|
return done(err, res, cb)
|
|
@@ -1155,7 +1228,7 @@ function realpathSync(filepath, opts) {
|
|
|
1155
1228
|
|
|
1156
1229
|
filepath = toNamespacedPath(filepath)
|
|
1157
1230
|
|
|
1158
|
-
|
|
1231
|
+
const req = FileRequest.borrow()
|
|
1159
1232
|
|
|
1160
1233
|
try {
|
|
1161
1234
|
binding.realpathSync(req.handle, filepath)
|
|
@@ -1171,6 +1244,8 @@ function realpathSync(filepath, opts) {
|
|
|
1171
1244
|
code: e.code,
|
|
1172
1245
|
path: filepath
|
|
1173
1246
|
})
|
|
1247
|
+
} finally {
|
|
1248
|
+
req.return()
|
|
1174
1249
|
}
|
|
1175
1250
|
}
|
|
1176
1251
|
|
|
@@ -1187,7 +1262,7 @@ async function readlink(filepath, opts, cb) {
|
|
|
1187
1262
|
|
|
1188
1263
|
filepath = toNamespacedPath(filepath)
|
|
1189
1264
|
|
|
1190
|
-
|
|
1265
|
+
const req = FileRequest.borrow()
|
|
1191
1266
|
|
|
1192
1267
|
let res
|
|
1193
1268
|
let err = null
|
|
@@ -1205,6 +1280,8 @@ async function readlink(filepath, opts, cb) {
|
|
|
1205
1280
|
code: e.code,
|
|
1206
1281
|
path: filepath
|
|
1207
1282
|
})
|
|
1283
|
+
} finally {
|
|
1284
|
+
req.return()
|
|
1208
1285
|
}
|
|
1209
1286
|
|
|
1210
1287
|
return done(err, res, cb)
|
|
@@ -1218,7 +1295,7 @@ function readlinkSync(filepath, opts) {
|
|
|
1218
1295
|
|
|
1219
1296
|
filepath = toNamespacedPath(filepath)
|
|
1220
1297
|
|
|
1221
|
-
|
|
1298
|
+
const req = FileRequest.borrow()
|
|
1222
1299
|
|
|
1223
1300
|
try {
|
|
1224
1301
|
binding.readlinkSync(req.handle, filepath)
|
|
@@ -1234,12 +1311,14 @@ function readlinkSync(filepath, opts) {
|
|
|
1234
1311
|
code: e.code,
|
|
1235
1312
|
path: filepath
|
|
1236
1313
|
})
|
|
1314
|
+
} finally {
|
|
1315
|
+
req.return()
|
|
1237
1316
|
}
|
|
1238
1317
|
}
|
|
1239
1318
|
|
|
1240
1319
|
function normalizeSymlinkTarget(target, type, filepath) {
|
|
1241
1320
|
if (isWindows) {
|
|
1242
|
-
if (type ===
|
|
1321
|
+
if (type === constants.UV_FS_SYMLINK_JUNCTION) target = path.resolve(filepath, '..', target)
|
|
1243
1322
|
|
|
1244
1323
|
if (path.isAbsolute(target)) return path.toNamespacedPath(target)
|
|
1245
1324
|
|
|
@@ -1286,9 +1365,9 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1286
1365
|
}
|
|
1287
1366
|
}
|
|
1288
1367
|
|
|
1289
|
-
target = normalizeSymlinkTarget(target)
|
|
1368
|
+
target = normalizeSymlinkTarget(target, type, filepath)
|
|
1290
1369
|
|
|
1291
|
-
|
|
1370
|
+
const req = FileRequest.borrow()
|
|
1292
1371
|
|
|
1293
1372
|
let err = null
|
|
1294
1373
|
try {
|
|
@@ -1302,6 +1381,8 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1302
1381
|
path: target,
|
|
1303
1382
|
destination: filepath
|
|
1304
1383
|
})
|
|
1384
|
+
} finally {
|
|
1385
|
+
req.return()
|
|
1305
1386
|
}
|
|
1306
1387
|
|
|
1307
1388
|
return done(err, cb)
|
|
@@ -1339,9 +1420,9 @@ function symlinkSync(target, filepath, type) {
|
|
|
1339
1420
|
}
|
|
1340
1421
|
}
|
|
1341
1422
|
|
|
1342
|
-
target = normalizeSymlinkTarget(target)
|
|
1423
|
+
target = normalizeSymlinkTarget(target, type, filepath)
|
|
1343
1424
|
|
|
1344
|
-
|
|
1425
|
+
const req = FileRequest.borrow()
|
|
1345
1426
|
|
|
1346
1427
|
try {
|
|
1347
1428
|
binding.symlinkSync(req.handle, target, filepath, type)
|
|
@@ -1352,6 +1433,8 @@ function symlinkSync(target, filepath, type) {
|
|
|
1352
1433
|
path: target,
|
|
1353
1434
|
destination: filepath
|
|
1354
1435
|
})
|
|
1436
|
+
} finally {
|
|
1437
|
+
req.return()
|
|
1355
1438
|
}
|
|
1356
1439
|
}
|
|
1357
1440
|
|
|
@@ -1366,7 +1449,7 @@ async function opendir(filepath, opts, cb) {
|
|
|
1366
1449
|
|
|
1367
1450
|
filepath = toNamespacedPath(filepath)
|
|
1368
1451
|
|
|
1369
|
-
|
|
1452
|
+
const req = FileRequest.borrow()
|
|
1370
1453
|
|
|
1371
1454
|
let dir
|
|
1372
1455
|
let err = null
|
|
@@ -1382,6 +1465,8 @@ async function opendir(filepath, opts, cb) {
|
|
|
1382
1465
|
code: e.code,
|
|
1383
1466
|
path: filepath
|
|
1384
1467
|
})
|
|
1468
|
+
} finally {
|
|
1469
|
+
req.return()
|
|
1385
1470
|
}
|
|
1386
1471
|
|
|
1387
1472
|
return done(err, dir, cb)
|
|
@@ -1393,7 +1478,7 @@ function opendirSync(filepath, opts) {
|
|
|
1393
1478
|
|
|
1394
1479
|
filepath = toNamespacedPath(filepath)
|
|
1395
1480
|
|
|
1396
|
-
|
|
1481
|
+
const req = FileRequest.borrow()
|
|
1397
1482
|
|
|
1398
1483
|
try {
|
|
1399
1484
|
binding.opendirSync(req.handle, filepath)
|
|
@@ -1405,6 +1490,8 @@ function opendirSync(filepath, opts) {
|
|
|
1405
1490
|
code: e.code,
|
|
1406
1491
|
path: filepath
|
|
1407
1492
|
})
|
|
1493
|
+
} finally {
|
|
1494
|
+
req.return()
|
|
1408
1495
|
}
|
|
1409
1496
|
}
|
|
1410
1497
|
|
|
@@ -1695,7 +1782,7 @@ class Stats {
|
|
|
1695
1782
|
}
|
|
1696
1783
|
|
|
1697
1784
|
isCharacterDevice() {
|
|
1698
|
-
return (this.mode & constants.
|
|
1785
|
+
return (this.mode & constants.S_IFMT) === constants.S_IFCHR
|
|
1699
1786
|
}
|
|
1700
1787
|
|
|
1701
1788
|
isFIFO() {
|
|
@@ -1728,7 +1815,7 @@ class Dir {
|
|
|
1728
1815
|
if (this._buffer.length) return ok(this._buffer.shift(), cb)
|
|
1729
1816
|
if (this._ended) return ok(null, cb)
|
|
1730
1817
|
|
|
1731
|
-
|
|
1818
|
+
const req = FileRequest.borrow()
|
|
1732
1819
|
|
|
1733
1820
|
let entries
|
|
1734
1821
|
let err = null
|
|
@@ -1744,6 +1831,8 @@ class Dir {
|
|
|
1744
1831
|
code: e.code,
|
|
1745
1832
|
path: this.path
|
|
1746
1833
|
})
|
|
1834
|
+
} finally {
|
|
1835
|
+
req.return()
|
|
1747
1836
|
}
|
|
1748
1837
|
|
|
1749
1838
|
if (err) return fail(err, cb)
|
|
@@ -1769,7 +1858,7 @@ class Dir {
|
|
|
1769
1858
|
if (this._buffer.length) return this._buffer.shift()
|
|
1770
1859
|
if (this._ended) return null
|
|
1771
1860
|
|
|
1772
|
-
|
|
1861
|
+
const req = FileRequest.borrow()
|
|
1773
1862
|
|
|
1774
1863
|
let entries
|
|
1775
1864
|
try {
|
|
@@ -1782,6 +1871,8 @@ class Dir {
|
|
|
1782
1871
|
code: e.code,
|
|
1783
1872
|
path: this.path
|
|
1784
1873
|
})
|
|
1874
|
+
} finally {
|
|
1875
|
+
req.return()
|
|
1785
1876
|
}
|
|
1786
1877
|
|
|
1787
1878
|
if (entries.length === 0) {
|
|
@@ -1802,7 +1893,7 @@ class Dir {
|
|
|
1802
1893
|
}
|
|
1803
1894
|
|
|
1804
1895
|
async close(cb) {
|
|
1805
|
-
|
|
1896
|
+
const req = FileRequest.borrow()
|
|
1806
1897
|
|
|
1807
1898
|
let err = null
|
|
1808
1899
|
try {
|
|
@@ -1815,6 +1906,8 @@ class Dir {
|
|
|
1815
1906
|
code: e.code,
|
|
1816
1907
|
path: this.path
|
|
1817
1908
|
})
|
|
1909
|
+
} finally {
|
|
1910
|
+
req.return()
|
|
1818
1911
|
}
|
|
1819
1912
|
|
|
1820
1913
|
this._handle = null
|
|
@@ -1823,7 +1916,7 @@ class Dir {
|
|
|
1823
1916
|
}
|
|
1824
1917
|
|
|
1825
1918
|
closeSync() {
|
|
1826
|
-
|
|
1919
|
+
const req = FileRequest.borrow()
|
|
1827
1920
|
|
|
1828
1921
|
try {
|
|
1829
1922
|
binding.closedirSync(req.handle, this._handle)
|
|
@@ -1833,6 +1926,8 @@ class Dir {
|
|
|
1833
1926
|
code: e.code,
|
|
1834
1927
|
path: this.path
|
|
1835
1928
|
})
|
|
1929
|
+
} finally {
|
|
1930
|
+
req.return()
|
|
1836
1931
|
}
|
|
1837
1932
|
|
|
1838
1933
|
this._handle = null
|
|
@@ -1990,11 +2085,10 @@ class FileReadStream extends Readable {
|
|
|
1990
2085
|
async _destroy(err, cb) {
|
|
1991
2086
|
if (this.fd === -1) return cb(err)
|
|
1992
2087
|
|
|
1993
|
-
err = null
|
|
1994
2088
|
try {
|
|
1995
2089
|
await close(this.fd)
|
|
1996
2090
|
} catch (e) {
|
|
1997
|
-
err = e
|
|
2091
|
+
err = err || e
|
|
1998
2092
|
}
|
|
1999
2093
|
|
|
2000
2094
|
cb(err)
|
|
@@ -2043,11 +2137,10 @@ class FileWriteStream extends Writable {
|
|
|
2043
2137
|
async _destroy(err, cb) {
|
|
2044
2138
|
if (this.fd === -1) return cb(err)
|
|
2045
2139
|
|
|
2046
|
-
err = null
|
|
2047
2140
|
try {
|
|
2048
2141
|
await close(this.fd)
|
|
2049
2142
|
} catch (e) {
|
|
2050
|
-
err = e
|
|
2143
|
+
err = err || e
|
|
2051
2144
|
}
|
|
2052
2145
|
|
|
2053
2146
|
cb(err)
|
|
@@ -2273,7 +2366,7 @@ exports.createWriteStream = function createWriteStream(path, opts) {
|
|
|
2273
2366
|
|
|
2274
2367
|
function toNamespacedPath(filepath) {
|
|
2275
2368
|
if (typeof filepath !== 'string') {
|
|
2276
|
-
if (
|
|
2369
|
+
if (isURL(filepath)) filepath = fileURLToPath(filepath)
|
|
2277
2370
|
else filepath = filepath.toString()
|
|
2278
2371
|
}
|
|
2279
2372
|
|
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
|