Lyric v4.5.0

std.io.file

text function

pub fn text(path: string): ?string

The whole content as text, decoded as UTF-8 — bytes that are not valid UTF-8 become U+FFFD. For binary data use bytes. null when the file does not exist or is not readable.

stdlib/std/io/file.lyr:41

bytes function

pub fn bytes(path: string): ?uint8[]

The raw bytes, undecoded — what text cannot give: its UTF-8 decoding turns invalid bytes into U+FFFD. null when the file is not readable; an EMPTY array is an empty file.

stdlib/std/io/file.lyr:45

lines function

pub fn lines(path: string): ?string[]

The lines of a file, terminators removed, so whether the file used CRLF or LF is no longer visible. null when the file is not readable; an EMPTY array is an empty file.

stdlib/std/io/file.lyr:49

writeText function

pub fn writeText(path: string, content: string): bool

Writes text (UTF-8), replacing an existing file. true on success.

stdlib/std/io/file.lyr:52

appendText function

pub fn appendText(path: string, content: string): bool

Appends to an existing file or creates it. true on success.

stdlib/std/io/file.lyr:55

exists function

pub fn exists(path: string): bool

Whether something — file or directory — exists at the path.

stdlib/std/io/file.lyr:58

remove function

pub fn remove(path: string): bool

true when the file is gone afterwards, including when it never existed.

stdlib/std/io/file.lyr:61

writeBytes function

pub fn writeBytes(path: string, data: uint8[]): bool

Writes raw bytes, replacing an existing file. true on success — the writeText convention. (v1.14: the first native whose parameter is an array.)

stdlib/std/io/file.lyr:65

appendBytes function

pub fn appendBytes(path: string, data: uint8[]): bool

Appends raw bytes to an existing file or creates it. true on success.

stdlib/std/io/file.lyr:68

textOrThrow function

pub fn textOrThrow(path: string): string throws IoError

text, with the reason when it cannot: the content, or an IoError saying why not.

stdlib/std/io/file.lyr:91

bytesOrThrow function

pub fn bytesOrThrow(path: string): uint8[] throws IoError

bytes, with the reason when it cannot.

stdlib/std/io/file.lyr:100

linesOrThrow function

pub fn linesOrThrow(path: string): string[] throws IoError

lines, with the reason when it cannot.

stdlib/std/io/file.lyr:109

sizeOrThrow function

pub fn sizeOrThrow(path: string): int throws IoError

size, with the reason when it cannot.

stdlib/std/io/file.lyr:118

entriesOrThrow function

pub fn entriesOrThrow(path: string): string[] throws IoError

entries, with the reason when it cannot.

stdlib/std/io/file.lyr:127

writeTextOrThrow function

pub fn writeTextOrThrow(path: string, content: string): void throws IoError

writeText, with the reason when it cannot.

stdlib/std/io/file.lyr:140

appendTextOrThrow function

pub fn appendTextOrThrow(path: string, content: string): void throws IoError

appendText, with the reason when it cannot.

stdlib/std/io/file.lyr:147

writeBytesOrThrow function

pub fn writeBytesOrThrow(path: string, data: uint8[]): void throws IoError

writeBytes, with the reason when it cannot.

stdlib/std/io/file.lyr:154

appendBytesOrThrow function

pub fn appendBytesOrThrow(path: string, data: uint8[]): void throws IoError

appendBytes, with the reason when it cannot.

stdlib/std/io/file.lyr:161

removeOrThrow function

pub fn removeOrThrow(path: string): void throws IoError

remove, with the reason when it cannot. A file that never existed is still success, as in remove — the twin throws exactly where the silent form answers false.

stdlib/std/io/file.lyr:169

copyOrThrow function

pub fn copyOrThrow(from: string, to: string): void throws IoError

copy, with the reason when it cannot.

stdlib/std/io/file.lyr:176

moveOrThrow function

pub fn moveOrThrow(from: string, to: string): void throws IoError

move, with the reason when it cannot.

stdlib/std/io/file.lyr:183

createDirOrThrow function

pub fn createDirOrThrow(path: string): void throws IoError

createDir, with the reason when it cannot.

stdlib/std/io/file.lyr:190

createDirAllOrThrow function

pub fn createDirAllOrThrow(path: string): void throws IoError

createDirAll, with the reason when it cannot.

stdlib/std/io/file.lyr:197

removeDirOrThrow function

pub fn removeDirOrThrow(path: string): void throws IoError

removeDir, with the reason when it cannot.

stdlib/std/io/file.lyr:204

size function

pub fn size(path: string): ?int

The size in bytes, or null when the file does not exist.

stdlib/std/io/file.lyr:215

isFile function

pub fn isFile(path: string): bool

Whether the path names an existing FILE.

stdlib/std/io/file.lyr:217

isDirectory function

pub fn isDirectory(path: string): bool

Whether the path names an existing DIRECTORY.

stdlib/std/io/file.lyr:219

copy function

pub fn copy(from: string, to: string): bool

Copies. false when the source is missing or the target is not writable.

stdlib/std/io/file.lyr:222

move function

pub fn move(from: string, to: string): bool

Moves or renames; the same operation on every file system.

stdlib/std/io/file.lyr:225

createDir function

pub fn createDir(path: string): bool

Creates one directory; the parent must exist. createDirAll creates the chain.

stdlib/std/io/file.lyr:228

createDirAll function

pub fn createDirAll(path: string): bool

Creates missing parent directories too. An existing directory counts as success.

stdlib/std/io/file.lyr:231

removeDir function

pub fn removeDir(path: string): bool

Deletes an EMPTY directory. There is no recursive delete; a caller that needs one writes the loop visibly.

stdlib/std/io/file.lyr:235

entries function

pub fn entries(path: string): ?string[]

The entries of a directory: names rather than paths, sorted alphabetically. null when the directory cannot be read; an EMPTY array is an empty directory — the 2.14 convention, which listDir predates.

stdlib/std/io/file.lyr:240

tempDir function

pub fn tempDir(): string

A path in the system's temporary directory. Does NOT create the file.

stdlib/std/io/file.lyr:247