io
rm(path) function
Remove the file or empty directory at the given path.
path: The file or empty directory to remove. Must be empty if a directory.
Returns: None
mkdir(path) function
Create a directory at the given path.
path: The directory path to create.
Returns: None
stat(path) function
Return an object describing file metadata for the given path. The object includes filesize, modtime, createtime, and accesstime. Throw an error if the path does not exist.
path: The file or directory to retrieve metadata for.
Returns: An object with metadata (filesize, modtime, createtime, accesstime).
globfs(patterns) function
Return an array of files that do not match any of the provided glob patterns. It recursively enumerates the filesystem within PHYSFS. Each pattern is treated as an "ignore" rule, similar to .gitignore usage.
patterns: An array of glob patterns to ignore. Any file matching one of these is skipped.
Returns: An array of matching file paths.
match(pattern, string) function
Return boolean indicating whether the given wildcard pattern matches the provided string. Dots must match dots. Case is not ignored.
Patterns can incorporate: '?' - Matches exactly one character (except leading dots or slashes). '' - Matches zero or more characters (excluding path separators). '*' - Matches zero or more characters, including path separators. '[abc]' - A bracket expression; matches any single character from the set. Ranges like [a-z], [0-9] also work. '[[:alpha:]]' - POSIX character classes can be used inside brackets. '\' - Backslash escapes the next character. '!' - If placed immediately inside brackets (like [!abc]), it negates the set.
pattern: The wildcard pattern to compare.
string: The string to test against the wildcard pattern.
Returns: True if matched, otherwise false.
exists(path) function
Return a boolean indicating whether the file or directory at the given path exists.
path: The file or directory path to check.
Returns: True if the path exists, otherwise false.
mount(archiveOrDir, mountPoint) function
Mount a directory or archive at the specified mount point. An undefined mount point mounts to '/'. Throw on error.
archiveOrDir: The directory or archive to mount.
mountPoint: The path at which to mount. If omitted or undefined, '/' is used.
Returns: None
unmount(path) function
Unmount a previously mounted directory or archive. Throw on error.
path: The directory or archive mount point to unmount.
Returns: None
slurp(path) function
Read the entire file at the given path as a string. Throw on error.
path: The file path to read from.
Returns: A string with the file’s contents.
slurpbytes(path) function
Read the entire file at the given path as a raw ArrayBuffer. Throw on error.
path: The file path to read from.
Returns: An ArrayBuffer containing the file’s raw bytes.
slurpwrite(data, path) function
Write data (string or ArrayBuffer) to the given file path. Overwrite if it exists. Throw on error.
data: The data to write (string or ArrayBuffer).
path: The file path to write to.
Returns: None
writepath(path) function
Set the write directory. Subsequent writes will go here by default. Throw on error.
path: The directory path to set as writable.
Returns: None
basedir() function
Return the application's base directory (where the executable is located).
Returns: A string with the base directory path.
prefdir(org, app) function
Get the user-and-app-specific path where files can be written.
org: The name of your organization.
app: The name of your application.
Returns: A string with the user's directory path.
realdir(path) function
Return the actual, real directory (on the host filesystem) that contains the given file path. Return undefined if not found.
path: The file path whose real directory is requested.
Returns: A string with the real directory path, or undefined.
open(path) function
Open a file for writing, returning a file object that can be used for further operations. Throw on error.
path: The file path to open for writing.
Returns: A file object for subsequent write operations.
searchpath() function
Return an array of all directories in the current paths.
Returns: An array of directory paths in the search path.
enumerate(path, recurse) function
Return an array of files within the given directory, optionally recursing into subdirectories.
path: The directory to list.
recurse: Whether to recursively include subdirectories (true or false).
Returns: An array of file (and directory) paths found.