An interpreted programming language written in Go.
The files module exposes functions to open, close, and manipulate files and directories.
To use: import 'std/file'
Reads the entire file at filepath
and returns its contents as a string.
Deletes the file at filepath
. If the file doesn’t exist, nothing happens.
Returns if the file at filepath
exists.
Attempts to rename a file from oldPath
to newPath
. If no error occurs, nil
is returned.
Returns an array which is the directory listing of path. If path is not a directory, an error will be returned.
Returns if path is a directory.
Represents a file object. Creating this class will attempt to open the file
at path
with mode mode
.
mode | description |
---|---|
r | Open for reading only |
r+ | Open for reading and writing |
w | Open for writing only; truncates the file to zero length; if the file doesn’t exist, attempts to create it |
w+ | Open for reading and writing; truncates the file to zero length; if the file doesn’t exist, attempts to create it |
a | Opening for writing only; places file pointer at the end of file (append); if the file doesn’t exist, attempts to create it |
a+ | Opening for reading and writing; places file pointer at the end of file (append); if the file doesn’t exist, attempts to create it |
Closes the open file. If the file is already closed, nothing happens.
Writes data
to file. File must have been open using a mode that allows
writing otherwise a runtime exception will occur. The function returns the
number of bytes written.
Reads the entire file contents and returns it as a string.
Reads a single line from the file and returns it.
Reads a single character from the file and returns it.
Closes the file and deletes it.
Closes the file and renames it.