# 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 | API | Description | | ------ | ------ | | [fs.path](/en/docs/fs/path) | Returns the path text bound to the current fs object. | | [fs.to_string](/en/docs/fs/to_string) | Returns the path text bound to the current fs object. | | [fs.read](/en/docs/fs/read) | Read the contents of the text file. | | [fs.real_path](/en/docs/fs/real_path) | Returns the real absolute path after the operating system resolves the symbolic link and `..`. | | [fs.binary](/en/docs/fs/binary) | Read the binary content of the file. | | [fs.lines](/en/docs/fs/lines) | Read text files line by line. | | [fs.write](/en/docs/fs/write) | Overwrite the content of the written file. | | [fs.atomic_write](/en/docs/fs/atomic_write) | Atomic replacement of content via temporary files in the same directory, rejecting conflicts as per old SHA-256. | | [fs.append](/en/docs/fs/append) | Append content to the end of the file. | | [fs.prepend](/en/docs/fs/prepend) | Write content to the beginning of the file. | | [fs.size](/en/docs/fs/size) | Read file or directory metadata size. | | [fs.rename](/en/docs/fs/rename) | Rename the current path to the target path. | | [fs.move](/en/docs/fs/move) | Move the current file or directory to the target directory, and the file name remains unchanged. | | [fs.copy](/en/docs/fs/copy) | Copy files or directories to the target path. | | [fs.delete](/en/docs/fs/delete) | Delete a file or directory. | | [fs.create_dir](/en/docs/fs/create_dir) | Create a directory recursively. | | [fs.create_file](/en/docs/fs/create_file) | Creates a file and writes optional initial content. | | [fs.list](/en/docs/fs/list) | List directory entries. | | [fs.is_dir](/en/docs/fs/is_dir) | Determine whether the path is a directory. | | [fs.is_file](/en/docs/fs/is_file) | Determine whether the path is an ordinary file. | | [fs.is_relative](/en/docs/fs/is_relative) | Determine whether the current path is a relative path. | | [fs.is_absolute](/en/docs/fs/is_absolute) | Determine whether the current path is an absolute path. | | [fs.is_symlink](/en/docs/fs/is_symlink) | Determine whether the path is a symbolic link. | | [fs.is_exists](/en/docs/fs/is_exists) | Determine whether the path exists. | | [fs.basename](/en/docs/fs/basename) | Returns the last level name of the path. | | [fs.filename](/en/docs/fs/filename) | Returns the last-level name of the path minus the extension. | | [fs.extension](/en/docs/fs/extension) | Returns the path extension. | ## Examples ```bt file = fs('demo.txt') file.write('BT') result = file.read() // Output: BT print result ``` ## 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.