 
   asarStatsToFsStats stats
 
-stat = fs.stat
-fs.stat = (p, callback) ->
+lstat = fs.lstat
+fs.lstat = (p, callback) ->
   [isAsar, asarPath, filePath] = splitPath p
-  return stat p, callback unless isAsar
+  return lstat p, callback unless isAsar
 
   archive = asar.createArchive asarPath
   return callback throw new Error("Invalid package #{asarPath}") unless archive

  info = archive.getFileInfo filePath
  return callback createNotFoundError(asarPath, filePath) unless info

  buffer = new Buffer(info.size)
  fs.open archive.path, 'r', (error, fd) ->
    return callback error if error
    fs.read fd, buffer, 0, info.size, info.offset, (error) ->
      fs.close fd, ->
        callback error, buffer

readFileSync = fs.readFileSync
fs.readFileSync = (p) ->
  [isAsar, asarPath, filePath] = splitPath p
  return readFileSync.apply this, arguments unless isAsar


  return callback createNotFoundError(asarPath, filePath) unless stats

  callback undefined, asarStatsToFsStats stats

statSync = fs.statSync
fs.statSync = (p) ->
  [isAsar, asarPath, filePath] = splitPath p
  return statSync p unless isAsar

  # Do not distinguish links for now.
  fs.lstatSync p

stat = fs.stat
fs.stat = (p, callback) ->
  [isAsar, asarPath, filePath] = splitPath p
  return stat p, callback unless isAsar

  # Do not distinguish links for now.
  fs.lstat p, callback

statSyncNoException = fs.statSyncNoException
fs.statSyncNoException = (p) ->
