bare-fs 4.5.6 → 4.7.0
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 +960 -1
- package/binding.c +616 -0
- package/index.d.ts +108 -0
- package/index.js +455 -69
- package/package.json +6 -3
- 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 +30 -1
package/index.js
CHANGED
|
@@ -488,11 +488,7 @@ async function stat(filepath, cb) {
|
|
|
488
488
|
|
|
489
489
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
490
490
|
} catch (e) {
|
|
491
|
-
err = new FileError(e.message, {
|
|
492
|
-
operation: 'stat',
|
|
493
|
-
code: e.code,
|
|
494
|
-
path: filepath
|
|
495
|
-
})
|
|
491
|
+
err = new FileError(e.message, { operation: 'stat', code: e.code, path: filepath })
|
|
496
492
|
} finally {
|
|
497
493
|
req.return()
|
|
498
494
|
}
|
|
@@ -510,11 +506,7 @@ function statSync(filepath) {
|
|
|
510
506
|
|
|
511
507
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
512
508
|
} catch (e) {
|
|
513
|
-
throw new FileError(e.message, {
|
|
514
|
-
operation: 'stat',
|
|
515
|
-
code: e.code,
|
|
516
|
-
path: filepath
|
|
517
|
-
})
|
|
509
|
+
throw new FileError(e.message, { operation: 'stat', code: e.code, path: filepath })
|
|
518
510
|
} finally {
|
|
519
511
|
req.return()
|
|
520
512
|
}
|
|
@@ -534,11 +526,7 @@ async function lstat(filepath, cb) {
|
|
|
534
526
|
|
|
535
527
|
st = new Stats(...binding.requestResultStat(req.handle))
|
|
536
528
|
} catch (e) {
|
|
537
|
-
err = new FileError(e.message, {
|
|
538
|
-
operation: 'lstat',
|
|
539
|
-
code: e.code,
|
|
540
|
-
path: filepath
|
|
541
|
-
})
|
|
529
|
+
err = new FileError(e.message, { operation: 'lstat', code: e.code, path: filepath })
|
|
542
530
|
} finally {
|
|
543
531
|
req.return()
|
|
544
532
|
}
|
|
@@ -556,11 +544,7 @@ function lstatSync(filepath) {
|
|
|
556
544
|
|
|
557
545
|
return new Stats(...binding.requestResultStat(req.handle))
|
|
558
546
|
} catch (e) {
|
|
559
|
-
throw new FileError(e.message, {
|
|
560
|
-
operation: 'lstat',
|
|
561
|
-
code: e.code,
|
|
562
|
-
path: filepath
|
|
563
|
-
})
|
|
547
|
+
throw new FileError(e.message, { operation: 'lstat', code: e.code, path: filepath })
|
|
564
548
|
} finally {
|
|
565
549
|
req.return()
|
|
566
550
|
}
|
|
@@ -600,6 +584,44 @@ function fstatSync(fd) {
|
|
|
600
584
|
}
|
|
601
585
|
}
|
|
602
586
|
|
|
587
|
+
async function statfs(filepath, cb) {
|
|
588
|
+
filepath = toNamespacedPath(filepath)
|
|
589
|
+
|
|
590
|
+
const req = FileRequest.borrow()
|
|
591
|
+
|
|
592
|
+
let st
|
|
593
|
+
let err = null
|
|
594
|
+
try {
|
|
595
|
+
binding.statfs(req.handle, filepath)
|
|
596
|
+
|
|
597
|
+
await req
|
|
598
|
+
|
|
599
|
+
st = new StatFs(...binding.requestResultStatfs(req.handle))
|
|
600
|
+
} catch (e) {
|
|
601
|
+
err = new FileError(e.message, { operation: 'statfs', code: e.code, path: filepath })
|
|
602
|
+
} finally {
|
|
603
|
+
req.return()
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return done(err, st, cb)
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function statfsSync(filepath) {
|
|
610
|
+
filepath = toNamespacedPath(filepath)
|
|
611
|
+
|
|
612
|
+
const req = FileRequest.borrow()
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
binding.statfsSync(req.handle, filepath)
|
|
616
|
+
|
|
617
|
+
return new StatFs(...binding.requestResultStatfs(req.handle))
|
|
618
|
+
} catch (e) {
|
|
619
|
+
throw new FileError(e.message, { operation: 'statfs', code: e.code, path: filepath })
|
|
620
|
+
} finally {
|
|
621
|
+
req.return()
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
603
625
|
async function ftruncate(fd, len = 0, cb) {
|
|
604
626
|
if (typeof len === 'function') {
|
|
605
627
|
cb = len
|
|
@@ -638,6 +660,38 @@ function ftruncateSync(fd, len = 0) {
|
|
|
638
660
|
}
|
|
639
661
|
}
|
|
640
662
|
|
|
663
|
+
async function truncate(filepath, len, cb) {
|
|
664
|
+
let fd = -1
|
|
665
|
+
let err
|
|
666
|
+
|
|
667
|
+
try {
|
|
668
|
+
fd = await open(filepath, 'r+')
|
|
669
|
+
|
|
670
|
+
await ftruncate(fd, len)
|
|
671
|
+
} catch (e) {
|
|
672
|
+
err = e
|
|
673
|
+
} finally {
|
|
674
|
+
if (fd !== -1) await close(fd)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return done(err, cb)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function truncateSync(filepath, len) {
|
|
681
|
+
let fd = -1
|
|
682
|
+
let err
|
|
683
|
+
|
|
684
|
+
try {
|
|
685
|
+
fd = openSync(filepath, 'r+')
|
|
686
|
+
|
|
687
|
+
ftruncateSync(fd, len)
|
|
688
|
+
} catch (e) {
|
|
689
|
+
err = e
|
|
690
|
+
} finally {
|
|
691
|
+
if (fd !== -1) closeSync(fd)
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
641
695
|
async function chmod(filepath, mode, cb) {
|
|
642
696
|
if (typeof mode === 'string') mode = toMode(mode)
|
|
643
697
|
|
|
@@ -716,6 +770,101 @@ function fchmodSync(fd, mode) {
|
|
|
716
770
|
}
|
|
717
771
|
}
|
|
718
772
|
|
|
773
|
+
async function chown(filepath, uid, gid, cb) {
|
|
774
|
+
filepath = toNamespacedPath(filepath)
|
|
775
|
+
|
|
776
|
+
const req = FileRequest.borrow()
|
|
777
|
+
|
|
778
|
+
let err = null
|
|
779
|
+
try {
|
|
780
|
+
binding.chown(req.handle, filepath, uid, gid)
|
|
781
|
+
|
|
782
|
+
await req
|
|
783
|
+
} catch (e) {
|
|
784
|
+
err = new FileError(e.message, { operation: 'chown', code: e.code, path: filepath })
|
|
785
|
+
} finally {
|
|
786
|
+
req.return()
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
return done(err, cb)
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
function chownSync(filepath, uid, gid) {
|
|
793
|
+
filepath = toNamespacedPath(filepath)
|
|
794
|
+
|
|
795
|
+
const req = FileRequest.borrow()
|
|
796
|
+
|
|
797
|
+
try {
|
|
798
|
+
binding.chownSync(req.handle, filepath, uid, gid)
|
|
799
|
+
} catch (e) {
|
|
800
|
+
throw new FileError(e.message, { operation: 'chownSync', code: e.code, path: filepath })
|
|
801
|
+
} finally {
|
|
802
|
+
req.return()
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
async function lchown(filepath, uid, gid, cb) {
|
|
807
|
+
filepath = toNamespacedPath(filepath)
|
|
808
|
+
|
|
809
|
+
const req = FileRequest.borrow()
|
|
810
|
+
|
|
811
|
+
let err = null
|
|
812
|
+
try {
|
|
813
|
+
binding.lchown(req.handle, filepath, uid, gid)
|
|
814
|
+
|
|
815
|
+
await req
|
|
816
|
+
} catch (e) {
|
|
817
|
+
err = new FileError(e.message, { operation: 'lchown', code: e.code, path: filepath })
|
|
818
|
+
} finally {
|
|
819
|
+
req.return()
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
return done(err, cb)
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function lchownSync(filepath, uid, gid) {
|
|
826
|
+
filepath = toNamespacedPath(filepath)
|
|
827
|
+
|
|
828
|
+
const req = FileRequest.borrow()
|
|
829
|
+
|
|
830
|
+
try {
|
|
831
|
+
binding.lchownSync(req.handle, filepath, uid, gid)
|
|
832
|
+
} catch (e) {
|
|
833
|
+
throw new FileError(e.message, { operation: 'lchownSync', code: e.code, path: filepath })
|
|
834
|
+
} finally {
|
|
835
|
+
req.return()
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
async function fchown(fd, uid, gid, cb) {
|
|
840
|
+
const req = FileRequest.borrow()
|
|
841
|
+
|
|
842
|
+
let err = null
|
|
843
|
+
try {
|
|
844
|
+
binding.fchown(req.handle, fd, uid, gid)
|
|
845
|
+
|
|
846
|
+
await req
|
|
847
|
+
} catch (e) {
|
|
848
|
+
err = new FileError(e.message, { operation: 'fchown', code: e.code, fd })
|
|
849
|
+
} finally {
|
|
850
|
+
req.return()
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return done(err, cb)
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function fchownSync(fd, uid, gid) {
|
|
857
|
+
const req = FileRequest.borrow()
|
|
858
|
+
|
|
859
|
+
try {
|
|
860
|
+
binding.fchownSync(req.handle, fd, uid, gid)
|
|
861
|
+
} catch (e) {
|
|
862
|
+
throw new FileError(e.message, { operation: 'fchownSync', code: e.code, fd })
|
|
863
|
+
} finally {
|
|
864
|
+
req.return()
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
719
868
|
async function utimes(filepath, atime, mtime, cb) {
|
|
720
869
|
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
721
870
|
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
@@ -730,11 +879,7 @@ async function utimes(filepath, atime, mtime, cb) {
|
|
|
730
879
|
|
|
731
880
|
await req
|
|
732
881
|
} catch (e) {
|
|
733
|
-
err = new FileError(e.message, {
|
|
734
|
-
operation: 'utimes',
|
|
735
|
-
code: e.code,
|
|
736
|
-
path: filepath
|
|
737
|
-
})
|
|
882
|
+
err = new FileError(e.message, { operation: 'utimes', code: e.code, path: filepath })
|
|
738
883
|
} finally {
|
|
739
884
|
req.return()
|
|
740
885
|
}
|
|
@@ -752,11 +897,121 @@ function utimesSync(filepath, atime, mtime) {
|
|
|
752
897
|
|
|
753
898
|
try {
|
|
754
899
|
binding.utimesSync(req.handle, filepath, atime, mtime)
|
|
900
|
+
} catch (e) {
|
|
901
|
+
throw new FileError(e.message, { operation: 'utimes', code: e.code, path: filepath })
|
|
902
|
+
} finally {
|
|
903
|
+
req.return()
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
async function lutimes(filepath, atime, mtime, cb) {
|
|
908
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
909
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
910
|
+
|
|
911
|
+
filepath = toNamespacedPath(filepath)
|
|
912
|
+
|
|
913
|
+
const req = FileRequest.borrow()
|
|
914
|
+
|
|
915
|
+
let err = null
|
|
916
|
+
try {
|
|
917
|
+
binding.lutimes(req.handle, filepath, atime, mtime)
|
|
918
|
+
|
|
919
|
+
await req
|
|
920
|
+
} catch (e) {
|
|
921
|
+
err = new FileError(e.message, { operation: 'lutimes', code: e.code, path: filepath })
|
|
922
|
+
} finally {
|
|
923
|
+
req.return()
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
return done(err, cb)
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function lutimesSync(filepath, atime, mtime) {
|
|
930
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
931
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
932
|
+
|
|
933
|
+
filepath = toNamespacedPath(filepath)
|
|
934
|
+
|
|
935
|
+
const req = FileRequest.borrow()
|
|
936
|
+
|
|
937
|
+
try {
|
|
938
|
+
binding.lutimesSync(req.handle, filepath, atime, mtime)
|
|
939
|
+
} catch (e) {
|
|
940
|
+
throw new FileError(e.message, { operation: 'lutimes', code: e.code, path: filepath })
|
|
941
|
+
} finally {
|
|
942
|
+
req.return()
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
async function futimes(fd, atime, mtime, cb) {
|
|
947
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
948
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
949
|
+
|
|
950
|
+
const req = FileRequest.borrow()
|
|
951
|
+
|
|
952
|
+
let err = null
|
|
953
|
+
try {
|
|
954
|
+
binding.futimes(req.handle, fd, atime, mtime)
|
|
955
|
+
|
|
956
|
+
await req
|
|
957
|
+
} catch (e) {
|
|
958
|
+
err = new FileError(e.message, { operation: 'futimes', code: e.code, fd })
|
|
959
|
+
} finally {
|
|
960
|
+
req.return()
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
return done(err, cb)
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
function futimesSync(fd, atime, mtime) {
|
|
967
|
+
if (typeof atime !== 'number') atime = atime.getTime() / 1000
|
|
968
|
+
if (typeof mtime !== 'number') mtime = mtime.getTime() / 1000
|
|
969
|
+
|
|
970
|
+
const req = FileRequest.borrow()
|
|
971
|
+
|
|
972
|
+
try {
|
|
973
|
+
binding.futimesSync(req.handle, fd, atime, mtime)
|
|
974
|
+
} catch (e) {
|
|
975
|
+
throw new FileError(e.message, { operation: 'futimesSync', code: e.code, fd })
|
|
976
|
+
} finally {
|
|
977
|
+
req.return()
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
async function link(src, dst, cb) {
|
|
982
|
+
src = toNamespacedPath(src)
|
|
983
|
+
dst = toNamespacedPath(dst)
|
|
984
|
+
|
|
985
|
+
const req = FileRequest.borrow()
|
|
986
|
+
|
|
987
|
+
let err = null
|
|
988
|
+
try {
|
|
989
|
+
binding.link(req.handle, src, dst)
|
|
990
|
+
|
|
991
|
+
await req
|
|
992
|
+
} catch (e) {
|
|
993
|
+
err = new FileError(e.message, { operation: 'link', code: e.code, path: src, destination: dst })
|
|
994
|
+
} finally {
|
|
995
|
+
req.return()
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return done(err, cb)
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function linkSync(src, dst) {
|
|
1002
|
+
src = toNamespacedPath(src)
|
|
1003
|
+
dst = toNamespacedPath(dst)
|
|
1004
|
+
|
|
1005
|
+
const req = FileRequest.borrow()
|
|
1006
|
+
|
|
1007
|
+
try {
|
|
1008
|
+
binding.linkSync(req.handle, src, dst)
|
|
755
1009
|
} catch (e) {
|
|
756
1010
|
throw new FileError(e.message, {
|
|
757
|
-
operation: '
|
|
1011
|
+
operation: 'linkSync',
|
|
758
1012
|
code: e.code,
|
|
759
|
-
path:
|
|
1013
|
+
path: src,
|
|
1014
|
+
destination: dst
|
|
760
1015
|
})
|
|
761
1016
|
} finally {
|
|
762
1017
|
req.return()
|
|
@@ -872,6 +1127,44 @@ function mkdirSync(filepath, opts) {
|
|
|
872
1127
|
}
|
|
873
1128
|
}
|
|
874
1129
|
|
|
1130
|
+
async function mkdtemp(prefix, cb) {
|
|
1131
|
+
prefix = toNamespacedPath(prefix)
|
|
1132
|
+
|
|
1133
|
+
const req = FileRequest.borrow()
|
|
1134
|
+
|
|
1135
|
+
let res
|
|
1136
|
+
let err = null
|
|
1137
|
+
try {
|
|
1138
|
+
binding.mkdtemp(req.handle, prefix + 'XXXXXX')
|
|
1139
|
+
|
|
1140
|
+
await req
|
|
1141
|
+
|
|
1142
|
+
res = binding.requestResultPath(req.handle)
|
|
1143
|
+
} catch (e) {
|
|
1144
|
+
err = new FileError(e.message, { operation: 'mkdtemp', code: e.code, path: prefix })
|
|
1145
|
+
} finally {
|
|
1146
|
+
req.return()
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
return done(err, res, cb)
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
function mkdtempSync(prefix) {
|
|
1153
|
+
prefix = toNamespacedPath(prefix)
|
|
1154
|
+
|
|
1155
|
+
const req = FileRequest.borrow()
|
|
1156
|
+
|
|
1157
|
+
try {
|
|
1158
|
+
binding.mkdtempSync(req.handle, prefix + 'XXXXXX')
|
|
1159
|
+
|
|
1160
|
+
return binding.requestResultPath(req.handle)
|
|
1161
|
+
} catch (e) {
|
|
1162
|
+
throw new FileError(e.message, { operation: 'mkdtempSync', code: e.code, path: prefix })
|
|
1163
|
+
} finally {
|
|
1164
|
+
req.return()
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
875
1168
|
async function rmdir(filepath, cb) {
|
|
876
1169
|
filepath = toNamespacedPath(filepath)
|
|
877
1170
|
|
|
@@ -1150,21 +1443,15 @@ async function cp(src, dst, opts, cb) {
|
|
|
1150
1443
|
|
|
1151
1444
|
if (st.isDirectory()) {
|
|
1152
1445
|
if (opts.recursive !== true) {
|
|
1153
|
-
throw new FileError('is a directory', {
|
|
1154
|
-
operation: 'cp',
|
|
1155
|
-
code: 'EISDIR',
|
|
1156
|
-
path: src
|
|
1157
|
-
})
|
|
1446
|
+
throw new FileError('is a directory', { operation: 'cp', code: 'EISDIR', path: src })
|
|
1158
1447
|
}
|
|
1159
1448
|
|
|
1160
1449
|
try {
|
|
1161
1450
|
await lstat(dst)
|
|
1162
1451
|
} catch (e) {
|
|
1163
|
-
if (e.code
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
throw e
|
|
1167
|
-
}
|
|
1452
|
+
if (e.code !== 'ENOENT') throw e
|
|
1453
|
+
|
|
1454
|
+
await mkdir(dst, { mode: st.mode, recursive: true })
|
|
1168
1455
|
}
|
|
1169
1456
|
|
|
1170
1457
|
const dir = await opendir(src)
|
|
@@ -1182,6 +1469,35 @@ async function cp(src, dst, opts, cb) {
|
|
|
1182
1469
|
return done(err, cb)
|
|
1183
1470
|
}
|
|
1184
1471
|
|
|
1472
|
+
function cpSync(src, dst, opts = {}) {
|
|
1473
|
+
src = toNamespacedPath(src)
|
|
1474
|
+
dst = toNamespacedPath(dst)
|
|
1475
|
+
|
|
1476
|
+
const st = lstatSync(src)
|
|
1477
|
+
|
|
1478
|
+
if (st.isDirectory()) {
|
|
1479
|
+
if (opts.recursive !== true) {
|
|
1480
|
+
throw new FileError('is a directory', { operation: 'cp', code: 'EISDIR', path: src })
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
try {
|
|
1484
|
+
lstatSync(dst)
|
|
1485
|
+
} catch (e) {
|
|
1486
|
+
if (e.code !== 'ENOENT') throw e
|
|
1487
|
+
|
|
1488
|
+
mkdirSync(dst, { mode: st.mode, recursive: true })
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
const dir = opendirSync(src)
|
|
1492
|
+
for (const { name } of dir) {
|
|
1493
|
+
cpSync(path.join(src, name), path.join(dst, name), opts)
|
|
1494
|
+
}
|
|
1495
|
+
} else if (st.isFile()) {
|
|
1496
|
+
copyFileSync(src, dst)
|
|
1497
|
+
chmodSync(dst, st.mode)
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1185
1501
|
async function realpath(filepath, opts, cb) {
|
|
1186
1502
|
if (typeof opts === 'function') {
|
|
1187
1503
|
cb = opts
|
|
@@ -1316,6 +1632,64 @@ function readlinkSync(filepath, opts) {
|
|
|
1316
1632
|
}
|
|
1317
1633
|
}
|
|
1318
1634
|
|
|
1635
|
+
async function fsync(fd, cb) {
|
|
1636
|
+
const req = FileRequest.borrow()
|
|
1637
|
+
|
|
1638
|
+
let err = null
|
|
1639
|
+
try {
|
|
1640
|
+
binding.fsync(req.handle, fd)
|
|
1641
|
+
|
|
1642
|
+
await req
|
|
1643
|
+
} catch (e) {
|
|
1644
|
+
err = new FileError(e.message, { operation: 'fsync', code: e.code, fd })
|
|
1645
|
+
} finally {
|
|
1646
|
+
req.return()
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
return done(err, cb)
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
function fsyncSync(fd) {
|
|
1653
|
+
const req = FileRequest.borrow()
|
|
1654
|
+
|
|
1655
|
+
try {
|
|
1656
|
+
binding.fsyncSync(req.handle, fd)
|
|
1657
|
+
} catch (e) {
|
|
1658
|
+
throw new FileError(e.message, { operation: 'fsyncSync', code: e.code, fd })
|
|
1659
|
+
} finally {
|
|
1660
|
+
req.return()
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
async function fdatasync(fd, cb) {
|
|
1665
|
+
const req = FileRequest.borrow()
|
|
1666
|
+
|
|
1667
|
+
let err = null
|
|
1668
|
+
try {
|
|
1669
|
+
binding.fdatasync(req.handle, fd)
|
|
1670
|
+
|
|
1671
|
+
await req
|
|
1672
|
+
} catch (e) {
|
|
1673
|
+
err = new FileError(e.message, { operation: 'fdatasync', code: e.code, fd })
|
|
1674
|
+
} finally {
|
|
1675
|
+
req.return()
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
return done(err, cb)
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
function fdatasyncSync(fd) {
|
|
1682
|
+
const req = FileRequest.borrow()
|
|
1683
|
+
|
|
1684
|
+
try {
|
|
1685
|
+
binding.fdatasyncSync(req.handle, fd)
|
|
1686
|
+
} catch (e) {
|
|
1687
|
+
throw new FileError(e.message, { operation: 'fdatasyncSync', code: e.code, fd })
|
|
1688
|
+
} finally {
|
|
1689
|
+
req.return()
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1319
1693
|
function normalizeSymlinkTarget(target, type, filepath) {
|
|
1320
1694
|
if (isWindows) {
|
|
1321
1695
|
if (type === constants.UV_FS_SYMLINK_JUNCTION) target = path.resolve(filepath, '..', target)
|
|
@@ -1338,16 +1712,16 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1338
1712
|
|
|
1339
1713
|
if (typeof type === 'string') {
|
|
1340
1714
|
switch (type) {
|
|
1341
|
-
case 'file':
|
|
1342
|
-
default:
|
|
1343
|
-
type = 0
|
|
1344
|
-
break
|
|
1345
1715
|
case 'dir':
|
|
1346
1716
|
type = constants.UV_FS_SYMLINK_DIR
|
|
1347
1717
|
break
|
|
1348
1718
|
case 'junction':
|
|
1349
1719
|
type = constants.UV_FS_SYMLINK_JUNCTION
|
|
1350
1720
|
break
|
|
1721
|
+
case 'file':
|
|
1722
|
+
default:
|
|
1723
|
+
type = 0
|
|
1724
|
+
break
|
|
1351
1725
|
}
|
|
1352
1726
|
} else if (typeof type !== 'number') {
|
|
1353
1727
|
if (isWindows) {
|
|
@@ -1393,16 +1767,16 @@ function symlinkSync(target, filepath, type) {
|
|
|
1393
1767
|
|
|
1394
1768
|
if (typeof type === 'string') {
|
|
1395
1769
|
switch (type) {
|
|
1396
|
-
case 'file':
|
|
1397
|
-
default:
|
|
1398
|
-
type = 0
|
|
1399
|
-
break
|
|
1400
1770
|
case 'dir':
|
|
1401
1771
|
type = constants.UV_FS_SYMLINK_DIR
|
|
1402
1772
|
break
|
|
1403
1773
|
case 'junction':
|
|
1404
1774
|
type = constants.UV_FS_SYMLINK_JUNCTION
|
|
1405
1775
|
break
|
|
1776
|
+
case 'file':
|
|
1777
|
+
default:
|
|
1778
|
+
type = 0
|
|
1779
|
+
break
|
|
1406
1780
|
}
|
|
1407
1781
|
} else if (typeof type !== 'number') {
|
|
1408
1782
|
if (isWindows) {
|
|
@@ -1798,6 +2172,18 @@ class Stats {
|
|
|
1798
2172
|
}
|
|
1799
2173
|
}
|
|
1800
2174
|
|
|
2175
|
+
class StatFs {
|
|
2176
|
+
constructor(type, bsize, blocks, bfree, bavail, files, ffree) {
|
|
2177
|
+
this.type = type
|
|
2178
|
+
this.bsize = bsize
|
|
2179
|
+
this.blocks = blocks
|
|
2180
|
+
this.bfree = bfree
|
|
2181
|
+
this.bavail = bavail
|
|
2182
|
+
this.files = files
|
|
2183
|
+
this.ffree = ffree
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
|
|
1801
2187
|
class Dir {
|
|
1802
2188
|
constructor(path, handle, opts = {}) {
|
|
1803
2189
|
const { encoding = 'utf8', bufferSize = 32 } = opts
|
|
@@ -2262,25 +2648,24 @@ class Watcher extends EventEmitter {
|
|
|
2262
2648
|
exports.access = access
|
|
2263
2649
|
exports.appendFile = appendFile
|
|
2264
2650
|
exports.chmod = chmod
|
|
2265
|
-
|
|
2651
|
+
exports.chown = chown
|
|
2266
2652
|
exports.close = close
|
|
2267
2653
|
exports.copyFile = copyFile
|
|
2268
2654
|
exports.cp = cp
|
|
2269
2655
|
exports.exists = exists
|
|
2270
2656
|
exports.fchmod = fchmod
|
|
2271
|
-
|
|
2272
|
-
|
|
2657
|
+
exports.fchown = fchown
|
|
2658
|
+
exports.fdatasync = fdatasync
|
|
2273
2659
|
exports.fstat = fstat
|
|
2274
|
-
|
|
2660
|
+
exports.fsync = fsync
|
|
2275
2661
|
exports.ftruncate = ftruncate
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
// exports.link = link TODO
|
|
2662
|
+
exports.futimes = futimes
|
|
2663
|
+
exports.lchown = lchown
|
|
2664
|
+
exports.lutimes = lutimes
|
|
2665
|
+
exports.link = link
|
|
2281
2666
|
exports.lstat = lstat
|
|
2282
2667
|
exports.mkdir = mkdir
|
|
2283
|
-
|
|
2668
|
+
exports.mkdtemp = mkdtemp
|
|
2284
2669
|
exports.open = open
|
|
2285
2670
|
exports.opendir = opendir
|
|
2286
2671
|
exports.read = read
|
|
@@ -2293,9 +2678,9 @@ exports.rename = rename
|
|
|
2293
2678
|
exports.rm = rm
|
|
2294
2679
|
exports.rmdir = rmdir
|
|
2295
2680
|
exports.stat = stat
|
|
2296
|
-
|
|
2681
|
+
exports.statfs = statfs
|
|
2297
2682
|
exports.symlink = symlink
|
|
2298
|
-
|
|
2683
|
+
exports.truncate = truncate
|
|
2299
2684
|
exports.unlink = unlink
|
|
2300
2685
|
exports.utimes = utimes
|
|
2301
2686
|
exports.watch = watch
|
|
@@ -2306,24 +2691,24 @@ exports.writev = writev
|
|
|
2306
2691
|
exports.accessSync = accessSync
|
|
2307
2692
|
exports.appendFileSync = appendFileSync
|
|
2308
2693
|
exports.chmodSync = chmodSync
|
|
2309
|
-
|
|
2694
|
+
exports.chownSync = chownSync
|
|
2310
2695
|
exports.closeSync = closeSync
|
|
2311
2696
|
exports.copyFileSync = copyFileSync
|
|
2697
|
+
exports.cpSync = cpSync
|
|
2312
2698
|
exports.existsSync = existsSync
|
|
2313
2699
|
exports.fchmodSync = fchmodSync
|
|
2314
|
-
|
|
2315
|
-
|
|
2700
|
+
exports.fchownSync = fchownSync
|
|
2701
|
+
exports.fdatasyncSync = fdatasyncSync
|
|
2316
2702
|
exports.fstatSync = fstatSync
|
|
2317
|
-
|
|
2703
|
+
exports.fsyncSync = fsyncSync
|
|
2318
2704
|
exports.ftruncateSync = ftruncateSync
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
// exports.linkSync = linkSync TODO
|
|
2705
|
+
exports.futimesSync = futimesSync
|
|
2706
|
+
exports.lchownSync = lchownSync
|
|
2707
|
+
exports.lutimesSync = lutimesSync
|
|
2708
|
+
exports.linkSync = linkSync
|
|
2324
2709
|
exports.lstatSync = lstatSync
|
|
2325
2710
|
exports.mkdirSync = mkdirSync
|
|
2326
|
-
|
|
2711
|
+
exports.mkdtempSync = mkdtempSync
|
|
2327
2712
|
exports.openSync = openSync
|
|
2328
2713
|
exports.opendirSync = opendirSync
|
|
2329
2714
|
exports.readFileSync = readFileSync
|
|
@@ -2336,9 +2721,9 @@ exports.renameSync = renameSync
|
|
|
2336
2721
|
exports.rmSync = rmSync
|
|
2337
2722
|
exports.rmdirSync = rmdirSync
|
|
2338
2723
|
exports.statSync = statSync
|
|
2339
|
-
|
|
2724
|
+
exports.statfsSync = statfsSync
|
|
2340
2725
|
exports.symlinkSync = symlinkSync
|
|
2341
|
-
|
|
2726
|
+
exports.truncateSync = truncateSync
|
|
2342
2727
|
exports.unlinkSync = unlinkSync
|
|
2343
2728
|
exports.utimesSync = utimesSync
|
|
2344
2729
|
exports.writeFileSync = writeFileSync
|
|
@@ -2348,6 +2733,7 @@ exports.writevSync = writevSync
|
|
|
2348
2733
|
exports.promises = require('./promises')
|
|
2349
2734
|
|
|
2350
2735
|
exports.Stats = Stats
|
|
2736
|
+
exports.StatFs = StatFs
|
|
2351
2737
|
exports.Dir = Dir
|
|
2352
2738
|
exports.Dirent = Dirent
|
|
2353
2739
|
exports.Watcher = Watcher
|