@@ -439,3 +439,262 @@ declare function InternalBinding(binding: 'config'): {
439439 bits : number ,
440440 hasDtrace : boolean
441441}
442+
443+ declare namespace InternalFSBinding {
444+ class FSReqCallback < ResultType = unknown > {
445+ constructor ( bigint ?: boolean ) ;
446+ oncomplete : ( ( error : Error ) => void ) | ( ( error : null , result : ResultType ) => void ) ;
447+ context : any ;
448+ }
449+
450+ interface FSSyncContext {
451+ fd ?: number ;
452+ path ?: string ;
453+ dest ?: string ;
454+ errno ?: string ;
455+ message ?: string ;
456+ syscall ?: string ;
457+ error ?: Error ;
458+ }
459+
460+ type Buffer = Uint8Array ;
461+ type StringOrBuffer = string | Buffer ;
462+
463+ const kUsePromises : symbol ;
464+
465+ class FileHandle {
466+ constructor ( fd : number , offset : number , length : number ) ;
467+ fd : number ;
468+ getAsyncId ( ) : number ;
469+ close ( ) : Promise < void > ;
470+ onread : ( ) => void ;
471+ stream : unknown ;
472+ }
473+
474+ class StatWatcher {
475+ constructor ( useBigint : boolean ) ;
476+ initialized : boolean ;
477+ start ( path : string , interval : number ) : number ;
478+ getAsyncId ( ) : number ;
479+ close ( ) : void ;
480+ ref ( ) : void ;
481+ unref ( ) : void ;
482+ onchange : ( status : number , eventType : string , filename : string | Buffer ) => void ;
483+ }
484+
485+ function access ( path : StringOrBuffer , mode : number , req : FSReqCallback ) : void ;
486+ function access ( path : StringOrBuffer , mode : number , req : undefined , ctx : FSSyncContext ) : void ;
487+ function access ( path : StringOrBuffer , mode : number , usePromises : typeof kUsePromises ) : Promise < void > ;
488+
489+ function chmod ( path : string , mode : number , req : FSReqCallback ) : void ;
490+ function chmod ( path : string , mode : number , req : undefined , ctx : FSSyncContext ) : void ;
491+ function chmod ( path : string , mode : number , usePromises : typeof kUsePromises ) : Promise < void > ;
492+
493+ function chown ( path : string , uid : number , gid : number , req : FSReqCallback ) : void ;
494+ function chown ( path : string , uid : number , gid : number , req : undefined , ctx : FSSyncContext ) : void ;
495+ function chown ( path : string , uid : number , gid : number , usePromises : typeof kUsePromises ) : Promise < void > ;
496+
497+ function close ( fd : number , req : FSReqCallback ) : void ;
498+ function close ( fd : number , req : undefined , ctx : FSSyncContext ) : void ;
499+
500+ function copyFile ( src : StringOrBuffer , dest : StringOrBuffer , mode : number , req : FSReqCallback ) : void ;
501+ function copyFile ( src : StringOrBuffer , dest : StringOrBuffer , mode : number , req : undefined , ctx : FSSyncContext ) : void ;
502+ function copyFile ( src : StringOrBuffer , dest : StringOrBuffer , mode : number , usePromises : typeof kUsePromises ) : Promise < void > ;
503+
504+ function fchmod ( fd : number , mode : number , req : FSReqCallback ) : void ;
505+ function fchmod ( fd : number , mode : number , req : undefined , ctx : FSSyncContext ) : void ;
506+ function fchmod ( fd : number , mode : number , usePromises : typeof kUsePromises ) : Promise < void > ;
507+
508+ function fchown ( fd : number , uid : number , gid : number , req : FSReqCallback ) : void ;
509+ function fchown ( fd : number , uid : number , gid : number , req : undefined , ctx : FSSyncContext ) : void ;
510+ function fchown ( fd : number , uid : number , gid : number , usePromises : typeof kUsePromises ) : Promise < void > ;
511+
512+ function fdatasync ( fd : number , req : FSReqCallback ) : void ;
513+ function fdatasync ( fd : number , req : undefined , ctx : FSSyncContext ) : void ;
514+ function fdatasync ( fd : number , usePromises : typeof kUsePromises ) : Promise < void > ;
515+
516+ function fstat ( fd : number , useBigint : boolean , req : FSReqCallback < Float64Array | BigUint64Array > ) : void ;
517+ function fstat ( fd : number , useBigint : true , req : FSReqCallback < BigUint64Array > ) : void ;
518+ function fstat ( fd : number , useBigint : false , req : FSReqCallback < Float64Array > ) : void ;
519+ function fstat ( fd : number , useBigint : boolean , req : undefined , ctx : FSSyncContext ) : Float64Array | BigUint64Array ;
520+ function fstat ( fd : number , useBigint : true , req : undefined , ctx : FSSyncContext ) : BigUint64Array ;
521+ function fstat ( fd : number , useBigint : false , req : undefined , ctx : FSSyncContext ) : Float64Array ;
522+ function fstat ( fd : number , useBigint : boolean , usePromises : typeof kUsePromises ) : Promise < Float64Array | BigUint64Array > ;
523+ function fstat ( fd : number , useBigint : true , usePromises : typeof kUsePromises ) : Promise < BigUint64Array > ;
524+ function fstat ( fd : number , useBigint : false , usePromises : typeof kUsePromises ) : Promise < Float64Array > ;
525+
526+ function fsync ( fd : number , req : FSReqCallback ) : void ;
527+ function fsync ( fd : number , req : undefined , ctx : FSSyncContext ) : void ;
528+ function fsync ( fd : number , usePromises : typeof kUsePromises ) : Promise < void > ;
529+
530+ function ftruncate ( fd : number , len : number , req : FSReqCallback ) : void ;
531+ function ftruncate ( fd : number , len : number , req : undefined , ctx : FSSyncContext ) : void ;
532+ function ftruncate ( fd : number , len : number , usePromises : typeof kUsePromises ) : Promise < void > ;
533+
534+ function futimes ( fd : number , atime : number , mtime : number , req : FSReqCallback ) : void ;
535+ function futimes ( fd : number , atime : number , mtime : number , req : undefined , ctx : FSSyncContext ) : void ;
536+ function futimes ( fd : number , atime : number , mtime : number , usePromises : typeof kUsePromises ) : Promise < void > ;
537+
538+ function internalModuleReadJSON ( path : string ) : [ ] | [ string , boolean ] ;
539+ function internalModuleStat ( path : string ) : number ;
540+
541+ function lchown ( path : string , uid : number , gid : number , req : FSReqCallback ) : void ;
542+ function lchown ( path : string , uid : number , gid : number , req : undefined , ctx : FSSyncContext ) : void ;
543+ function lchown ( path : string , uid : number , gid : number , usePromises : typeof kUsePromises ) : Promise < void > ;
544+
545+ function link ( existingPath : string , newPath : string , req : FSReqCallback ) : void ;
546+ function link ( existingPath : string , newPath : string , req : undefined , ctx : FSSyncContext ) : void ;
547+ function link ( existingPath : string , newPath : string , usePromises : typeof kUsePromises ) : Promise < void > ;
548+
549+ function lstat ( path : StringOrBuffer , useBigint : boolean , req : FSReqCallback < Float64Array | BigUint64Array > ) : void ;
550+ function lstat ( path : StringOrBuffer , useBigint : true , req : FSReqCallback < BigUint64Array > ) : void ;
551+ function lstat ( path : StringOrBuffer , useBigint : false , req : FSReqCallback < Float64Array > ) : void ;
552+ function lstat ( path : StringOrBuffer , useBigint : boolean , req : undefined , ctx : FSSyncContext ) : Float64Array | BigUint64Array ;
553+ function lstat ( path : StringOrBuffer , useBigint : true , req : undefined , ctx : FSSyncContext ) : BigUint64Array ;
554+ function lstat ( path : StringOrBuffer , useBigint : false , req : undefined , ctx : FSSyncContext ) : Float64Array ;
555+ function lstat ( path : StringOrBuffer , useBigint : boolean , usePromises : typeof kUsePromises ) : Promise < Float64Array | BigUint64Array > ;
556+ function lstat ( path : StringOrBuffer , useBigint : true , usePromises : typeof kUsePromises ) : Promise < BigUint64Array > ;
557+ function lstat ( path : StringOrBuffer , useBigint : false , usePromises : typeof kUsePromises ) : Promise < Float64Array > ;
558+
559+ function lutimes ( path : string , atime : number , mtime : number , req : FSReqCallback ) : void ;
560+ function lutimes ( path : string , atime : number , mtime : number , req : undefined , ctx : FSSyncContext ) : void ;
561+ function lutimes ( path : string , atime : number , mtime : number , usePromises : typeof kUsePromises ) : Promise < void > ;
562+
563+ function mkdtemp ( prefix : string , encoding : unknown , req : FSReqCallback < string > ) : void ;
564+ function mkdtemp ( prefix : string , encoding : unknown , req : undefined , ctx : FSSyncContext ) : string ;
565+ function mkdtemp ( prefix : string , encoding : unknown , usePromises : typeof kUsePromises ) : Promise < string > ;
566+
567+ function mkdir ( path : string , mode : number , recursive : boolean , req : FSReqCallback < void | string > ) : void ;
568+ function mkdir ( path : string , mode : number , recursive : true , req : FSReqCallback < string > ) : void ;
569+ function mkdir ( path : string , mode : number , recursive : false , req : FSReqCallback < void > ) : void ;
570+ function mkdir ( path : string , mode : number , recursive : boolean , req : undefined , ctx : FSSyncContext ) : void | string ;
571+ function mkdir ( path : string , mode : number , recursive : true , req : undefined , ctx : FSSyncContext ) : string ;
572+ function mkdir ( path : string , mode : number , recursive : false , req : undefined , ctx : FSSyncContext ) : void ;
573+ function mkdir ( path : string , mode : number , recursive : boolean , usePromises : typeof kUsePromises ) : Promise < void | string > ;
574+ function mkdir ( path : string , mode : number , recursive : true , usePromises : typeof kUsePromises ) : Promise < string > ;
575+ function mkdir ( path : string , mode : number , recursive : false , usePromises : typeof kUsePromises ) : Promise < void > ;
576+
577+ function open ( path : StringOrBuffer , flags : number , mode : number , req : FSReqCallback < number > ) : void ;
578+ function open ( path : StringOrBuffer , flags : number , mode : number , req : undefined , ctx : FSSyncContext ) : number ;
579+
580+ function openFileHandle ( path : StringOrBuffer , flags : number , mode : number , usePromises : typeof kUsePromises ) : Promise < FileHandle > ;
581+
582+ function read ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number , req : FSReqCallback < number > ) : void ;
583+ function read ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number , req : undefined , ctx : FSSyncContext ) : number ;
584+ function read ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number , usePromises : typeof kUsePromises ) : Promise < number > ;
585+
586+ function readBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , req : FSReqCallback < number > ) : void ;
587+ function readBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , req : undefined , ctx : FSSyncContext ) : number ;
588+ function readBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , usePromises : typeof kUsePromises ) : Promise < number > ;
589+
590+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : boolean , req : FSReqCallback < string [ ] | [ string [ ] , number [ ] ] > ) : void ;
591+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : true , req : FSReqCallback < [ string [ ] , number [ ] ] > ) : void ;
592+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : false , req : FSReqCallback < string [ ] > ) : void ;
593+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : boolean , req : undefined , ctx : FSSyncContext ) : string [ ] | [ string [ ] , number [ ] ] ;
594+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : true , req : undefined , ctx : FSSyncContext ) : [ string [ ] , number [ ] ] ;
595+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : false , req : undefined , ctx : FSSyncContext ) : string [ ] ;
596+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : boolean , usePromises : typeof kUsePromises ) : Promise < string [ ] | [ string [ ] , number [ ] ] > ;
597+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : true , usePromises : typeof kUsePromises ) : Promise < [ string [ ] , number [ ] ] > ;
598+ function readdir ( path : StringOrBuffer , encoding : unknown , withFileTypes : false , usePromises : typeof kUsePromises ) : Promise < string [ ] > ;
599+
600+ function readlink ( path : StringOrBuffer , encoding : unknown , req : FSReqCallback < string | Buffer > ) : void ;
601+ function readlink ( path : StringOrBuffer , encoding : unknown , req : undefined , ctx : FSSyncContext ) : string | Buffer ;
602+ function readlink ( path : StringOrBuffer , encoding : unknown , usePromises : typeof kUsePromises ) : Promise < string | Buffer > ;
603+
604+ function realpath ( path : StringOrBuffer , encoding : unknown , req : FSReqCallback < string | Buffer > ) : void ;
605+ function realpath ( path : StringOrBuffer , encoding : unknown , req : undefined , ctx : FSSyncContext ) : string | Buffer ;
606+ function realpath ( path : StringOrBuffer , encoding : unknown , usePromises : typeof kUsePromises ) : Promise < string | Buffer > ;
607+
608+ function rename ( oldPath : string , newPath : string , req : FSReqCallback ) : void ;
609+ function rename ( oldPath : string , newPath : string , req : undefined , ctx : FSSyncContext ) : void ;
610+ function rename ( oldPath : string , newPath : string , usePromises : typeof kUsePromises ) : Promise < void > ;
611+
612+ function rmdir ( path : string , req : FSReqCallback ) : void ;
613+ function rmdir ( path : string , req : undefined , ctx : FSSyncContext ) : void ;
614+ function rmdir ( path : string , usePromises : typeof kUsePromises ) : Promise < void > ;
615+
616+ function stat ( path : StringOrBuffer , useBigint : boolean , req : FSReqCallback < Float64Array | BigUint64Array > ) : void ;
617+ function stat ( path : StringOrBuffer , useBigint : true , req : FSReqCallback < BigUint64Array > ) : void ;
618+ function stat ( path : StringOrBuffer , useBigint : false , req : FSReqCallback < Float64Array > ) : void ;
619+ function stat ( path : StringOrBuffer , useBigint : boolean , req : undefined , ctx : FSSyncContext ) : Float64Array | BigUint64Array ;
620+ function stat ( path : StringOrBuffer , useBigint : true , req : undefined , ctx : FSSyncContext ) : BigUint64Array ;
621+ function stat ( path : StringOrBuffer , useBigint : false , req : undefined , ctx : FSSyncContext ) : Float64Array ;
622+ function stat ( path : StringOrBuffer , useBigint : boolean , usePromises : typeof kUsePromises ) : Promise < Float64Array | BigUint64Array > ;
623+ function stat ( path : StringOrBuffer , useBigint : true , usePromises : typeof kUsePromises ) : Promise < BigUint64Array > ;
624+ function stat ( path : StringOrBuffer , useBigint : false , usePromises : typeof kUsePromises ) : Promise < Float64Array > ;
625+
626+ function symlink ( target : StringOrBuffer , path : StringOrBuffer , type : number , req : FSReqCallback ) : void ;
627+ function symlink ( target : StringOrBuffer , path : StringOrBuffer , type : number , req : undefined , ctx : FSSyncContext ) : void ;
628+ function symlink ( target : StringOrBuffer , path : StringOrBuffer , type : number , usePromises : typeof kUsePromises ) : Promise < void > ;
629+
630+ function unlink ( path : string , req : FSReqCallback ) : void ;
631+ function unlink ( path : string , req : undefined , ctx : FSSyncContext ) : void ;
632+ function unlink ( path : string , usePromises : typeof kUsePromises ) : Promise < void > ;
633+
634+ function utimes ( path : string , atime : number , mtime : number , req : FSReqCallback ) : void ;
635+ function utimes ( path : string , atime : number , mtime : number , req : undefined , ctx : FSSyncContext ) : void ;
636+ function utimes ( path : string , atime : number , mtime : number , usePromises : typeof kUsePromises ) : Promise < void > ;
637+
638+ function writeBuffer ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number | null , req : FSReqCallback < number > ) : void ;
639+ function writeBuffer ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number | null , req : undefined , ctx : FSSyncContext ) : number ;
640+ function writeBuffer ( fd : number , buffer : ArrayBufferView , offset : number , length : number , position : number | null , usePromises : typeof kUsePromises ) : Promise < number > ;
641+
642+ function writeBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , req : FSReqCallback < number > ) : void ;
643+ function writeBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , req : undefined , ctx : FSSyncContext ) : number ;
644+ function writeBuffers ( fd : number , buffers : ArrayBufferView [ ] , position : number , usePromises : typeof kUsePromises ) : Promise < number > ;
645+
646+ function writeString ( fd : number , value : string , pos : unknown , encoding : unknown , req : FSReqCallback < number > ) : void ;
647+ function writeString ( fd : number , value : string , pos : unknown , encoding : unknown , req : undefined , ctx : FSSyncContext ) : number ;
648+ function writeString ( fd : number , value : string , pos : unknown , encoding : unknown , usePromises : typeof kUsePromises ) : Promise < number > ;
649+ }
650+
651+ declare function InternalBinding ( binding : 'fs' ) : {
652+ FSReqCallback : typeof InternalFSBinding . FSReqCallback ;
653+
654+ FileHandle : typeof InternalFSBinding . FileHandle ;
655+
656+ kUsePromises : typeof InternalFSBinding . kUsePromises ;
657+
658+ statValues : Float64Array ;
659+ bigintStatValues : BigUint64Array ;
660+
661+ kFsStatsFieldsNumber : number ;
662+ StatWatcher : typeof InternalFSBinding . StatWatcher ;
663+
664+ access : typeof InternalFSBinding . access ;
665+ chmod : typeof InternalFSBinding . chmod ;
666+ chown : typeof InternalFSBinding . chown ;
667+ close : typeof InternalFSBinding . close ;
668+ copyFile : typeof InternalFSBinding . copyFile ;
669+ fchmod : typeof InternalFSBinding . fchmod ;
670+ fchown : typeof InternalFSBinding . fchown ;
671+ fdatasync : typeof InternalFSBinding . fdatasync ;
672+ fstat : typeof InternalFSBinding . fstat ;
673+ fsync : typeof InternalFSBinding . fsync ;
674+ ftruncate : typeof InternalFSBinding . ftruncate ;
675+ futimes : typeof InternalFSBinding . futimes ;
676+ internalModuleReadJSON : typeof InternalFSBinding . internalModuleReadJSON ;
677+ internalModuleStat : typeof InternalFSBinding . internalModuleStat ;
678+ lchown : typeof InternalFSBinding . lchown ;
679+ link : typeof InternalFSBinding . link ;
680+ lstat : typeof InternalFSBinding . lstat ;
681+ lutimes : typeof InternalFSBinding . lutimes ;
682+ mkdtemp : typeof InternalFSBinding . mkdtemp ;
683+ mkdir : typeof InternalFSBinding . mkdir ;
684+ open : typeof InternalFSBinding . open ;
685+ openFileHandle : typeof InternalFSBinding . openFileHandle ;
686+ read : typeof InternalFSBinding . read ;
687+ readBuffers : typeof InternalFSBinding . readBuffers ;
688+ readdir : typeof InternalFSBinding . readdir ;
689+ readlink : typeof InternalFSBinding . readlink ;
690+ realpath : typeof InternalFSBinding . realpath ;
691+ rename : typeof InternalFSBinding . rename ;
692+ rmdir : typeof InternalFSBinding . rmdir ;
693+ stat : typeof InternalFSBinding . stat ;
694+ symlink : typeof InternalFSBinding . symlink ;
695+ unlink : typeof InternalFSBinding . unlink ;
696+ utimes : typeof InternalFSBinding . utimes ;
697+ writeBuffer : typeof InternalFSBinding . writeBuffer ;
698+ writeBuffers : typeof InternalFSBinding . writeBuffers ;
699+ writeString : typeof InternalFSBinding . writeString ;
700+ } ;
0 commit comments