lib/dirio.js
function _pathStated(item, stat, stated, callback, err, stats) {
  if (err) return callback(err);

  item.name = path.basename(stated);

  if (stats.isFile()) {
    item.type = TYPE_FILE;
    // TODO set encoding according to the read file content or user preferences
    return fs.readFile(stated, {encoding: 'utf8'}, _fileRead.bind(null, item, callback));
  }
  if (stats.isDirectory()) {
    item.type = TYPE_FOLDER;
    return fs.readdir(stated, _folderRead.bind(null, item, stat, stated, callback));
  }
  if (stats.isSymbolicLink()) {
    item.type = TYPE_ALIAS;
    return fs.readlink(stated, _aliasRead.bind(null, item, callback));
  }
  // not supported type
  item.type = TYPE_UNKNOWN;
  callback(null, item);
}
function _pathStated(item, stat, stated, callback, err, stats) {
  if (err) return callback(err);

  item.name = path.basename(stated);

  if (stats.isFile()) {
    item.type = TYPE_FILE;
    // TODO set encoding according to the read file content or user preferences
    return fs.readFile(stated, {encoding: 'utf8'}, _fileRead.bind(null, item, callback));
  }
  if (stats.isDirectory()) {
    item.type = TYPE_FOLDER;
    return fs.readdir(stated, _folderRead.bind(null, item, stat, stated, callback));
  }
  if (stats.isSymbolicLink()) {
    item.type = TYPE_ALIAS;
    return fs.readlink(stated, _aliasRead.bind(null, item, callback));
  }
  // not supported type
  item.type = TYPE_UNKNOWN;
  callback(null, item);
}
function _pathStated ( item , stat , stated , callback , err , stats ) { if ( err ) return callback ( err ) ; item . name = path . basename ( stated ) ; if ( stats . isFile ( ) ) { item . type = TYPE_FILE ; // TODO set encoding according to the read file content or user preferences return fs . readFile ( stated , { encoding : 'utf8' } , _fileRead . bind ( null , item , callback ) ) ; } if ( stats . isDirectory ( ) ) { item . type = TYPE_FOLDER ; return fs . readdir ( stated , _folderRead . bind ( null , item , stat , stated , callback ) ) ; } if ( stats . isSymbolicLink ( ) ) { item . type = TYPE_ALIAS ; return fs . readlink ( stated , _aliasRead . bind ( null , item , callback ) ) ; } // not supported type item . type = TYPE_UNKNOWN ; callback ( null , item ) ; }
Investigates stats of a path and continues according to stats type.
Supported types are file, directory, symbolic link.
@param {Object} item - Object that is supposed to be updated with
discovered data.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} stated - The investigated path on file system.
@param {Function} callback - Callback that expects a possible error
and the result.
@param {*} err - Possible error passed by caller.
@param {fs.Stats} stats - Metadata of the path.
Investigates stats of a path and continues according to stats type . Supported types are file directory symbolic link .