Opens a file and returns a File handle.
Mode: "r" (default), "w", "a", "r+", "w+", "a+".
@eryx/fs Module
File system operations and file handle I/O.
Use open() / openSync() to get a File handle with read, write, seek,
truncate, and other operations. Most File methods yield by default; use
the Sync suffix for non-yielding variants (e.g. readSync, writeSync).
Pure path manipulation lives under @eryx/path.
fs.path.* remains as a legacy compatibility surface.
Summary
Functions
API Reference
Functions
fs.open
⚠ Yields
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
Returns
Open file handle.
fs.openSync
Opens a file synchronously and returns a File handle.
Mode: "r" (default), "w", "a", "r+", "w+", "a+".
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
File path to open.
File mode string.
Returns
Open file handle.
Parameters
Returns
Open file handle.
fs.exists
Parameters
Path to check.
Returns
true when the path exists.
fs.isFile
Parameters
Path to check.
Returns
true when the path is a regular file.
fs.isDirectory
Parameters
Path to check.
Returns
true when the path is a directory.
fs.mkdir
Parameters
Directory path to create.
Returns
true when directory creation succeeds.
fs.remove
Parameters
File or directory path to remove recursively.
Returns
true when removal succeeds.
fs.rename
Parameters
fs.copy
Parameters
fs.listDir
Parameters
Directory path.
Returns
Entry names from the directory.
fs.symlink
Creates a symlink at link pointing to target.
type: "file" (default) or "directory". Auto-detected from target if omitted.
On Windows, creating symlinks requires Developer Mode or administrator privileges.
Parameters
fs.readlink
Parameters
Symlink path.
Returns
Symlink target path.
fs.isSymlink
Parameters
Path to inspect.
Returns
true when the path itself is a symbolic link.
fs.stat
Returns file metadata.
Set followSymlinks to false to inspect the link itself.
The result always includes isSymlink regardless of followSymlinks.
Parameters
Path to inspect.
Whether symlinks should be followed. Defaults to true.
Returns
Metadata for the path, or an empty-like table when missing.
fs.hasPermission
Checks whether a principal has a specific permission on a path.
If options is omitted, checks the current effective principal.
Parameters
Target path.
Permission to test.
Optional principal/group override.
Returns
true when permission is granted.
fs.chmod
Changes POSIX mode bits.
Warning
POSIX only. On Windows, use setReadonly and setAcl.
Parameters
fs.chown
Changes owner (uid on POSIX, SID string on Windows).
Parameters
fs.chgrp
Changes group (gid on POSIX).
Warning
POSIX only.
Parameters
fs.getReadonly
Gets whether the path has the readonly attribute/effective readonly state.
Parameters
Target path.
Returns
true when readonly is enabled.
fs.setReadonly
Sets whether the path is readonly.
Parameters
fs.getHidden
Gets whether the path has the hidden attribute.
Warning
This API is only available in Windows environments.
Parameters
Target path.
Returns
true when hidden is enabled.
fs.setHidden
Sets whether the path has the hidden attribute.
Warning
This API is only available in Windows environments.
Parameters
fs.getSystem
Gets whether the path has the system attribute.
Warning
This API is only available in Windows environments.
Parameters
Target path.
Returns
true when the system attribute is enabled.
fs.setSystem
Sets whether the path has the system attribute.
Warning
This API is only available in Windows environments.
Parameters
fs.getAcl
Reads ACL entries for a path.
Warning
This API is only available in Windows environments.
Parameters
Target path.
Returns
Ordered ACL entries.
fs.setAcl
Writes ACL entries for a path.
Warning
This API is only available in Windows environments.
Parameters
path
fs.path.dirname
Returns the parent directory of the path ("a/b/c.txt" -> "a/b").
Parameters
Input path.
Returns
Parent directory path.
fs.path.basename
Returns the filename component of the path ("a/b/c.txt" -> "c.txt").
Parameters
Input path.
Returns
Basename component.
fs.path.stem
Returns the filename without its extension ("a/b/c.txt" -> "c").
Parameters
Input path.
Returns
Stem component.
fs.path.extension
Returns the file extension including the dot ("a/b/c.txt" -> ".txt").
Parameters
Input path.
Returns
Extension including leading dot, or empty string.
fs.path.canonicalize
Resolves a path to an absolute, canonical form.
Parameters
Input path.
Returns
Canonical absolute path.
fs.path.join
Joins path segments with the platform separator.
Parameters
Returns
Joined path.
Types
BaseFile
Truncates the file to size bytes, or at the current position if nil.
Returns the file size in bytes.
The file path passed to open.
The underlying file descriptor number.
true if the file has not been closed.
true if the file was opened for reading.
true if the file was opened for writing.
ReadableFile
WritableFile
ReadWriteFile
File
Union of all file-handle variants returned by fs.open/fs.openSync.
PermissionToken
Permission token used by hasPermission and ACL entry rights.
AclEntry
Single ACL entry. Windows-focused in this release.
Entry type.
Principal identifier (SID on Windows).
Rights granted/denied by this entry.
Whether this rule participates in inheritance.
Whether this entry was inherited from a parent ACL.
Scope this entry applies to.
PermissionCheckOptions
Optional overrides for hasPermission checks.
Principal id override (uid/gid on POSIX, SID on Windows when supported).
Whether symlinks should be followed while evaluating access.
FileStat
Metadata returned by stat.
File size in bytes when available.
Last modification time as Unix timestamp seconds.
true when the path is a regular file.
true when the path is a directory.
true when the path itself is a symlink.
true when readonly is enabled/effective.