Definition and functionality of all functions of node. JS FS

Source: Internet
Author: User

Table 4-1 FS module function table

Function Async methods Synchronization method
Open File   Fs.open (Path,flags, [mode], [Callback (Err, FD)]) Fs.opensync (path, flags, [mode])
Close File   Fs.close (FD, [Callback (ERR)]) Fs.closesync (FD)
Read file (file descriptor ) Fs.read (Fd,buffer,offset,length,position, [Callback (Err, bytesread, buffer)]) Fs.readsync (fd, buffer, offset, length, position)
Write file (file descriptor) Fs.write (Fd,buffer,offset,length,position, [Callback (Err, Byteswritten, buffer)]) Fs.writesync (fd, buffer, offset, length, position)
Read File contents   Fs.readfile (Filename,[encoding],[callback (err, data)]) Fs.readfilesync (filename, [encoding])
Write file contents Fs.writefile (filename, data,[encoding], [Callback (ERR)]) Fs.writefilesync (filename, data, [encoding])
Deleting Files   Fs.unlink (Path, [Callback (ERR)]) Fs.unlinksync (PATH)
Create a directory   Fs.mkdir (path, [mode], [Callback (ERR)]) Fs.mkdirsync (path, [mode])
Delete directory   Fs.rmdir (Path, [Callback (ERR)]) Fs.rmdirsync (PATH)
Read Directory   Fs.readdir (Path, [Callback (Err, files)]) Fs.readdirsync (PATH)
Get the real path Fs.realpath (Path, [Callback (Err, Resolvedpath)]) Fs.realpathsync (PATH)
renamed   Fs.rename (path1, path2, [Callback (ERR)]) Fs.renamesync (path1, path2)
truncate   Fs.truncate (FD, Len, [Callback (ERR)]) Fs.truncatesync (FD, Len)
Change Ownership   Fs.chown (path, UID, GID, [Callback (ERR)]) Fs.chownsync (path, UID, GID)
Change ownership (file descriptor) Fs.fchown (FD, UID, GID, [Callback (ERR)]) Fs.fchownsync (FD, UID, GID)
Change ownership (do not parse symbolic links) Fs.lchown (path, UID, GID, [Callback (ERR)]) Fs.lchownsync (path, UID, GID)
Change permissions Fs.chmod (path, mode, [Callback (ERR)]) Fs.chmodsync (path, mode)
Change permissions (file descriptors) Fs.fchmod (fd, Mode, [Callback (ERR)]) Fs.fchmodsync (FD, mode)
Change permissions (do not parse symbolic links) Fs.lchmod (path, mode, [Callback (ERR)]) Fs.lchmodsync (path, mode)
Get file Information   Fs.stat (Path, [Callback (err, stats)]) Fs.statsync (PATH)
Get file information (file descriptor) Fs.fstat (FD, [Callback (err, stats)]) Fs.fstatsync (FD)
Get file information (do not parse symbolic links) Fs.lstat (Path, [Callback (err, stats)]) Fs.lstatsync (PATH)
Create a hard link Fs.link (Srcpath, Dstpath, [Callback (ERR)]) Fs.linksync (Srcpath, Dstpath)
Creating Symbolic Links Fs.symlink (linkdata, path, [type], [Callback (ERR)]) Fs.symlinksync (linkdata, path, [type])
Read Link   Fs.readlink (Path, [Callback (Err, linkstring)]) Fs.readlinksync (PATH)
Modify File timestamp   Fs.utimes (Path, Atime, Mtime, [Callback (ERR)]) Fs.utimessync (Path, atime, Mtime)
Modify file timestamp (file descriptor) Fs.futimes (FD, Atime, Mtime, [Callback (ERR)]) Fs.futimessync (FD, Atime, Mtime)
Synchronizing disk caches   Fs.fsync (FD, [Callback (ERR)]) Fs.fsyncsync (FD)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.