@@ -27,11 +27,15 @@ const {Constants} = require('./constants');
2727const { Utils} = require ( './utils' ) ;
2828
2929
30- async function _listDir ( handle , callback ) {
30+ async function _listDir ( path , handle , options , callback ) {
3131 let dirEntryNames = [ ] ;
3232 try {
33- for await ( const [ key ] of handle . entries ( ) ) {
34- dirEntryNames . push ( key ) ;
33+ for await ( const [ key , value ] of handle . entries ( ) ) {
34+ let entry = key ;
35+ if ( options [ 'withFileTypes' ] ) {
36+ entry = await Utils . createStatObject ( globalObject . path . join ( path , key ) , value ) ;
37+ }
38+ dirEntryNames . push ( entry ) ;
3539 }
3640 if ( callback ) {
3741 callback ( null , dirEntryNames ) ;
@@ -85,10 +89,10 @@ function mkdir(path, mode, callback) {
8589
8690function readdir ( path , options , callback ) {
8791 path = globalObject . path . normalize ( path ) ;
88- if ( typeof options !== 'function' ) {
89- throw new Errors . ENOSYS ( 'Filer readdir options are not yet supported' ) ;
92+ if ( typeof options === 'function' ) {
93+ callback = options ;
94+ options = { } ;
9095 }
91- callback = options ;
9296
9397 if ( path === Constants . MOUNT_POINT_ROOT ) {
9498 let mountedFolders = Object . keys ( Mounts . getMountPoints ( ) ) ;
@@ -100,7 +104,7 @@ function readdir(path, options, callback) {
100104 } else if ( handle . kind === Constants . KIND_FILE ) {
101105 callback ( new Errors . ENOTDIR ( 'Path is not a directory.' ) ) ;
102106 } else {
103- _listDir ( handle , callback ) ;
107+ _listDir ( path , handle , options , callback ) ;
104108 }
105109 } ) ;
106110 }
0 commit comments