fs

450 阅读2分钟

常用的标记蓝色,方法默认异步;同步=Sync, f=filehand,L=不解析符号链接

【信息】

realpath
  • fs.realpath(path[, options], callback) 获取真实路径
  • fs.realpath.native(path[, options], callback)
  • fs.realpathSync(path[, options])
  • fs.realpathSync.native(path[, options])
stat
  • fs.stat(path[, options], callback) 获取文件信息
  • fs.statSync(path[, options])
  • fs.fstat(fd[, options], callback) 返回文件的详细信息
  • fs.fstatSync(fd[, options])
  • fs.lstat(path[, options], callback) 获取文件信息(不解析符号链接)
  • fs.lstatSync(path[, options])

【权限】

F
  • fs.fchmod(fd, mode, callback)
  • fs.fchmodSync(fd, mode)
  • fs.fchown(fd, uid, gid, callback)
  • fs.fchownSync(fd, uid, gid)
L
  • fs.lchmod(path, mode, callback) 更改文件权限(不解析符号链接)
  • fs.lchmodSync(path, mode)
  • fs.lchown(path, uid, gid, callback) 更改文件所有权(不解析符号链接)
  • fs.lchownSync(path, uid, gid)

【目录】

【文件】

read
write
truncate

【其它】

  • fs.fdatasync(fd, callback) 刷新数据到磁盘
  • fs.fdatasyncSync(fd)
  • fs.fsync(fd, callback) 同步缓存数据到磁盘
  • fs.fsyncSync(fd)
  • fs.rename(oldPath, newPath, callback) 重命名路径
  • fs.renameSync(oldPath, newPath)
link
watch
time
  • fs.utimes(path, atime, mtime, callback) 修改文件时间戳
  • fs.utimesSync(path, atime, mtime)
  • fs.futimes(fd, atime, mtime, callback) 更改一个文件所提供的文件描述符引用的文件的时间戳
  • fs.futimesSync(fd, atime, mtime)

【流】