aboutsummaryrefslogtreecommitdiff
path: root/std/prelude/io.pk
blob: d44f403f6261d2ae3fed2dc7417e333642f0130b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## std.io: Platform-independent I/O constructs. Mostly revolves around files.
## This module is imported by default.
# reference: https://nim-lang.org/docs/syncio.html
# reference: https://doc.rust-lang.org/stable/std/io/

pub type File = ...
pub type FileMode = enum[Read, Write, ReadWrite, Append]

# todo: file destructors call `close`

pub const stdout: File = ...
pub const stdin: File = ...
pub const stderr: File = ...

pub func open(path: str, mode: FileMode): File =
  ...

pub func close(file: owned File) =
  ...

pub func write(file: File, values: varargs[str]) =
  ...

pub func read(file: File): str? =
  ...

pub func lines(file: File): Iter[str] =
  ...

pub func chars(file: File): Iter[char] =
  ...

pub func exists(file: File): bool =
  ...

pub func hidden(file: File): bool =
  ...

pub func size(file: File): uint =
  ...

pub func dir(file: File): str =
  ...

pub func path(file: File): str =
  ...