lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
// Generated by Lisette bindgen
// Source: os (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

import "go:io"
import "go:io/fs"
import "go:syscall"
import "go:time"

/// Chdir changes the current working directory to the named directory.
/// If there is an error, it will be of type [*PathError].
pub fn Chdir(dir: string) -> Result<(), error>

/// Chmod changes the mode of the named file to mode.
/// If the file is a symbolic link, it changes the mode of the link's target.
/// If there is an error, it will be of type [*PathError].
/// 
/// A different subset of the mode bits are used, depending on the
/// operating system.
/// 
/// On Unix, the mode's permission bits, [ModeSetuid], [ModeSetgid], and
/// [ModeSticky] are used.
/// 
/// On Windows, only the 0o200 bit (owner writable) of mode is used; it
/// controls whether the file's read-only attribute is set or cleared.
/// The other bits are currently unused. For compatibility with Go 1.12
/// and earlier, use a non-zero mode. Use mode 0o400 for a read-only
/// file and 0o600 for a readable+writable file.
/// 
/// On Plan 9, the mode's permission bits, [ModeAppend], [ModeExclusive],
/// and [ModeTemporary] are used.
pub fn Chmod(name: string, mode: fs.FileMode) -> Result<(), error>

/// Chown changes the numeric uid and gid of the named file.
/// If the file is a symbolic link, it changes the uid and gid of the link's target.
/// A uid or gid of -1 means to not change that value.
/// If there is an error, it will be of type [*PathError].
/// 
/// On Windows or Plan 9, Chown always returns the [syscall.EWINDOWS] or
/// [syscall.EPLAN9] error, wrapped in [*PathError].
pub fn Chown(name: string, uid: int, gid: int) -> Result<(), error>

/// Chtimes changes the access and modification times of the named
/// file, similar to the Unix utime() or utimes() functions.
/// A zero [time.Time] value will leave the corresponding file time unchanged.
/// 
/// The underlying filesystem may truncate or round the values to a
/// less precise time unit.
/// If there is an error, it will be of type [*PathError].
pub fn Chtimes(name: string, atime: time.Time, mtime: time.Time) -> Result<(), error>

/// Clearenv deletes all environment variables.
pub fn Clearenv()

/// CopyFS copies the file system fsys into the directory dir,
/// creating dir if necessary.
/// 
/// Files are created with mode 0o666 plus any execute permissions
/// from the source, and directories are created with mode 0o777
/// (before umask).
/// 
/// CopyFS will not overwrite existing files. If a file name in fsys
/// already exists in the destination, CopyFS will return an error
/// such that errors.Is(err, fs.ErrExist) will be true.
/// 
/// Symbolic links in dir are followed.
/// 
/// New files added to fsys (including if dir is a subdirectory of fsys)
/// while CopyFS is running are not guaranteed to be copied.
/// 
/// Copying stops at and returns the first error encountered.
pub fn CopyFS(dir: string, fsys: fs.FS) -> Result<(), error>

pub fn Create(name: string) -> Result<Ref<File>, error>

pub fn CreateTemp(dir: string, pattern: string) -> Result<Ref<File>, error>

/// DirFS returns a file system (an fs.FS) for the tree of files rooted at the directory dir.
/// 
/// Note that DirFS("/prefix") only guarantees that the Open calls it makes to the
/// operating system will begin with "/prefix": DirFS("/prefix").Open("file") is the
/// same as os.Open("/prefix/file"). So if /prefix/file is a symbolic link pointing outside
/// the /prefix tree, then using DirFS does not stop the access any more than using
/// os.Open does. Additionally, the root of the fs.FS returned for a relative path,
/// DirFS("prefix"), will be affected by later calls to Chdir. DirFS is therefore not
/// a general substitute for a chroot-style security mechanism when the directory tree
/// contains arbitrary content.
/// 
/// Use [Root.FS] to obtain a fs.FS that prevents escapes from the tree via symbolic links.
/// 
/// The directory dir must not be "".
/// 
/// The result implements [io/fs.StatFS], [io/fs.ReadFileFS], [io/fs.ReadDirFS], and
/// [io/fs.ReadLinkFS].
pub fn DirFS(dir: string) -> fs.FS

/// Environ returns a copy of strings representing the environment,
/// in the form "key=value".
pub fn Environ() -> Slice<string>

/// Executable returns the path name for the executable that started
/// the current process. There is no guarantee that the path is still
/// pointing to the correct executable. If a symlink was used to start
/// the process, depending on the operating system, the result might
/// be the symlink or the path it pointed to. If a stable result is
/// needed, [path/filepath.EvalSymlinks] might help.
/// 
/// Executable returns an absolute path unless an error occurred.
/// 
/// The main use case is finding resources located relative to an
/// executable.
pub fn Executable() -> Result<string, error>

/// Exit causes the current program to exit with the given status code.
/// Conventionally, code zero indicates success, non-zero an error.
/// The program terminates immediately; deferred functions are not run.
/// 
/// For portability, the status code should be in the range [0, 125].
pub fn Exit(code: int) -> Never

/// Expand replaces ${var} or $var in the string based on the mapping function.
/// For example, [os.ExpandEnv](s) is equivalent to [os.Expand](s, [os.Getenv]).
pub fn Expand(s: string, mapping: fn(string) -> string) -> string

/// ExpandEnv replaces ${var} or $var in the string according to the values
/// of the current environment variables. References to undefined
/// variables are replaced by the empty string.
pub fn ExpandEnv(s: string) -> string

pub fn FindProcess(pid: int) -> Result<Ref<Process>, error>

/// Getegid returns the numeric effective group id of the caller.
/// 
/// On Windows, it returns -1.
pub fn Getegid() -> int

/// Getenv retrieves the value of the environment variable named by the key.
/// It returns the value, which will be empty if the variable is not present.
/// To distinguish between an empty value and an unset value, use [LookupEnv].
pub fn Getenv(key: string) -> string

/// Geteuid returns the numeric effective user id of the caller.
/// 
/// On Windows, it returns -1.
pub fn Geteuid() -> int

/// Getgid returns the numeric group id of the caller.
/// 
/// On Windows, it returns -1.
pub fn Getgid() -> int

/// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
/// 
/// On Windows, it returns [syscall.EWINDOWS]. See the [os/user] package
/// for a possible alternative.
pub fn Getgroups() -> Result<Slice<int>, error>

/// Getpagesize returns the underlying system's memory page size.
pub fn Getpagesize() -> int

/// Getpid returns the process id of the caller.
pub fn Getpid() -> int

/// Getppid returns the process id of the caller's parent.
pub fn Getppid() -> int

/// Getuid returns the numeric user id of the caller.
/// 
/// On Windows, it returns -1.
pub fn Getuid() -> int

/// Getwd returns an absolute path name corresponding to the
/// current directory. If the current directory can be
/// reached via multiple paths (due to symbolic links),
/// Getwd may return any one of them.
/// 
/// On Unix platforms, if the environment variable PWD
/// provides an absolute name, and it is a name of the
/// current directory, it is returned.
pub fn Getwd() -> Result<string, error>

/// Hostname returns the host name reported by the kernel.
pub fn Hostname() -> Result<string, error>

/// IsExist returns a boolean indicating whether its argument is known to report
/// that a file or directory already exists. It is satisfied by [ErrExist] as
/// well as some syscall errors.
/// 
/// This function predates [errors.Is]. It only supports errors returned by
/// the os package. New code should use errors.Is(err, fs.ErrExist).
pub fn IsExist(err: error) -> bool

/// IsNotExist returns a boolean indicating whether its argument is known to
/// report that a file or directory does not exist. It is satisfied by
/// [ErrNotExist] as well as some syscall errors.
/// 
/// This function predates [errors.Is]. It only supports errors returned by
/// the os package. New code should use errors.Is(err, fs.ErrNotExist).
pub fn IsNotExist(err: error) -> bool

/// IsPathSeparator reports whether c is a directory separator character.
pub fn IsPathSeparator(c: uint8) -> bool

/// IsPermission returns a boolean indicating whether its argument is known to
/// report that permission is denied. It is satisfied by [ErrPermission] as well
/// as some syscall errors.
/// 
/// This function predates [errors.Is]. It only supports errors returned by
/// the os package. New code should use errors.Is(err, fs.ErrPermission).
pub fn IsPermission(err: error) -> bool

/// IsTimeout returns a boolean indicating whether its argument is known
/// to report that a timeout occurred.
/// 
/// This function predates [errors.Is], and the notion of whether an
/// error indicates a timeout can be ambiguous. For example, the Unix
/// error EWOULDBLOCK sometimes indicates a timeout and sometimes does not.
/// New code should use errors.Is with a value appropriate to the call
/// returning the error, such as [os.ErrDeadlineExceeded].
pub fn IsTimeout(err: error) -> bool

/// Lchown changes the numeric uid and gid of the named file.
/// If the file is a symbolic link, it changes the uid and gid of the link itself.
/// If there is an error, it will be of type [*PathError].
/// 
/// On Windows, it always returns the [syscall.EWINDOWS] error, wrapped
/// in [*PathError].
pub fn Lchown(name: string, uid: int, gid: int) -> Result<(), error>

/// Link creates newname as a hard link to the oldname file.
/// If there is an error, it will be of type *LinkError.
pub fn Link(oldname: string, newname: string) -> Result<(), error>

/// LookupEnv retrieves the value of the environment variable named
/// by the key. If the variable is present in the environment the
/// value (which may be empty) is returned and the boolean is true.
/// Otherwise the returned value will be empty and the boolean will
/// be false.
pub fn LookupEnv(key: string) -> Option<string>

pub fn Lstat(name: string) -> Result<fs.FileInfo, error>

/// Mkdir creates a new directory with the specified name and permission
/// bits (before umask).
/// If there is an error, it will be of type [*PathError].
pub fn Mkdir(name: string, perm: fs.FileMode) -> Result<(), error>

/// MkdirAll creates a directory named path,
/// along with any necessary parents, and returns nil,
/// or else returns an error.
/// The permission bits perm (before umask) are used for all
/// directories that MkdirAll creates.
/// If path is already a directory, MkdirAll does nothing
/// and returns nil.
pub fn MkdirAll(path: string, perm: fs.FileMode) -> Result<(), error>

/// MkdirTemp creates a new temporary directory in the directory dir
/// and returns the pathname of the new directory.
/// The new directory's name is generated by adding a random string to the end of pattern.
/// If pattern includes a "*", the random string replaces the last "*" instead.
/// The directory is created with mode 0o700 (before umask).
/// If dir is the empty string, MkdirTemp uses the default directory for temporary files, as returned by TempDir.
/// Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory.
/// It is the caller's responsibility to remove the directory when it is no longer needed.
pub fn MkdirTemp(dir: string, pattern: string) -> Result<string, error>

pub fn NewFile(fd: uint, name: string) -> Option<Ref<File>>

/// NewSyscallError returns, as an error, a new [SyscallError]
/// with the given system call name and error details.
/// As a convenience, if err is nil, NewSyscallError returns nil.
pub fn NewSyscallError(syscall: string, err: error) -> Option<error>

pub fn Open(name: string) -> Result<Ref<File>, error>

pub fn OpenFile(name: string, flag: int, perm: fs.FileMode) -> Result<Ref<File>, error>

pub fn OpenInRoot(dir: string, name: string) -> Result<Ref<File>, error>

pub fn OpenRoot(name: string) -> Result<Ref<Root>, error>

/// Pipe returns a connected pair of Files; reads from r return bytes written to w.
/// It returns the files and an error, if any.
pub fn Pipe() -> Result<(Ref<File>, Ref<File>), error>

pub fn ReadDir(name: string) -> Result<Slice<fs.DirEntry>, error>

/// ReadFile reads the named file and returns the contents.
/// A successful call returns err == nil, not err == EOF.
/// Because ReadFile reads the whole file, it does not treat an EOF from Read
/// as an error to be reported.
pub fn ReadFile(name: string) -> Result<Slice<uint8>, error>

/// Readlink returns the destination of the named symbolic link.
/// If there is an error, it will be of type [*PathError].
/// 
/// If the link destination is relative, Readlink returns the relative path
/// without resolving it to an absolute one.
pub fn Readlink(name: string) -> Result<string, error>

/// Remove removes the named file or (empty) directory.
/// If there is an error, it will be of type [*PathError].
pub fn Remove(name: string) -> Result<(), error>

/// RemoveAll removes path and any children it contains.
/// It removes everything it can but returns the first error
/// it encounters. If the path does not exist, RemoveAll
/// returns nil (no error).
/// If there is an error, it will be of type [*PathError].
pub fn RemoveAll(path: string) -> Result<(), error>

/// Rename renames (moves) oldpath to newpath.
/// If newpath already exists and is not a directory, Rename replaces it.
/// If newpath already exists and is a directory, Rename returns an error.
/// OS-specific restrictions may apply when oldpath and newpath are in different directories.
/// Even within the same directory, on non-Unix platforms Rename is not an atomic operation.
/// If there is an error, it will be of type *LinkError.
pub fn Rename(oldpath: string, newpath: string) -> Result<(), error>

/// SameFile reports whether fi1 and fi2 describe the same file.
/// For example, on Unix this means that the device and inode fields
/// of the two underlying structures are identical; on other systems
/// the decision may be based on the path names.
/// SameFile only applies to results returned by this package's [Stat].
/// It returns false in other cases.
pub fn SameFile(fi1: fs.FileInfo, fi2: fs.FileInfo) -> bool

/// Setenv sets the value of the environment variable named by the key.
/// It returns an error, if any.
pub fn Setenv(key: string, value: string) -> Result<(), error>

pub fn StartProcess(name: string, argv: Slice<string>, attr: Ref<ProcAttr>) -> Result<Ref<Process>, error>

pub fn Stat(name: string) -> Result<fs.FileInfo, error>

/// Symlink creates newname as a symbolic link to oldname.
/// On Windows, a symlink to a non-existent oldname creates a file symlink;
/// if oldname is later created as a directory the symlink will not work.
/// If there is an error, it will be of type *LinkError.
pub fn Symlink(oldname: string, newname: string) -> Result<(), error>

/// TempDir returns the default directory to use for temporary files.
/// 
/// On Unix systems, it returns $TMPDIR if non-empty, else /tmp.
/// On Windows, it uses GetTempPath, returning the first non-empty
/// value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.
/// On Plan 9, it returns /tmp.
/// 
/// The directory is neither guaranteed to exist nor have accessible
/// permissions.
pub fn TempDir() -> string

/// Truncate changes the size of the named file.
/// If the file is a symbolic link, it changes the size of the link's target.
/// If there is an error, it will be of type [*PathError].
pub fn Truncate(name: string, size: int64) -> Result<(), error>

/// Unsetenv unsets a single environment variable.
pub fn Unsetenv(key: string) -> Result<(), error>

/// UserCacheDir returns the default root directory to use for user-specific
/// cached data. Users should create their own application-specific subdirectory
/// within this one and use that.
/// 
/// On Unix systems, it returns $XDG_CACHE_HOME as specified by
/// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if
/// non-empty, else $HOME/.cache.
/// On Darwin, it returns $HOME/Library/Caches.
/// On Windows, it returns %LocalAppData%.
/// On Plan 9, it returns $home/lib/cache.
/// 
/// If the location cannot be determined (for example, $HOME is not defined) or
/// the path in $XDG_CACHE_HOME is relative, then it will return an error.
pub fn UserCacheDir() -> Result<string, error>

/// UserConfigDir returns the default root directory to use for user-specific
/// configuration data. Users should create their own application-specific
/// subdirectory within this one and use that.
/// 
/// On Unix systems, it returns $XDG_CONFIG_HOME as specified by
/// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if
/// non-empty, else $HOME/.config.
/// On Darwin, it returns $HOME/Library/Application Support.
/// On Windows, it returns %AppData%.
/// On Plan 9, it returns $home/lib.
/// 
/// If the location cannot be determined (for example, $HOME is not defined) or
/// the path in $XDG_CONFIG_HOME is relative, then it will return an error.
pub fn UserConfigDir() -> Result<string, error>

/// UserHomeDir returns the current user's home directory.
/// 
/// On Unix, including macOS, it returns the $HOME environment variable.
/// On Windows, it returns %USERPROFILE%.
/// On Plan 9, it returns the $home environment variable.
/// 
/// If the expected variable is not set in the environment, UserHomeDir
/// returns either a platform-specific default value or a non-nil error.
pub fn UserHomeDir() -> Result<string, error>

/// WriteFile writes data to the named file, creating it if necessary.
/// If the file does not exist, WriteFile creates it with permissions perm (before umask);
/// otherwise WriteFile truncates it before writing, without changing permissions.
/// Since WriteFile requires multiple system calls to complete, a failure mid-operation
/// can leave the file in a partially written state.
pub fn WriteFile(name: string, data: Slice<uint8>, perm: fs.FileMode) -> Result<(), error>

/// A DirEntry is an entry read from a directory
/// (using the [ReadDir] function or a [File.ReadDir] method).
pub type DirEntry = fs.DirEntry

/// File represents an open file descriptor.
/// 
/// The methods of File are safe for concurrent use.
pub type File

/// A FileInfo describes a file and is returned by [Stat] and [Lstat].
pub type FileInfo = fs.FileInfo

/// A FileMode represents a file's mode and permission bits.
/// The bits have the same definition on all systems, so that
/// information about files can be moved from one system
/// to another portably. Not all bits apply to all systems.
/// The only required bit is [ModeDir] for directories.
pub type FileMode = fs.FileMode

/// LinkError records an error during a link or symlink or rename
/// system call and the paths that caused it.
pub struct LinkError {
  pub Op: string,
  pub Old: string,
  pub New: string,
  pub Err: error,
}

/// PathError records an error and the operation and file path that caused it.
pub type PathError = fs.PathError

/// ProcAttr holds the attributes that will be applied to a new process
/// started by StartProcess.
pub struct ProcAttr {
  pub Dir: string,
  pub Env: Slice<string>,
  pub Files: Slice<Option<Ref<File>>>,
  pub Sys: Option<Ref<syscall.SysProcAttr>>,
}

/// Process stores the information about a process created by [StartProcess].
pub struct Process {
  pub Pid: int,
}

/// ProcessState stores information about a process, as reported by Wait.
pub type ProcessState

/// Root may be used to only access files within a single directory tree.
/// 
/// Methods on Root can only access files and directories beneath a root directory.
/// If any component of a file name passed to a method of Root references a location
/// outside the root, the method returns an error.
/// File names may reference the directory itself (.).
/// 
/// Methods on Root will follow symbolic links, but symbolic links may not
/// reference a location outside the root.
/// Symbolic links must not be absolute.
/// 
/// Methods on Root do not prohibit traversal of filesystem boundaries,
/// Linux bind mounts, /proc special files, or access to Unix device files.
/// 
/// Methods on Root are safe to be used from multiple goroutines simultaneously.
/// 
/// On most platforms, creating a Root opens a file descriptor or handle referencing
/// the directory. If the directory is moved, methods on Root reference the original
/// directory in its new location.
/// 
/// Root's behavior differs on some platforms:
/// 
///   - When GOOS=windows, file names may not reference Windows reserved device names
///     such as NUL and COM1.
///   - On Unix, [Root.Chmod], [Root.Chown], and [Root.Chtimes] are vulnerable to a race condition.
///     If the target of the operation is changed from a regular file to a symlink
///     while the operation is in progress, the operation may be performed on the link
///     rather than the link target.
///   - When GOOS=js, Root is vulnerable to TOCTOU (time-of-check-time-of-use)
///     attacks in symlink validation, and cannot ensure that operations will not
///     escape the root.
///   - When GOOS=plan9 or GOOS=js, Root does not track directories across renames.
///     On these platforms, a Root references a directory name, not a file descriptor.
///   - WASI preview 1 (GOOS=wasip1) does not support [Root.Chmod].
pub type Root

/// A Signal represents an operating system signal.
/// The usual underlying implementation is operating system-dependent:
/// on Unix it is syscall.Signal.
pub interface Signal {
  fn Signal()
  fn String() -> string
}

/// SyscallError records an error from a specific system call.
pub struct SyscallError {
  pub Syscall: string,
  pub Err: error,
}

/// DevNull is the name of the operating system's “null device.”
/// On Unix-like systems, it is "/dev/null"; on Windows, "NUL".
const DevNull = "/dev/null"

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeAppend: fs.FileMode = 1073741824

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeCharDevice: fs.FileMode = 2097152

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeDevice: fs.FileMode = 67108864

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeDir: fs.FileMode = 2147483648

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeExclusive: fs.FileMode = 536870912

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeIrregular: fs.FileMode = 524288

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeNamedPipe: fs.FileMode = 33554432

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModePerm: fs.FileMode = 511

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeSetgid: fs.FileMode = 4194304

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeSetuid: fs.FileMode = 8388608

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeSocket: fs.FileMode = 16777216

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeSticky: fs.FileMode = 1048576

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeSymlink: fs.FileMode = 134217728

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeTemporary: fs.FileMode = 268435456

/// The defined file mode bits are the most significant bits of the [FileMode].
/// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
/// The values of these bits should be considered part of the public API and
/// may be used in wire protocols or disk representations: they must not be
/// changed, although new bits might be added.
const ModeType: fs.FileMode = 2401763328

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_APPEND = 8

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_CREATE = 512

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_EXCL = 2048

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_RDONLY = 0

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_RDWR = 2

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_SYNC = 128

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_TRUNC = 1024

/// Flags to OpenFile wrapping those of the underlying system. Not all
/// flags may be implemented on a given system.
const O_WRONLY = 1

const PathListSeparator = 58

const PathSeparator = 47

/// Seek whence values.
/// 
/// Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
const SEEK_CUR = 1

/// Seek whence values.
/// 
/// Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
const SEEK_END = 2

/// Seek whence values.
/// 
/// Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.
const SEEK_SET = 0

/// Args hold the command-line arguments, starting with the program name.
pub var Args: Slice<string>

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrClosed: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrDeadlineExceeded: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrExist: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrInvalid: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrNoDeadline: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrNotExist: error

/// Portable analogs of some common system call errors.
/// 
/// Errors returned from this package may be tested against these errors
/// with [errors.Is].
pub var ErrPermission: error

/// ErrProcessDone indicates a [Process] has finished.
pub var ErrProcessDone: error

pub var Interrupt: Signal

pub var Kill: Signal

/// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
/// standard output, and standard error file descriptors.
/// 
/// Note that the Go runtime writes to standard error for panics and crashes;
/// closing Stderr may cause those messages to go elsewhere, perhaps
/// to a file opened later.
pub var Stderr: Ref<File>

/// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
/// standard output, and standard error file descriptors.
/// 
/// Note that the Go runtime writes to standard error for panics and crashes;
/// closing Stderr may cause those messages to go elsewhere, perhaps
/// to a file opened later.
pub var Stdin: Ref<File>

/// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
/// standard output, and standard error file descriptors.
/// 
/// Note that the Go runtime writes to standard error for panics and crashes;
/// closing Stderr may cause those messages to go elsewhere, perhaps
/// to a file opened later.
pub var Stdout: Ref<File>

impl File {
  /// Chdir changes the current working directory to the file,
  /// which must be a directory.
  /// If there is an error, it will be of type [*PathError].
  fn Chdir(self: Ref<File>) -> Result<(), error>

  /// Chmod changes the mode of the file to mode.
  /// If there is an error, it will be of type [*PathError].
  fn Chmod(self: Ref<File>, mode: fs.FileMode) -> Result<(), error>

  /// Chown changes the numeric uid and gid of the named file.
  /// If there is an error, it will be of type [*PathError].
  /// 
  /// On Windows, it always returns the [syscall.EWINDOWS] error, wrapped
  /// in [*PathError].
  fn Chown(self: Ref<File>, uid: int, gid: int) -> Result<(), error>

  /// Close closes the [File], rendering it unusable for I/O.
  /// On files that support [File.SetDeadline], any pending I/O operations will
  /// be canceled and return immediately with an [ErrClosed] error.
  /// Close will return an error if it has already been called.
  #[allow(unused_result)]
  fn Close(self: Ref<File>) -> Result<(), error>

  /// Fd returns the system file descriptor or handle referencing the open file.
  /// If f is closed, the descriptor becomes invalid.
  /// If f is garbage collected, a finalizer may close the descriptor,
  /// making it invalid; see [runtime.SetFinalizer] for more information on when
  /// a finalizer might be run.
  /// 
  /// Do not close the returned descriptor; that could cause a later
  /// close of f to close an unrelated descriptor.
  /// 
  /// Fd's behavior differs on some platforms:
  /// 
  ///   - On Unix and Windows, [File.SetDeadline] methods will stop working.
  ///   - On Windows, the file descriptor will be disassociated from the
  ///     Go runtime I/O completion port if there are no concurrent I/O
  ///     operations on the file.
  /// 
  /// For most uses prefer the f.SyscallConn method.
  fn Fd(self: Ref<File>) -> uint

  /// Name returns the name of the file as presented to Open.
  /// 
  /// It is safe to call Name after [Close].
  fn Name(self: Ref<File>) -> string

  /// Read reads up to len(b) bytes from the File and stores them in b.
  /// It returns the number of bytes read and any error encountered.
  /// At end of file, Read returns 0, io.EOF.
  fn Read(self: Ref<File>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadAt reads len(b) bytes from the File starting at byte offset off.
  /// It returns the number of bytes read and the error, if any.
  /// ReadAt always returns a non-nil error when n < len(b).
  /// At end of file, that error is io.EOF.
  fn ReadAt(self: Ref<File>, mut b: Slice<uint8>, off: int64) -> Partial<int, error>

  /// ReadDir reads the contents of the directory associated with the file f
  /// and returns a slice of [DirEntry] values in directory order.
  /// Subsequent calls on the same file will yield later DirEntry records in the directory.
  /// 
  /// If n > 0, ReadDir returns at most n DirEntry records.
  /// In this case, if ReadDir returns an empty slice, it will return an error explaining why.
  /// At the end of a directory, the error is [io.EOF].
  /// 
  /// If n <= 0, ReadDir returns all the DirEntry records remaining in the directory.
  /// When it succeeds, it returns a nil error (not io.EOF).
  fn ReadDir(self: Ref<File>, n: int) -> Result<Slice<fs.DirEntry>, error>

  /// ReadFrom implements io.ReaderFrom.
  fn ReadFrom(self: Ref<File>, r: io.Reader) -> Result<int64, error>

  /// Readdir reads the contents of the directory associated with file and
  /// returns a slice of up to n [FileInfo] values, as would be returned
  /// by [Lstat], in directory order. Subsequent calls on the same file will yield
  /// further FileInfos.
  /// 
  /// If n > 0, Readdir returns at most n FileInfo structures. In this case, if
  /// Readdir returns an empty slice, it will return a non-nil error
  /// explaining why. At the end of a directory, the error is [io.EOF].
  /// 
  /// If n <= 0, Readdir returns all the FileInfo from the directory in
  /// a single slice. In this case, if Readdir succeeds (reads all
  /// the way to the end of the directory), it returns the slice and a
  /// nil error. If it encounters an error before the end of the
  /// directory, Readdir returns the FileInfo read until that point
  /// and a non-nil error.
  /// 
  /// Most clients are better served by the more efficient ReadDir method.
  fn Readdir(self: Ref<File>, n: int) -> Result<Slice<fs.FileInfo>, error>

  /// Readdirnames reads the contents of the directory associated with file
  /// and returns a slice of up to n names of files in the directory,
  /// in directory order. Subsequent calls on the same file will yield
  /// further names.
  /// 
  /// If n > 0, Readdirnames returns at most n names. In this case, if
  /// Readdirnames returns an empty slice, it will return a non-nil error
  /// explaining why. At the end of a directory, the error is [io.EOF].
  /// 
  /// If n <= 0, Readdirnames returns all the names from the directory in
  /// a single slice. In this case, if Readdirnames succeeds (reads all
  /// the way to the end of the directory), it returns the slice and a
  /// nil error. If it encounters an error before the end of the
  /// directory, Readdirnames returns the names read until that point and
  /// a non-nil error.
  fn Readdirnames(self: Ref<File>, n: int) -> Result<Slice<string>, error>

  /// Seek sets the offset for the next Read or Write on file to offset, interpreted
  /// according to whence: 0 means relative to the origin of the file, 1 means
  /// relative to the current offset, and 2 means relative to the end.
  /// It returns the new offset and an error, if any.
  /// The behavior of Seek on a file opened with [O_APPEND] is not specified.
  fn Seek(self: Ref<File>, offset: int64, whence: int) -> Result<int64, error>

  /// SetDeadline sets the read and write deadlines for a File.
  /// It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
  /// 
  /// Only some kinds of files support setting a deadline. Calls to SetDeadline
  /// for files that do not support deadlines will return ErrNoDeadline.
  /// On most systems ordinary files do not support deadlines, but pipes do.
  /// 
  /// A deadline is an absolute time after which I/O operations fail with an
  /// error instead of blocking. The deadline applies to all future and pending
  /// I/O, not just the immediately following call to Read or Write.
  /// After a deadline has been exceeded, the connection can be refreshed
  /// by setting a deadline in the future.
  /// 
  /// If the deadline is exceeded a call to Read or Write or to other I/O
  /// methods will return an error that wraps ErrDeadlineExceeded.
  /// This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
  /// That error implements the Timeout method, and calling the Timeout
  /// method will return true, but there are other possible errors for which
  /// the Timeout will return true even if the deadline has not been exceeded.
  /// 
  /// An idle timeout can be implemented by repeatedly extending
  /// the deadline after successful Read or Write calls.
  /// 
  /// A zero value for t means I/O operations will not time out.
  fn SetDeadline(self: Ref<File>, t: time.Time) -> Result<(), error>

  /// SetReadDeadline sets the deadline for future Read calls and any
  /// currently-blocked Read call.
  /// A zero value for t means Read will not time out.
  /// Not all files support setting deadlines; see SetDeadline.
  fn SetReadDeadline(self: Ref<File>, t: time.Time) -> Result<(), error>

  /// SetWriteDeadline sets the deadline for any future Write calls and any
  /// currently-blocked Write call.
  /// Even if Write times out, it may return n > 0, indicating that
  /// some of the data was successfully written.
  /// A zero value for t means Write will not time out.
  /// Not all files support setting deadlines; see SetDeadline.
  fn SetWriteDeadline(self: Ref<File>, t: time.Time) -> Result<(), error>

  /// Stat returns the [FileInfo] structure describing file.
  /// If there is an error, it will be of type [*PathError].
  fn Stat(self: Ref<File>) -> Result<fs.FileInfo, error>

  /// Sync commits the current contents of the file to stable storage.
  /// Typically, this means flushing the file system's in-memory copy
  /// of recently written data to disk.
  fn Sync(self: Ref<File>) -> Result<(), error>

  /// SyscallConn returns a raw file.
  /// This implements the syscall.Conn interface.
  fn SyscallConn(self: Ref<File>) -> Result<syscall.RawConn, error>

  /// Truncate changes the size of the file.
  /// It does not change the I/O offset.
  /// If there is an error, it will be of type [*PathError].
  fn Truncate(self: Ref<File>, size: int64) -> Result<(), error>

  /// Write writes len(b) bytes from b to the File.
  /// It returns the number of bytes written and an error, if any.
  /// Write returns a non-nil error when n != len(b).
  fn Write(self: Ref<File>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteAt writes len(b) bytes to the File starting at byte offset off.
  /// It returns the number of bytes written and an error, if any.
  /// WriteAt returns a non-nil error when n != len(b).
  /// 
  /// If file was opened with the [O_APPEND] flag, WriteAt returns an error.
  fn WriteAt(self: Ref<File>, b: Slice<uint8>, off: int64) -> Partial<int, error>

  /// WriteString is like Write, but writes the contents of string s rather than
  /// a slice of bytes.
  fn WriteString(self: Ref<File>, s: string) -> Result<int, error>

  /// WriteTo implements io.WriterTo.
  fn WriteTo(self: Ref<File>, w: io.Writer) -> Result<int64, error>
}

impl LinkError {
  fn Error(self: Ref<LinkError>) -> string

  fn Unwrap(self: Ref<LinkError>) -> Option<error>
}

impl Process {
  /// Kill causes the [Process] to exit immediately. Kill does not wait until
  /// the Process has actually exited. This only kills the Process itself,
  /// not any other processes it may have started.
  fn Kill(self: Ref<Process>) -> Result<(), error>

  /// Release releases any resources associated with the [Process] p,
  /// rendering it unusable in the future.
  /// Release only needs to be called if [Process.Wait] is not.
  fn Release(self: Ref<Process>) -> Result<(), error>

  /// Signal sends a signal to the [Process].
  /// Sending [Interrupt] on Windows is not implemented.
  fn Signal(self: Ref<Process>, sig: Signal) -> Result<(), error>

  /// Wait waits for the [Process] to exit, and then returns a
  /// ProcessState describing its status and an error, if any.
  /// Wait releases any resources associated with the Process.
  /// On most operating systems, the Process must be a child
  /// of the current process or an error will be returned.
  fn Wait(self: Ref<Process>) -> Result<Ref<ProcessState>, error>
}

impl ProcessState {
  /// ExitCode returns the exit code of the exited process, or -1
  /// if the process hasn't exited or was terminated by a signal.
  fn ExitCode(self: Ref<ProcessState>) -> int

  /// Exited reports whether the program has exited.
  /// On Unix systems this reports true if the program exited due to calling exit,
  /// but false if the program terminated due to a signal.
  fn Exited(self: Ref<ProcessState>) -> bool

  /// Pid returns the process id of the exited process.
  fn Pid(self: Ref<ProcessState>) -> int

  fn String(self: Ref<ProcessState>) -> string

  /// Success reports whether the program exited successfully,
  /// such as with exit status 0 on Unix.
  fn Success(self: Ref<ProcessState>) -> bool

  /// Sys returns system-dependent exit information about
  /// the process. Convert it to the appropriate underlying
  /// type, such as [syscall.WaitStatus] on Unix, to access its contents.
  fn Sys(self: Ref<ProcessState>) -> Unknown

  /// SysUsage returns system-dependent resource usage information about
  /// the exited process. Convert it to the appropriate underlying
  /// type, such as [*syscall.Rusage] on Unix, to access its contents.
  /// (On Unix, *syscall.Rusage matches struct rusage as defined in the
  /// getrusage(2) manual page.)
  fn SysUsage(self: Ref<ProcessState>) -> Unknown

  /// SystemTime returns the system CPU time of the exited process and its children.
  fn SystemTime(self: Ref<ProcessState>) -> time.Duration

  /// UserTime returns the user CPU time of the exited process and its children.
  fn UserTime(self: Ref<ProcessState>) -> time.Duration
}

impl Root {
  /// Chmod changes the mode of the named file in the root to mode.
  /// See [Chmod] for more details.
  fn Chmod(self: Ref<Root>, name: string, mode: fs.FileMode) -> Result<(), error>

  /// Chown changes the numeric uid and gid of the named file in the root.
  /// See [Chown] for more details.
  fn Chown(self: Ref<Root>, name: string, uid: int, gid: int) -> Result<(), error>

  /// Chtimes changes the access and modification times of the named file in the root.
  /// See [Chtimes] for more details.
  fn Chtimes(self: Ref<Root>, name: string, atime: time.Time, mtime: time.Time) -> Result<(), error>

  /// Close closes the Root.
  /// After Close is called, methods on Root return errors.
  #[allow(unused_result)]
  fn Close(self: Ref<Root>) -> Result<(), error>

  /// Create creates or truncates the named file in the root.
  /// See [Create] for more details.
  fn Create(self: Ref<Root>, name: string) -> Result<Ref<File>, error>

  /// FS returns a file system (an fs.FS) for the tree of files in the root.
  /// 
  /// The result implements [io/fs.StatFS], [io/fs.ReadFileFS],
  /// [io/fs.ReadDirFS], and [io/fs.ReadLinkFS].
  fn FS(self: Ref<Root>) -> fs.FS

  /// Lchown changes the numeric uid and gid of the named file in the root.
  /// See [Lchown] for more details.
  fn Lchown(self: Ref<Root>, name: string, uid: int, gid: int) -> Result<(), error>

  /// Link creates newname as a hard link to the oldname file.
  /// Both paths are relative to the root.
  /// See [Link] for more details.
  /// 
  /// If oldname is a symbolic link, Link creates new link to oldname and not its target.
  /// This behavior may differ from that of [Link] on some platforms.
  /// 
  /// When GOOS=js, Link returns an error if oldname is a symbolic link.
  fn Link(self: Ref<Root>, oldname: string, newname: string) -> Result<(), error>

  /// Lstat returns a [FileInfo] describing the named file in the root.
  /// If the file is a symbolic link, the returned FileInfo
  /// describes the symbolic link.
  /// See [Lstat] for more details.
  fn Lstat(self: Ref<Root>, name: string) -> Result<fs.FileInfo, error>

  /// Mkdir creates a new directory in the root
  /// with the specified name and permission bits (before umask).
  /// See [Mkdir] for more details.
  /// 
  /// If perm contains bits other than the nine least-significant bits (0o777),
  /// Mkdir returns an error.
  fn Mkdir(self: Ref<Root>, name: string, perm: fs.FileMode) -> Result<(), error>

  /// MkdirAll creates a new directory in the root, along with any necessary parents.
  /// See [MkdirAll] for more details.
  /// 
  /// If perm contains bits other than the nine least-significant bits (0o777),
  /// MkdirAll returns an error.
  fn MkdirAll(self: Ref<Root>, name: string, perm: fs.FileMode) -> Result<(), error>

  /// Name returns the name of the directory presented to OpenRoot.
  /// 
  /// It is safe to call Name after [Close].
  fn Name(self: Ref<Root>) -> string

  /// Open opens the named file in the root for reading.
  /// See [Open] for more details.
  fn Open(self: Ref<Root>, name: string) -> Result<Ref<File>, error>

  /// OpenFile opens the named file in the root.
  /// See [OpenFile] for more details.
  /// 
  /// If perm contains bits other than the nine least-significant bits (0o777),
  /// OpenFile returns an error.
  fn OpenFile(self: Ref<Root>, name: string, flag: int, perm: fs.FileMode) -> Result<Ref<File>, error>

  /// OpenRoot opens the named directory in the root.
  /// If there is an error, it will be of type [*PathError].
  fn OpenRoot(self: Ref<Root>, name: string) -> Result<Ref<Root>, error>

  /// ReadFile reads the named file in the root and returns its contents.
  /// See [ReadFile] for more details.
  fn ReadFile(self: Ref<Root>, name: string) -> Result<Slice<uint8>, error>

  /// Readlink returns the destination of the named symbolic link in the root.
  /// See [Readlink] for more details.
  fn Readlink(self: Ref<Root>, name: string) -> Result<string, error>

  /// Remove removes the named file or (empty) directory in the root.
  /// See [Remove] for more details.
  fn Remove(self: Ref<Root>, name: string) -> Result<(), error>

  /// RemoveAll removes the named file or directory and any children that it contains.
  /// See [RemoveAll] for more details.
  fn RemoveAll(self: Ref<Root>, name: string) -> Result<(), error>

  /// Rename renames (moves) oldname to newname.
  /// Both paths are relative to the root.
  /// See [Rename] for more details.
  fn Rename(self: Ref<Root>, oldname: string, newname: string) -> Result<(), error>

  /// Stat returns a [FileInfo] describing the named file in the root.
  /// See [Stat] for more details.
  fn Stat(self: Ref<Root>, name: string) -> Result<fs.FileInfo, error>

  /// Symlink creates newname as a symbolic link to oldname.
  /// See [Symlink] for more details.
  /// 
  /// Symlink does not validate oldname,
  /// which may reference a location outside the root.
  /// 
  /// On Windows, a directory link is created if oldname references
  /// a directory within the root. Otherwise a file link is created.
  fn Symlink(self: Ref<Root>, oldname: string, newname: string) -> Result<(), error>

  /// WriteFile writes data to the named file in the root, creating it if necessary.
  /// See [WriteFile] for more details.
  fn WriteFile(
    self: Ref<Root>,
    name: string,
    data: Slice<uint8>,
    perm: fs.FileMode,
  ) -> Result<(), error>
}

impl SyscallError {
  fn Error(self: Ref<SyscallError>) -> string

  /// Timeout reports whether this error represents a timeout.
  fn Timeout(self: Ref<SyscallError>) -> bool

  fn Unwrap(self: Ref<SyscallError>) -> Option<error>
}