File

Enums

enum FileType with Eq, Order, ToStringSource
case File(Unit)case Directory(Unit)case SymLink(Unit)case Other(Unit)

File types.

Type Aliases

type alias StatInfo = { accessTime = Int64, creationTime = Int64, fileType = FileType, modificationTime = Int64, size = Int64 }Source

Statistical information for a file.

Definitions

def accessTime(f: String): Result[String, Int64] \ IOSource

Returns the last access time of the given file f in milliseconds.

def append(f: String, data: t): Result[String, Bool] \ IOSource

Appends data to the given file f.

Returns true if the file f was created, and false if data was appended to an existing f.

def appendBytes(f: String, data: f[Int8]): Result[String, Bool] \ IOSource

Appends data to the given f.

Returns true if the file f was created, and false if data was appended to an existing f.

def appendLines(f: String, data: f[String]): Result[String, Bool] \ IOSource

Appends data to the given file f.

Returns true if the file f was created, and false if data was appended to an existing f.

def copy(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Copies a file or directory from path src to path dst.

Returns Ok(()) if src was copied, and dst did not already exist. Returns Err(msg) if src was not copied because: - dst already exists, or - dst is a subpath of src, or - an I/O error occurred.

def copyInto(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Copies a file or directory from path src to directory dst.

Returns Ok(()) if src was copied, and dst is a directory. Returns Err(msg) if: - src was not copied, or - dst is a subpath of src, or - dst is not a directory, or - an I/O error occurred.

def copyOver(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Copies a file or directory from path src to path dst. Overwrites if dst already exists.

Returns Ok(()) if src was copied. Returns Err(msg) if src was not copied, or an I/O error occurred.

def creationTime(f: String): Result[String, Int64] \ IOSource

Returns the creation time of the given file f in milliseconds.

def delete(f: String): Result[String, Unit] \ IOSource

Deletes the given file or directory f.

If f is a directory it must be empty.

def deleteIfExists(f: String): Result[String, Bool] \ IOSource

Returns true if the given file or directory f was deleted and false if f was not deleted because it did not exist.

If f is a directory it must be empty.

def exists(f: String): Result[String, Bool] \ IOSource

Returns true if the given file f exists.

def fileType(f: String): Result[String, FileType] \ IOSource

Returns the type of the given file f.

def isDirectory(f: String): Result[String, Bool] \ IOSource

Returns true is the given file f is a directory.

def isExecutable(f: String): Result[String, Bool] \ IOSource

Returns true if the given file f is executable.

def isReadable(f: String): Result[String, Bool] \ IOSource

Returns true if the given file f is readable.

def isRegularFile(f: String): Result[String, Bool] \ IOSource

Returns true if the given file f is a regular file.

def isWritable(f: String): Result[String, Bool] \ IOSource

Returns true if the given file f is writable.

def list(f: String): Result[String, List[String]] \ IOSource

Returns a list naming the files and directories in the directory f. The full paths of the files and directories are specified.

Does not recursively traverse the directory.

def listWithIter(rc: Region[r], f: String): Result[String, Iterator[String, r, r]] \ IOSource

Returns an Iterator naming the files and directories in the directory f. The full paths of the files and directories are specified.

Does not recursively traverse the directory.

def mkdir(d: String): Result[String, Bool] \ IOSource

Creates the directory d.

Returns Ok(true) if the directory d was created and did not already exist. Returns Ok(false) if the directory d already existed and is a directory. Returns Err(msg) if the directory could not be created.

def mkdirs(d: String): Result[String, Bool] \ IOSource

Creates the directory d along with all necessary parent directories.

Returns Ok(true) if the directory d was created and did not already exist. Returns Ok(false) if the directory d already existed and is a directory. Returns Err(msg) if the directory could not be created.

def modificationTime(f: String): Result[String, Int64] \ IOSource

Returns the last-modified timestamp of the given file f in milliseconds

def move(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Moves a file or directory from path src to path dst.

Returns Ok(()) if src was moved, and dst did not already exist. Returns Err(msg) if src was not moved because: - dst already exists, or - dst is a subpath of src, or - an I/O error occurred.

def moveInto(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Moves a file or directory from path src to directory dst.

Returns Ok(()) if src was moved, and dst is a directory. Returns Err(msg) if: - src was not moved, or - dst is a subpath of src, or - dst is not a directory, or - an I/O error occurred.

def moveOver(src: { src = String }, dst: String): Result[String, Unit] \ IOSource

Moves a file or directory from path src to path dst. Overwrites if dst already exists.

Returns Ok(()) if src was moved. Returns Err(msg) if src was not moved, or an I/O error occurred.

def read(f: String): Result[String, String] \ IOSource

Returns a string containing the given file f.

def readBytes(_rc: Region[r], f: String): Result[String, Array[Int8, r]] \ IOSource

Returns an array of all the bytes in the given file f.

def readBytesWith(rc: Region[r], opts: { count = Int32, offset = Int64 }, f: String): Result[String, Array[Int8, r]] \ IOSource

Returns an array of all the bytes in the given file f and applying the options opts. The options opts to apply consists of offset - the start offset in the given file f. count - the number of bytes read.

def readChunks(rc: Region[r], chunkSize: Int32, f: String): Iterator[Result[String, Array[Int8, r]], IO, r] \ IOSource

Returns an iterator of the bytes in the given file in chunks of size chunkSize.

def readLines(f: String): Result[String, List[String]] \ IOSource

Returns a list of all the lines in the given file f.

def readLinesIter(rc: Region[r], f: String): Iterator[Result[String, String], IO, r] \ IOSource

Returns an iterator of the given file f

def readLinesIterWith(rc: Region[r], opts: { charSet = String }, f: String): Iterator[Result[String, String], IO, r] \ IOSource

Returns an iterator of the given file f with the options opts. The options opts to apply consists of charSet - the specific charset to be used to decode the bytes.

def readLinesWith(opts: { charSet = String }, f: String): Result[String, List[String]] \ IOSource

Returns a list of all the lines in the given file f with the options opts. The options opts to apply consists of charSet - the specific charset to be used to decode the bytes.

def readWith(opts: { charSet = String, count = Int32, offset = Int64 }, f: String): Result[String, String] \ IOSource

Returns a string containing the given file f with the options opts. The options opts to apply consists of offset - the start offset in the given file f. count - the number of bytes read. charSet - the specific charset to be used to decode the bytes.

def size(f: String): Result[String, Int64] \ IOSource

Returns the size of the given file f in bytes.

def stat(f: String): Result[String, StatInfo] \ IOSource

Returns the statistics of the given file f.

def truncate(f: String): Result[String, Bool] \ IOSource

Returns true if the file f was created, and false if f was overwritten.

def walk(rc: Region[r], f: String): Result[String, Iterator[String, r, r]] \ IOSource

Returns an Iterator over the files and directories recursively under the path f, including f itself. The full paths of the files and directories are specified.

Recursively traverses the directory.

def write(f: String, data: t): Result[String, Bool] \ IOSource

Writes data to the given file f.

Creates file f if it does not exist. Overwrites it if it exists.

Returns true if the file was created.

def writeBytes(f: String, data: f[Int8]): Result[String, Bool] \ IOSource

Writes data to the given f.

Creates f if it does not exist. Overwrites it if it exists.

Returns true if the file f was created, and false if f was overwritten.

def writeLines(f: String, data: f[String]): Result[String, Bool] \ IOSource

Writes data to the given f.

Creates f if it does not exist. Overwrites it if it exists.

Returns true if the file f was created, and false if f was overwritten.