bare-fs 4.6.0 → 4.7.1
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/README.md +961 -1
- package/binding.c +616 -0
- package/index.d.ts +106 -0
- package/index.js +452 -59
- package/package.json +2 -2
- 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/promises.d.ts +28 -0
- package/promises.js +27 -0
package/index.js
CHANGED
|
@@ -286,6 +286,8 @@ async function read(fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
286
286
|
try {
|
|
287
287
|
binding.read(req.handle, fd, buffer, offset, len, pos)
|
|
288
288
|
|
|
289
|
+
req.retain(buffer)
|
|
290
|
+
|
|
289
291
|
bytes = await req
|
|
290
292
|
} catch (e) {
|
|
291
293
|
err = new FileError(e.message, { operation: 'read', code: e.code, fd })
|
|
@@ -323,6 +325,8 @@ async function readv(fd, buffers, pos = -1, cb) {
|
|
|
323
325
|
try {
|
|
324
326
|
binding.readv(req.handle, fd, buffers, pos)
|
|
325
327
|
|
|
328
|
+
req.retain(buffers)
|
|
329
|
+
|
|
326
330
|
bytes = await req
|
|
327
331
|
} catch (e) {
|
|
328
332
|
err = new FileError(e.message, { operation: 'readv', code: e.code, fd })
|
|
@@ -395,6 +399,8 @@ async function write(fd, data, offset, len, pos = -1, cb) {
|
|
|
395
399
|
try {
|
|
396
400
|
binding.write(req.handle, fd, data, offset, len, pos)
|
|
397
401
|
|
|
402
|
+
req.retain(data)
|
|
403
|
+
|
|
398
404
|
bytes = await req
|
|
399
405
|
} catch (e) {
|
|
400
406
|
err = new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
@@ -450,6 +456,8 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
450
456
|
try {
|
|
451
457
|
binding.writev(req.handle, fd, buffers, pos)
|
|
452
458
|
|
|
459
|
+
req.retain(buffers)
|
|
460
|
+
|
|
453
461
|
bytes = await req
|
|
454
462
|
} catch (e) {
|
|
455
463
|
err = new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
@@ -488,11 +496,7 @@ async function stat(filepath, cb) {
|
|
|
488
496
|
|
|
489
497
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
490
498
|
} catch (e) {
|
|
491
|
-
err = new FileError(e.message, {
|
|
492
|
-
operation: 'stat',
|
|
493
|
-
code: e.code,
|
|
494
|
-
path: filepath
|
|
495
|
-
})
|
|
499
|
+
err = new FileError(e.message, { operation: 'stat', code: e.code, path: filepath })
|
|
496
500
|
} finally {
|
|
497
501
|
req.return()
|
|
498
502
|
}
|
|
@@ -510,11 +514,7 @@ function statSync(filepath) {
|
|
|
510
514
|
|
|
511
515
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
512
516
|
} catch (e) {
|
|
513
|
-
throw new FileError(e.message, {
|
|
514
|
-
operation: 'stat',
|
|
515
|
-
code: e.code,
|
|
516
|
-
path: filepath
|
|
517
|
-
})
|
|
517
|
+
throw new FileError(e.message, { operation: 'stat', code: e.code, path: filepath })
|
|
518
518
|
} finally {
|
|
519
519
|
req.return()
|
|
520
520
|
}
|
|
@@ -534,11 +534,7 @@ async function lstat(filepath, cb) {
|
|
|
534
534
|
|
|
535
535
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
536
536
|
} catch (e) {
|
|
537
|
-
err = new FileError(e.message, {
|
|
538
|
-
operation: 'lstat',
|
|
539
|
-
code: e.code,
|
|
540
|
-
path: filepath
|
|
541
|
-
})
|
|
537
|
+
err = new FileError(e.message, { operation: 'lstat', code: e.code, path: filepath })
|
|
542
538
|
} finally {
|
|
543
539
|
req.return()
|
|
544
540
|
}
|
|
@@ -556,11 +552,7 @@ function lstatSync(filepath) {
|
|
|
556
552
|
|
|
557
553
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
558
554
|
} catch (e) {
|
|
559
|
-
throw new FileError(e.message, {
|
|
560
|
-
operation: 'lstat',
|
|
561
|
-
code: e.code,
|
|
562
|
-
path: filepath
|
|
563
|
-
})
|
|
555
|
+
throw new FileError(e.message, { operation: 'lstat', code: e.code, path: filepath })
|
|
564
556
|
} finally {
|
|
565
557
|
req.return()
|
|
566
558
|
}
|
|
@@ -600,6 +592,44 @@ function fstatSync(fd) {
|
|
|
600
592
|
}
|
|
601
593
|
}
|
|
602
594
|
|
|
595
|
+
async function statfs(filepath, cb) {
|
|
596
|
+
filepath = toNamespacedPath(filepath)
|
|
597
|
+
|
|
598
|
+
const req = FileRequest.borrow()
|
|
599
|
+
|
|
600
|
+
let st
|
|
601
|
+
let err = null
|
|
602
|
+
try {
|
|
603
|
+
binding.statfs(req.handle, filepath)
|
|
604
|
+
|
|
605
|
+
await req
|
|
606
|
+
|
|
607
|
+
st = new StatFs(...binding.requestResultStatfs(req.handle))
|
|
608
|
+
} catch (e) {
|
|
609
|
+
err = new FileError(e.message, { operation: 'statfs', code: e.code, path: filepath })
|
|
610
|
+
} finally {
|
|
611
|
+
req.return()
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return done(err, st, cb)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function statfsSync(filepath) {
|
|
618
|
+
filepath = toNamespacedPath(filepath)
|
|
619
|
+
|
|
620
|
+
const req = FileRequest.borrow()
|
|
621
|
+
|
|
622
|
+
try {
|
|
623
|
+
binding.statfsSync(req.handle, filepath)
|
|
624
|
+
|
|
625
|
+
return new StatFs(...binding.requestResultStatfs(req.handle))
|
|
626
|
+
} catch (e) {
|
|
627
|
+
throw new FileError(e.message, { operation: 'statfs', code: e.code, path: filepath })
|
|
628
|
+
} finally {
|
|
629
|
+
req.return()
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
603
633
|
async function ftruncate(fd, len = 0, cb) {
|
|
604
634
|
if (typeof len === 'function') {
|
|
605
635
|
cb = len
|
|
@@ -638,6 +668,38 @@ function ftruncateSync(fd, len = 0) {
|
|
|
638
668
|
}
|
|
639
669
|
}
|
|
640
670
|
|
|
671
|
+
async function truncate(filepath, len, cb) {
|
|
672
|
+
let fd = -1
|
|
673
|
+
let err
|
|
674
|
+
|
|
675
|
+
try {
|
|
676
|
+
fd = await open(filepath, 'r+')
|
|
677
|
+
|
|
678
|
+
await ftruncate(fd, len)
|
|
679
|
+
} catch (e) {
|
|
680
|
+
err = e
|
|
681
|
+
} finally {
|
|
682
|
+
if (fd !== -1) await close(fd)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return done(err, cb)
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function truncateSync(filepath, len) {
|
|
689
|
+
let fd = -1
|
|
690
|
+
let err
|
|
691
|
+
|
|
692
|
+
try {
|
|
693
|
+
fd = openSync(filepath, 'r+')
|
|
694
|
+
|
|
695
|
+
ftruncateSync(fd, len)
|
|
696
|
+
} catch (e) {
|
|
697
|
+
err = e
|
|
698
|
+
} finally {
|
|
699
|
+
if (fd !== -1) closeSync(fd)
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
641
703
|
async function chmod(filepath, mode, cb) {
|
|
642
704
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
643
705
|
|
|
@@ -716,6 +778,101 @@ function fchmodSync(fd, mode) {
|
|
|
716
778
|
}
|
|
717
779
|
}
|
|
718
780
|
|
|
781
|
+
async function chown(filepath, uid, gid, cb) {
|
|
782
|
+
filepath = toNamespacedPath(filepath)
|
|
783
|
+
|
|
784
|
+
const req = FileRequest.borrow()
|
|
785
|
+
|
|
786
|
+
let err = null
|
|
787
|
+
try {
|
|
788
|
+
binding.chown(req.handle, filepath, uid, gid)
|
|
789
|
+
|
|
790
|
+
await req
|
|
791
|
+
} catch (e) {
|
|
792
|
+
err = new FileError(e.message, { operation: 'chown', code: e.code, path: filepath })
|
|
793
|
+
} finally {
|
|
794
|
+
req.return()
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
return done(err, cb)
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function chownSync(filepath, uid, gid) {
|
|
801
|
+
filepath = toNamespacedPath(filepath)
|
|
802
|
+
|
|
803
|
+
const req = FileRequest.borrow()
|
|
804
|
+
|
|
805
|
+
try {
|
|
806
|
+
binding.chownSync(req.handle, filepath, uid, gid)
|
|
807
|
+
} catch (e) {
|
|
808
|
+
throw new FileError(e.message, { operation: 'chownSync', code: e.code, path: filepath })
|
|
809
|
+
} finally {
|
|
810
|
+
req.return()
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
async function lchown(filepath, uid, gid, cb) {
|
|
815
|
+
filepath = toNamespacedPath(filepath)
|
|
816
|
+
|
|
817
|
+
const req = FileRequest.borrow()
|
|
818
|
+
|
|
819
|
+
let err = null
|
|
820
|
+
try {
|
|
821
|
+
binding.lchown(req.handle, filepath, uid, gid)
|
|
822
|
+
|
|
823
|
+
await req
|
|
824
|
+
} catch (e) {
|
|
825
|
+
err = new FileError(e.message, { operation: 'lchown', code: e.code, path: filepath })
|
|
826
|
+
} finally {
|
|
827
|
+
req.return()
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
return done(err, cb)
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
function lchownSync(filepath, uid, gid) {
|
|
834
|
+
filepath = toNamespacedPath(filepath)
|
|
835
|
+
|
|
836
|
+
const req = FileRequest.borrow()
|
|
837
|
+
|
|
838
|
+
try {
|
|
839
|
+
binding.lchownSync(req.handle, filepath, uid, gid)
|
|
840
|
+
} catch (e) {
|
|
841
|
+
throw new FileError(e.message, { operation: 'lchownSync', code: e.code, path: filepath })
|
|
842
|
+
} finally {
|
|
843
|
+
req.return()
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
async function fchown(fd, uid, gid, cb) {
|
|
848
|
+
const req = FileRequest.borrow()
|
|
849
|
+
|
|
850
|
+
let err = null
|
|
851
|
+
try {
|
|
852
|
+
binding.fchown(req.handle, fd, uid, gid)
|
|
853
|
+
|
|
854
|
+
await req
|
|
855
|
+
} catch (e) {
|
|
856
|
+
err = new FileError(e.message, { operation: 'fchown', code: e.code, fd })
|
|
857
|
+
} finally {
|
|
858
|
+
req.return()
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
return done(err, cb)
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function fchownSync(fd, uid, gid) {
|
|
865
|
+
const req = FileRequest.borrow()
|
|
866
|
+
|
|
867
|
+
try {
|
|
868
|
+
binding.fchownSync(req.handle, fd, uid, gid)
|
|
869
|
+
} catch (e) {
|
|
870
|
+
throw new FileError(e.message, { operation: 'fchownSync', code: e.code, fd })
|
|
871
|
+
} finally {
|
|
872
|
+
req.return()
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
719
876
|
async function utimes(filepath, atime, mtime, cb) {
|
|
720
877
|
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
721
878
|
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
@@ -730,11 +887,7 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
730
887
|
|
|
731
888
|
await req
|
|
732
889
|
} catch (e) {
|
|
733
|
-
err = new FileError(e.message, {
|
|
734
|
-
operation: 'utimes',
|
|
735
|
-
code: e.code,
|
|
736
|
-
path: filepath
|
|
737
|
-
})
|
|
890
|
+
err = new FileError(e.message, { operation: 'utimes', code: e.code, path: filepath })
|
|
738
891
|
} finally {
|
|
739
892
|
req.return()
|
|
740
893
|
}
|
|
@@ -752,11 +905,121 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
752
905
|
|
|
753
906
|
try {
|
|
754
907
|
binding.utimesSync(req.handle, filepath, atime, mtime)
|
|
908
|
+
} catch (e) {
|
|
909
|
+
throw new FileError(e.message, { operation: 'utimes', code: e.code, path: filepath })
|
|
910
|
+
} finally {
|
|
911
|
+
req.return()
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
async function lutimes(filepath, atime, mtime, cb) {
|
|
916
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
917
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
918
|
+
|
|
919
|
+
filepath = toNamespacedPath(filepath)
|
|
920
|
+
|
|
921
|
+
const req = FileRequest.borrow()
|
|
922
|
+
|
|
923
|
+
let err = null
|
|
924
|
+
try {
|
|
925
|
+
binding.lutimes(req.handle, filepath, atime, mtime)
|
|
926
|
+
|
|
927
|
+
await req
|
|
928
|
+
} catch (e) {
|
|
929
|
+
err = new FileError(e.message, { operation: 'lutimes', code: e.code, path: filepath })
|
|
930
|
+
} finally {
|
|
931
|
+
req.return()
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
return done(err, cb)
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function lutimesSync(filepath, atime, mtime) {
|
|
938
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
939
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
940
|
+
|
|
941
|
+
filepath = toNamespacedPath(filepath)
|
|
942
|
+
|
|
943
|
+
const req = FileRequest.borrow()
|
|
944
|
+
|
|
945
|
+
try {
|
|
946
|
+
binding.lutimesSync(req.handle, filepath, atime, mtime)
|
|
947
|
+
} catch (e) {
|
|
948
|
+
throw new FileError(e.message, { operation: 'lutimes', code: e.code, path: filepath })
|
|
949
|
+
} finally {
|
|
950
|
+
req.return()
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
async function futimes(fd, atime, mtime, cb) {
|
|
955
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
956
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
957
|
+
|
|
958
|
+
const req = FileRequest.borrow()
|
|
959
|
+
|
|
960
|
+
let err = null
|
|
961
|
+
try {
|
|
962
|
+
binding.futimes(req.handle, fd, atime, mtime)
|
|
963
|
+
|
|
964
|
+
await req
|
|
965
|
+
} catch (e) {
|
|
966
|
+
err = new FileError(e.message, { operation: 'futimes', code: e.code, fd })
|
|
967
|
+
} finally {
|
|
968
|
+
req.return()
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return done(err, cb)
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function futimesSync(fd, atime, mtime) {
|
|
975
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
976
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
977
|
+
|
|
978
|
+
const req = FileRequest.borrow()
|
|
979
|
+
|
|
980
|
+
try {
|
|
981
|
+
binding.futimesSync(req.handle, fd, atime, mtime)
|
|
982
|
+
} catch (e) {
|
|
983
|
+
throw new FileError(e.message, { operation: 'futimesSync', code: e.code, fd })
|
|
984
|
+
} finally {
|
|
985
|
+
req.return()
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
async function link(src, dst, cb) {
|
|
990
|
+
src = toNamespacedPath(src)
|
|
991
|
+
dst = toNamespacedPath(dst)
|
|
992
|
+
|
|
993
|
+
const req = FileRequest.borrow()
|
|
994
|
+
|
|
995
|
+
let err = null
|
|
996
|
+
try {
|
|
997
|
+
binding.link(req.handle, src, dst)
|
|
998
|
+
|
|
999
|
+
await req
|
|
1000
|
+
} catch (e) {
|
|
1001
|
+
err = new FileError(e.message, { operation: 'link', code: e.code, path: src, destination: dst })
|
|
1002
|
+
} finally {
|
|
1003
|
+
req.return()
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return done(err, cb)
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
function linkSync(src, dst) {
|
|
1010
|
+
src = toNamespacedPath(src)
|
|
1011
|
+
dst = toNamespacedPath(dst)
|
|
1012
|
+
|
|
1013
|
+
const req = FileRequest.borrow()
|
|
1014
|
+
|
|
1015
|
+
try {
|
|
1016
|
+
binding.linkSync(req.handle, src, dst)
|
|
755
1017
|
} catch (e) {
|
|
756
1018
|
throw new FileError(e.message, {
|
|
757
|
-
operation: '
|
|
1019
|
+
operation: 'linkSync',
|
|
758
1020
|
code: e.code,
|
|
759
|
-
path:
|
|
1021
|
+
path: src,
|
|
1022
|
+
destination: dst
|
|
760
1023
|
})
|
|
761
1024
|
} finally {
|
|
762
1025
|
req.return()
|
|
@@ -872,6 +1135,44 @@ function mkdirSync(filepath, opts) {
|
|
|
872
1135
|
}
|
|
873
1136
|
}
|
|
874
1137
|
|
|
1138
|
+
async function mkdtemp(prefix, cb) {
|
|
1139
|
+
prefix = toNamespacedPath(prefix)
|
|
1140
|
+
|
|
1141
|
+
const req = FileRequest.borrow()
|
|
1142
|
+
|
|
1143
|
+
let res
|
|
1144
|
+
let err = null
|
|
1145
|
+
try {
|
|
1146
|
+
binding.mkdtemp(req.handle, prefix + 'XXXXXX')
|
|
1147
|
+
|
|
1148
|
+
await req
|
|
1149
|
+
|
|
1150
|
+
res = binding.requestResultPath(req.handle)
|
|
1151
|
+
} catch (e) {
|
|
1152
|
+
err = new FileError(e.message, { operation: 'mkdtemp', code: e.code, path: prefix })
|
|
1153
|
+
} finally {
|
|
1154
|
+
req.return()
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
return done(err, res, cb)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function mkdtempSync(prefix) {
|
|
1161
|
+
prefix = toNamespacedPath(prefix)
|
|
1162
|
+
|
|
1163
|
+
const req = FileRequest.borrow()
|
|
1164
|
+
|
|
1165
|
+
try {
|
|
1166
|
+
binding.mkdtempSync(req.handle, prefix + 'XXXXXX')
|
|
1167
|
+
|
|
1168
|
+
return binding.requestResultPath(req.handle)
|
|
1169
|
+
} catch (e) {
|
|
1170
|
+
throw new FileError(e.message, { operation: 'mkdtempSync', code: e.code, path: prefix })
|
|
1171
|
+
} finally {
|
|
1172
|
+
req.return()
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
875
1176
|
async function rmdir(filepath, cb) {
|
|
876
1177
|
filepath = toNamespacedPath(filepath)
|
|
877
1178
|
|
|
@@ -1339,6 +1640,64 @@ function readlinkSync(filepath, opts) {
|
|
|
1339
1640
|
}
|
|
1340
1641
|
}
|
|
1341
1642
|
|
|
1643
|
+
async function fsync(fd, cb) {
|
|
1644
|
+
const req = FileRequest.borrow()
|
|
1645
|
+
|
|
1646
|
+
let err = null
|
|
1647
|
+
try {
|
|
1648
|
+
binding.fsync(req.handle, fd)
|
|
1649
|
+
|
|
1650
|
+
await req
|
|
1651
|
+
} catch (e) {
|
|
1652
|
+
err = new FileError(e.message, { operation: 'fsync', code: e.code, fd })
|
|
1653
|
+
} finally {
|
|
1654
|
+
req.return()
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
return done(err, cb)
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
function fsyncSync(fd) {
|
|
1661
|
+
const req = FileRequest.borrow()
|
|
1662
|
+
|
|
1663
|
+
try {
|
|
1664
|
+
binding.fsyncSync(req.handle, fd)
|
|
1665
|
+
} catch (e) {
|
|
1666
|
+
throw new FileError(e.message, { operation: 'fsyncSync', code: e.code, fd })
|
|
1667
|
+
} finally {
|
|
1668
|
+
req.return()
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
async function fdatasync(fd, cb) {
|
|
1673
|
+
const req = FileRequest.borrow()
|
|
1674
|
+
|
|
1675
|
+
let err = null
|
|
1676
|
+
try {
|
|
1677
|
+
binding.fdatasync(req.handle, fd)
|
|
1678
|
+
|
|
1679
|
+
await req
|
|
1680
|
+
} catch (e) {
|
|
1681
|
+
err = new FileError(e.message, { operation: 'fdatasync', code: e.code, fd })
|
|
1682
|
+
} finally {
|
|
1683
|
+
req.return()
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
return done(err, cb)
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
function fdatasyncSync(fd) {
|
|
1690
|
+
const req = FileRequest.borrow()
|
|
1691
|
+
|
|
1692
|
+
try {
|
|
1693
|
+
binding.fdatasyncSync(req.handle, fd)
|
|
1694
|
+
} catch (e) {
|
|
1695
|
+
throw new FileError(e.message, { operation: 'fdatasyncSync', code: e.code, fd })
|
|
1696
|
+
} finally {
|
|
1697
|
+
req.return()
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1342
1701
|
function normalizeSymlinkTarget(target, type, filepath) {
|
|
1343
1702
|
if (isWindows) {
|
|
1344
1703
|
if (type === constants.UV_FS_SYMLINK_JUNCTION) target = path.resolve(filepath, '..', target)
|
|
@@ -1527,17 +1886,28 @@ async function readdir(filepath, opts, cb) {
|
|
|
1527
1886
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1528
1887
|
else if (!opts) opts = {}
|
|
1529
1888
|
|
|
1530
|
-
const { withFileTypes = false } = opts
|
|
1889
|
+
const { withFileTypes = false, recursive = false } = opts
|
|
1531
1890
|
|
|
1532
1891
|
filepath = toNamespacedPath(filepath)
|
|
1533
1892
|
|
|
1893
|
+
const queue = [filepath]
|
|
1534
1894
|
let result = []
|
|
1535
1895
|
let err = null
|
|
1536
1896
|
try {
|
|
1537
|
-
|
|
1897
|
+
while (queue.length !== 0) {
|
|
1898
|
+
const dir = await opendir(queue.pop())
|
|
1899
|
+
|
|
1900
|
+
for await (const entry of dir) {
|
|
1901
|
+
const entryPath = path.join(entry.parentPath, entry.name)
|
|
1538
1902
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1903
|
+
if (withFileTypes) {
|
|
1904
|
+
result.push(entry)
|
|
1905
|
+
} else {
|
|
1906
|
+
result.push(path.relative(filepath, entryPath))
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
if (recursive && entry.isDirectory()) queue.push(entryPath)
|
|
1910
|
+
}
|
|
1541
1911
|
}
|
|
1542
1912
|
} catch (e) {
|
|
1543
1913
|
result = []
|
|
@@ -1551,15 +1921,27 @@ function readdirSync(filepath, opts) {
|
|
|
1551
1921
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1552
1922
|
else if (!opts) opts = {}
|
|
1553
1923
|
|
|
1554
|
-
const { withFileTypes = false } = opts
|
|
1924
|
+
const { withFileTypes = false, recursive = false } = opts
|
|
1555
1925
|
|
|
1556
1926
|
filepath = toNamespacedPath(filepath)
|
|
1557
1927
|
|
|
1558
|
-
const
|
|
1928
|
+
const queue = [filepath]
|
|
1559
1929
|
const result = []
|
|
1560
1930
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1931
|
+
while (queue.length !== 0) {
|
|
1932
|
+
const dir = opendirSync(queue.pop(), opts)
|
|
1933
|
+
|
|
1934
|
+
for (const entry of dir) {
|
|
1935
|
+
const entryPath = path.join(entry.parentPath, entry.name)
|
|
1936
|
+
|
|
1937
|
+
if (withFileTypes) {
|
|
1938
|
+
result.push(entry)
|
|
1939
|
+
} else {
|
|
1940
|
+
result.push(path.relative(filepath, entryPath))
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
if (recursive && entry.isDirectory()) queue.push(entryPath)
|
|
1944
|
+
}
|
|
1563
1945
|
}
|
|
1564
1946
|
|
|
1565
1947
|
return result
|
|
@@ -1821,6 +2203,18 @@ class Stats {
|
|
|
1821
2203
|
}
|
|
1822
2204
|
}
|
|
1823
2205
|
|
|
2206
|
+
class StatFs {
|
|
2207
|
+
constructor(type, bsize, blocks, bfree, bavail, files, ffree) {
|
|
2208
|
+
this.type = type
|
|
2209
|
+
this.bsize = bsize
|
|
2210
|
+
this.blocks = blocks
|
|
2211
|
+
this.bfree = bfree
|
|
2212
|
+
this.bavail = bavail
|
|
2213
|
+
this.files = files
|
|
2214
|
+
this.ffree = ffree
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
|
|
1824
2218
|
class Dir {
|
|
1825
2219
|
constructor(path, handle, opts = {}) {
|
|
1826
2220
|
const { encoding = 'utf8', bufferSize = 32 } = opts
|
|
@@ -2285,25 +2679,24 @@ class Watcher extends EventEmitter {
|
|
|
2285
2679
|
exports.access = access
|
|
2286
2680
|
exports.appendFile = appendFile
|
|
2287
2681
|
exports.chmod = chmod
|
|
2288
|
-
|
|
2682
|
+
exports.chown = chown
|
|
2289
2683
|
exports.close = close
|
|
2290
2684
|
exports.copyFile = copyFile
|
|
2291
2685
|
exports.cp = cp
|
|
2292
2686
|
exports.exists = exists
|
|
2293
2687
|
exports.fchmod = fchmod
|
|
2294
|
-
|
|
2295
|
-
|
|
2688
|
+
exports.fchown = fchown
|
|
2689
|
+
exports.fdatasync = fdatasync
|
|
2296
2690
|
exports.fstat = fstat
|
|
2297
|
-
|
|
2691
|
+
exports.fsync = fsync
|
|
2298
2692
|
exports.ftruncate = ftruncate
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
// exports.link = link TODO
|
|
2693
|
+
exports.futimes = futimes
|
|
2694
|
+
exports.lchown = lchown
|
|
2695
|
+
exports.lutimes = lutimes
|
|
2696
|
+
exports.link = link
|
|
2304
2697
|
exports.lstat = lstat
|
|
2305
2698
|
exports.mkdir = mkdir
|
|
2306
|
-
|
|
2699
|
+
exports.mkdtemp = mkdtemp
|
|
2307
2700
|
exports.open = open
|
|
2308
2701
|
exports.opendir = opendir
|
|
2309
2702
|
exports.read = read
|
|
@@ -2316,9 +2709,9 @@ exports.rename = rename
|
|
|
2316
2709
|
exports.rm = rm
|
|
2317
2710
|
exports.rmdir = rmdir
|
|
2318
2711
|
exports.stat = stat
|
|
2319
|
-
|
|
2712
|
+
exports.statfs = statfs
|
|
2320
2713
|
exports.symlink = symlink
|
|
2321
|
-
|
|
2714
|
+
exports.truncate = truncate
|
|
2322
2715
|
exports.unlink = unlink
|
|
2323
2716
|
exports.utimes = utimes
|
|
2324
2717
|
exports.watch = watch
|
|
@@ -2329,25 +2722,24 @@ exports.writev = writev
|
|
|
2329
2722
|
exports.accessSync = accessSync
|
|
2330
2723
|
exports.appendFileSync = appendFileSync
|
|
2331
2724
|
exports.chmodSync = chmodSync
|
|
2332
|
-
|
|
2725
|
+
exports.chownSync = chownSync
|
|
2333
2726
|
exports.closeSync = closeSync
|
|
2334
2727
|
exports.copyFileSync = copyFileSync
|
|
2335
2728
|
exports.cpSync = cpSync
|
|
2336
2729
|
exports.existsSync = existsSync
|
|
2337
2730
|
exports.fchmodSync = fchmodSync
|
|
2338
|
-
|
|
2339
|
-
|
|
2731
|
+
exports.fchownSync = fchownSync
|
|
2732
|
+
exports.fdatasyncSync = fdatasyncSync
|
|
2340
2733
|
exports.fstatSync = fstatSync
|
|
2341
|
-
|
|
2734
|
+
exports.fsyncSync = fsyncSync
|
|
2342
2735
|
exports.ftruncateSync = ftruncateSync
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
// exports.linkSync = linkSync TODO
|
|
2736
|
+
exports.futimesSync = futimesSync
|
|
2737
|
+
exports.lchownSync = lchownSync
|
|
2738
|
+
exports.lutimesSync = lutimesSync
|
|
2739
|
+
exports.linkSync = linkSync
|
|
2348
2740
|
exports.lstatSync = lstatSync
|
|
2349
2741
|
exports.mkdirSync = mkdirSync
|
|
2350
|
-
|
|
2742
|
+
exports.mkdtempSync = mkdtempSync
|
|
2351
2743
|
exports.openSync = openSync
|
|
2352
2744
|
exports.opendirSync = opendirSync
|
|
2353
2745
|
exports.readFileSync = readFileSync
|
|
@@ -2360,9 +2752,9 @@ exports.renameSync = renameSync
|
|
|
2360
2752
|
exports.rmSync = rmSync
|
|
2361
2753
|
exports.rmdirSync = rmdirSync
|
|
2362
2754
|
exports.statSync = statSync
|
|
2363
|
-
|
|
2755
|
+
exports.statfsSync = statfsSync
|
|
2364
2756
|
exports.symlinkSync = symlinkSync
|
|
2365
|
-
|
|
2757
|
+
exports.truncateSync = truncateSync
|
|
2366
2758
|
exports.unlinkSync = unlinkSync
|
|
2367
2759
|
exports.utimesSync = utimesSync
|
|
2368
2760
|
exports.writeFileSync = writeFileSync
|
|
@@ -2372,6 +2764,7 @@ exports.writevSync = writevSync
|
|
|
2372
2764
|
exports.promises = require('./promises')
|
|
2373
2765
|
|
|
2374
2766
|
exports.Stats = Stats
|
|
2767
|
+
exports.StatFs = StatFs
|
|
2375
2768
|
exports.Dir = Dir
|
|
2376
2769
|
exports.Dirent = Dirent
|
|
2377
2770
|
exports.Watcher = Watcher
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|