fs

module methods:

FileMode type

ModeDesc
ModeDird: is a directory
ModeAppenda: append-only
ModeExclusivel: exclusive use
ModeTemporaryT: temporary file; Plan 9 only
ModeSymlinkL: symbolic link
ModeDeviceD: device file
ModeNamedPipep: named pipe (FIFO)
ModeSocketS: Unix domain socket
ModeSetuidu: setuid
ModeSetgidg: setgid
ModeCharDevicec: Unix character device
ModeStickyt: sticky
ModeIrregular?: non-regular file; nothing else is known about this file

FileMode permission

Normally, use expression such as (fs perm 777) to generate a permission FileMode.

flag

Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified. The remaining values may be or'ed in to control behavior.

FlagDesc
O_RDONLYopen the file read-only
O_WRONLYopen the file write-only
O_RDWRopen the file read-write
O_CREATEcreate a new file if none exists
O_EXCLused with O_CREATE, file must not exist
O_APPENDappend data to the file when writing
O_TRUNCtruncate regular writable file when opened
O_SYNCopen for synchronous I/O

perm

Create a permission fs/FileMode.

(fs perm p(int)) -> filemode

remove

Remove the file name. It returns an error, if any.

(fs remove name(string)) -> nil

open

Open the file name. It returns an error, if any.

(fs open name(string)) -> file

open_file

Open file for generalize purple. Users can use OS_RDONLY flag for reading, OS_WRONLY flag for writing, etc.

(fs open_file name(string) flag(int) mode(filemode)) -> file

create

Create a new file name. It returns an error, if any.

(fs create name(string)) -> file

exist?

Test whether the file name exists.

(fs exist? name(string)) -> bool

read_all

Read all content in file name. It returns an error, if any.

(fs readall name(string)) -> string

read_line

Read lines in file name by calling the callback for each line. Every line as first parameter of callback. It returns an error, if any.

(fs read name(string) callback(lambda)) -> nil

chtimes

Changes the access and modification times of the name file

(fs chtimes name(string) atime(time) mtime(time)) -> nil

move

Moves source to target. If target already exists and is not a directory, move replaces it.

(fs move source(string) target(string)) -> nil

remove_all

Removes path and any children it contains.

(fs remove_all path(string)) -> nil

chdir

Changes the current working directory to path.

(fs chdir path(string)) -> nil

walk

Walks the file tree rooted at root, calling callback for each file or directory in the tree, including root. file path is as callback first parameter, file info is as callback second parameter.

(fs walk root(string) callback(lambda)) -> nil

chmod

Changes the mode of the name file to mode.

(fs chmod name(string) mode(filemode)) -> nil

chown

Changes the numeric uid and gid of the name file. On Windows, it will raise error.

(fs chown name(string) uid(int) gid(int)) -> nil