TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sxyazi/yazi/llms.txt
Use this file to discover all available pages before exploring further.
fs namespace provides filesystem operations that work with both local and remote (VFS) files.
File Access
fs.access()
Create a file access builder for opening files with specific permissions.
Access builder object
Access Methods
:append(bool)- Open for appending:create(bool)- Create file if it doesn’t exist:create_new(bool)- Create new file, fail if exists:read(bool)- Open for reading:write(bool)- Open for writing:truncate(bool)- Truncate file on open:open(url)- Open the file and return file descriptor
File Operations
fs.copy(from, to)
Copy a file from one location to another.
Source file URL
Destination file URL
Number of bytes copied, or (nil, error)
fs.rename(from, to)
Rename/move a file or directory.
Source URL
Destination URL
Success boolean, or (false, error)
fs.write(url, data)
Write data to a file.
File URL
Data to write
Success boolean, or (false, error)
Directory Operations
fs.create(type, url)
Create a directory.
Either
"dir" or "dir_all" (creates parent directories)Directory URL
Success boolean, or (false, error)
fs.remove(type, url)
Remove a file or directory.
One of:
"file", "dir", "dir_all" (recursive), "dir_clean" (only if empty)File/directory URL
Success boolean, or (false, error)
fs.read_dir(dir, options)
Read directory contents.
Directory URL
Read options
Glob pattern to filter files
Maximum number of files to read (default: unlimited)
Resolve symlinks and get full metadata (default: false)
List of files, or (nil, error)
File Metadata
fs.cha(url, follow?)
Get file characteristics (metadata).
File URL
Follow symlinks (default: false)
File characteristics, or (nil, error)
Cha Fields
len(number) - File size in bytesis_dir(bool) - Is directoryis_hidden(bool) - Is hidden fileis_link(bool) - Is symbolic linkis_orphan(bool) - Is orphan symlinkis_block(bool) - Is block deviceis_char(bool) - Is character deviceis_fifo(bool) - Is FIFOis_sock(bool) - Is socketis_exec(bool) - Is executableis_sticky(bool) - Has sticky bitmodified(number) - Last modified time (timestamp)accessed(number) - Last accessed time (timestamp)created(number) - Created time (timestamp)permissions(string) - Unix permissions string (e.g., “rwxr-xr-x”)
fs.calc_size(url)
Calculate total size of a directory (async iterator).
Directory URL
Size calculator iterator, or (nil, error)
Utilities
fs.unique(type, url)
Create a unique file or directory name (handles naming conflicts).
Either
"file" or "dir"Desired URL (may be modified to be unique)
Unique URL, or (nil, error)
This replaces the deprecated
fs.unique_name() to fix TOCTOU race conditions. See #3677.fs.cwd()
Get the current working directory.
Current directory URL, or (nil, error)
fs.expand_url(value)
Expand ~ and environment variables in a URL/path string.
URL string or Url object
Expanded URL
fs.partitions()
Get list of mounted partitions.
List of partition info tables
src(string) - Device pathdist(string) - Mount pointlabel(string) - Volume labelfstype(string) - Filesystem typeexternal(bool) - Is external driveremovable(bool) - Is removable media
File Operations Helper
fs.op(name, options)
Low-level file operation helper (internal use).
Operation name:
"part", "done", "size"Operation-specific options