function createStatEntry(file, fullpath, callback) {
        fs.lstat(fullpath, function (err, stat) {
            var entry = {
                name: file
            };

            if (err) {
                entry.err = err;
                return callback(entry);
            } else {
                entry.size = stat.size;
                entry.mtime = stat.mtime.valueOf();

                if (stat.isDirectory()) {
                    entry.mime = "inode/directory";
                } else if (stat.isBlockDevice()) entry.mime = "inode/blockdevice";
                else if (stat.isCharacterDevice()) entry.mime = "inode/chardevice";
                else if (stat.isSymbolicLink()) entry.mime = "inode/symlink";
                else if (stat.isFIFO()) entry.mime = "inode/fifo";
                else if (stat.isSocket()) entry.mime = "inode/socket";
                else {
                    entry.mime = getMime(fullpath);
                }

                if (!stat.isSymbolicLink()) {
                    return callback(entry);
                }
                fs.readlink(fullpath, function (err, link) {
                    if (entry.name == link) {
                        entry.linkStatErr = "ELOOP: recursive symlink";
                        return callback(entry);
                    }

                    if (err) {
                        entry.linkErr = err.stack;
                        return callback(entry);
                    }
                    entry.link = link;
                    resolvePath(pathResolve(dirname(fullpath), link), {alreadyRooted: true, nocheck: 1}, function (err, newpath) {
                      if (err) {
                          entry.linkStatErr = err;
                          return callback(entry);
                      }
                      createStatEntry(basename(newpath), newpath, function (linkStat) {
                          entry.linkStat = linkStat;
                          linkStat.fullPath = newpath.substr(base.length) || "/";
                          return callback(entry);
                      });
                    });
                });
            }
        });
    }
// there is no err, only entry.
there is no err, only entry.
there is no err only entry .
function createStatEntry(file, fullpath, callback) {
        fs.lstat(fullpath, function (err, stat) {
            var entry = {
                name: file
            };
            if (err) {
                entry.err = err;
                return callback(entry);
            } else {
                entry.size = stat.size;
                entry.mtime = stat.mtime.valueOf();
                if (stat.isDirectory()) {
                    entry.mime = "inode/directory";
                } else if (stat.isBlockDevice()) entry.mime = "inode/blockdevice";
                else if (stat.isCharacterDevice()) entry.mime = "inode/chardevice";
                else if (stat.isSymbolicLink()) entry.mime = "inode/symlink";
                else if (stat.isFIFO()) entry.mime = "inode/fifo";
                else if (stat.isSocket()) entry.mime = "inode/socket";
                else {
                    entry.mime = getMime(fullpath);
                }
                if (!stat.isSymbolicLink()) {
                    return callback(entry);
                }
                fs.readlink(fullpath, function (err, link) {
                    if (entry.name == link) {
                        entry.linkStatErr = "ELOOP: recursive symlink";
                        return callback(entry);
                    }
                    if (err) {
                        entry.linkErr = err.stack;
                        return callback(entry);
                    }
                    entry.link = link;
                    resolvePath(pathResolve(dirname(fullpath), link), {alreadyRooted: true, nocheck: 1}, function (err, newpath) {
                      if (err) {
                          entry.linkStatErr = err;
                          return callback(entry);
                      }
                      createStatEntry(basename(newpath), newpath, function (linkStat) {
                          entry.linkStat = linkStat;
                          linkStat.fullPath = newpath.substr(base.length) || "/";
                          return callback(entry);
                      });
                    });
                });
            }
        });
    }
function createStatEntry ( file , fullpath , callback ) { fs . lstat ( fullpath , function ( err , stat ) { var entry = { name : file } ; if ( err ) { entry . err = err ; return callback ( entry ) ; } else { entry . size = stat . size ; entry . mtime = stat . mtime . valueOf ( ) ; if ( stat . isDirectory ( ) ) { entry . mime = "inode/directory" ; } else if ( stat . isBlockDevice ( ) ) entry . mime = "inode/blockdevice" ; else if ( stat . isCharacterDevice ( ) ) entry . mime = "inode/chardevice" ; else if ( stat . isSymbolicLink ( ) ) entry . mime = "inode/symlink" ; else if ( stat . isFIFO ( ) ) entry . mime = "inode/fifo" ; else if ( stat . isSocket ( ) ) entry . mime = "inode/socket" ; else { entry . mime = getMime ( fullpath ) ; } if ( ! stat . isSymbolicLink ( ) ) { return callback ( entry ) ; } fs . readlink ( fullpath , function ( err , link ) { if ( entry . name == link ) { entry . linkStatErr = "ELOOP: recursive symlink" ; return callback ( entry ) ; } if ( err ) { entry . linkErr = err . stack ; return callback ( entry ) ; } entry . link = link ; resolvePath ( pathResolve ( dirname ( fullpath ) , link ) , { alreadyRooted : true , nocheck : 1 } , function ( err , newpath ) { if ( err ) { entry . linkStatErr = err ; return callback ( entry ) ; } createStatEntry ( basename ( newpath ) , newpath , function ( linkStat ) { entry . linkStat = linkStat ; linkStat . fullPath = newpath . substr ( base . length ) || "/" ; return callback ( entry ) ; } ) ; } ) ; } ) ; } } ) ; }
there is no err, only entry.
there is no err only entry .