Functions for working with files and directories are described here.
The finfo is used for getting information about a file and has the following fields:
str Name - base name of the file
int Size - length in bytes for regular files
int Mode - file's mode and permission bits.
time Time - last modification time
bool IsDir - true if it is a directory
The AppendFile function appends data of buf variable or a string to a file named by filename. If the file does not exist, AppendFile creates it with 0644 permissions.
The ChDir function changes the current directory.
The ChMode function changes the attributes of the file.
The CopyFile function copies src file to dest file. If dest file exists it is overwritten. The file attributes are preserved when copying. The function returns the number of copied bytes.
The CreateDir function creates a directory named dirname, along with any necessary parents. If dirname is already a directory, CreateDir does nothing.
The FileInfo function gets information about the named file and returns finfo structure.
The FileMode function returns the file attributes.
The GetCurDir function returns the current directory.
The Md5File function returns the MD5 hash of the specified file as a hex string.
The ReadDir function reads the directory named by dirname and returns a list of directories and files entries.
The ReadFile function reads the specified file and returns the contents as a string.
The ReadFile function reads the file named by filename to the buf variable out and returns it.
The ReadFile function reads data from the filename file starting at offset offset and length length. If offset is less than zero, then the offset is counted from the end to the beginning of the file.
The Remove function removes a file or an empty directory.
The RemoveDir function removes dirname directory and any children it contains.
The Rename function renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it.
The SetFileTime function changes the modification time of the named file.
The Sha256File function returns the SHA256 hash of the specified file as a hex string.
The TempDir function returns the default temporary directory.
The TempDir function creates a new temporary directory in the directory path with a name beginning with prefix and returns the path of the new directory. If path is the empty string, TempDir uses the default temporary directory.
The WriteFile function writes data of buf variable or a string to a file named by filename. If the file does not exist, WriteFile creates it with 0777 permissions, otherwise the file is truncated before writing.