Path to the file. ~ is expanded.
Optionalmode: string
The open mode. Defaults to "r".
Optionalpermissions: number
POSIX permission bits applied if the file is created, e.g. 0o600 (0 creates a file with no permissions). Defaults to 0o644 when omitted; any other non-integer value, including NaN, fails with EINVAL. The process umask is applied in either case.
An HSFile, or null on failure (see hs.fs.lastError).
Open a file, returning an
HSFileobject for reading and/or writing it.Modes follow C's
fopen()(and Lua'sio.open()):"r""r+""w""w+""a""a+"Add
xto awmode ("wx","w+x") to fail if the file already exists. Abis accepted and ignored, since all files can be read as text or bytes.Directories cannot be opened. A file that can't be opened (for example because it doesn't exist) is not logged to the Console, since that is often an expected outcome; check
hs.fs.lastErrorinstead. Invalid arguments, such as an unknown mode, are logged.Close the file with
close()when you are finished with it; any files still open are closed automatically when your configuration is reloaded.