fs file system library

fs file system library

fs file system library

Function

fs(path) creates a file system path object, providing read and write, copy, move, delete, directory traversal and path information reading capabilities around the path.

API List

APIDescription
fs.pathReturns the path text bound to the current fs object.
fs.to_stringReturns the path text bound to the current fs object.
fs.readRead the contents of the text file.
fs.real_pathReturns the real absolute path after the operating system resolves the symbolic link and ...
fs.binaryRead the binary content of the file.
fs.linesRead text files line by line.
fs.writeOverwrite the content of the written file.
fs.atomic_writeAtomic replacement of content via temporary files in the same directory, rejecting conflicts as per old SHA-256.
fs.appendAppend content to the end of the file.
fs.prependWrite content to the beginning of the file.
fs.sizeRead file or directory metadata size.
fs.renameRename the current path to the target path.
fs.moveMove the current file or directory to the target directory, and the file name remains unchanged.
fs.copyCopy files or directories to the target path.
fs.deleteDelete a file or directory.
fs.create_dirCreate a directory recursively.
fs.create_fileCreates a file and writes optional initial content.
fs.listList directory entries.
fs.is_dirDetermine whether the path is a directory.
fs.is_fileDetermine whether the path is an ordinary file.
fs.is_relativeDetermine whether the current path is a relative path.
fs.is_absoluteDetermine whether the current path is an absolute path.
fs.is_symlinkDetermine whether the path is a symbolic link.
fs.is_existsDetermine whether the path exists.
fs.basenameReturns the last level name of the path.
fs.filenameReturns the last-level name of the path minus the extension.
fs.extensionReturns the path extension.

Examples

Notes

  • The path parameter of fs() will be parsed by the VM according to the current source code directory and project root rules.
- Synchronization file operation time should be controlled in the resident web service hot path.