os - files.
Everything goes through syscall, no dependency on the C library of the host.
¶O_RDONLY = syscall.O_RDONLYvaluesource
¶O_WRONLY = syscall.O_WRONLYvaluesource
¶O_RDWR = syscall.O_RDWRvaluesource
¶O_CREAT = syscall.O_CREATvaluesource
¶O_TRUNC = syscall.O_TRUNCvaluesource
¶O_APPEND = syscall.O_APPENDvaluesource
¶O_EXCL = syscall.O_EXCLvaluesource
¶Open = fn(path, flags, perm)source
Open returns the file at path open with the given flags. Perm is only used when the file is created, 0644 is the usual value.
¶Name = pathvaluesource
¶Read = fn(n)source
Read returns up to n bytes, or an empty bytes value at end of file.
¶ReadAll = fn()source
ReadAll returns the rest of the file.
¶ReadString = fn()source
¶Write = fn(data)source
Write writes a string or bytes and returns how many bytes went out.
¶Seek = fn(offset, whence)source
¶Close = fn()source
¶Create = fn(path)source
Create opens path for writing, truncating it or creating it as needed.
¶Name = pathvaluesource
¶Read = fn(n)source
Read returns up to n bytes, or an empty bytes value at end of file.
¶ReadAll = fn()source
ReadAll returns the rest of the file.
¶ReadString = fn()source
¶Write = fn(data)source
Write writes a string or bytes and returns how many bytes went out.
¶Seek = fn(offset, whence)source
¶Close = fn()source
¶ReadFile = fn(path)source
ReadFile returns the whole content of path as bytes.
¶ReadFileString = fn(path)source
¶WriteFile = fn(path, data)source
WriteFile writes data, a string or bytes, to path.
¶Mkdir = fn(path, perm)source
¶Remove = fn(path)source
¶Rmdir = fn(path)source
¶Chmod = fn(path, mode)source
¶Exists = fn(path)source
Exists reports whether path exists.
¶Stdin = newFile(0, "/dev/stdin")valuesource
¶Name = pathvaluesource
¶Read = fn(n)source
Read returns up to n bytes, or an empty bytes value at end of file.
¶ReadAll = fn()source
ReadAll returns the rest of the file.
¶ReadString = fn()source
¶Write = fn(data)source
Write writes a string or bytes and returns how many bytes went out.
¶Seek = fn(offset, whence)source
¶Close = fn()source
¶Stdout = newFile(1, "/dev/stdout")valuesource
¶Name = pathvaluesource
¶Read = fn(n)source
Read returns up to n bytes, or an empty bytes value at end of file.
¶ReadAll = fn()source
ReadAll returns the rest of the file.
¶ReadString = fn()source
¶Write = fn(data)source
Write writes a string or bytes and returns how many bytes went out.
¶Seek = fn(offset, whence)source
¶Close = fn()source
¶Stderr = newFile(2, "/dev/stderr")valuesource
¶Name = pathvaluesource
¶Read = fn(n)source
Read returns up to n bytes, or an empty bytes value at end of file.
¶ReadAll = fn()source
ReadAll returns the rest of the file.
¶ReadString = fn()source
¶Write = fn(data)source
Write writes a string or bytes and returns how many bytes went out.
¶Seek = fn(offset, whence)source
¶Close = fn()source
¶Args = args()valuesource
Args is the command line: the program itself first, then its arguments.
¶Getenv = fn(name)source
Getenv returns the value of the environment variable name, or an empty string when it isn't set. LookupEnv tells the two apart.
¶LookupEnv = fn(name)source
LookupEnv returns the value of name and whether it was set at all.
¶Setenv = fn(name, value)source
¶Unsetenv = fn(name)source
¶Rename = fn(from, to)source
¶Getwd = fn()source
¶Chdir = fn(path)source
¶TempDir = fn()source
TempDir returns the directory for temporary files.
¶Stat = fn(path)source
Stat returns what is known about the file at path: its Name, Size in bytes, Mode, whether it IsDir and when it was last modified, in seconds since the Unix epoch.
¶Name = pathvaluesource
¶Size = sizevaluesource
¶Mode = modevaluesource
¶Perm = mode & 0777valuesource
¶IsDir = (mode & syscall.S_IFMT) == syscall.S_IFDIRvaluesource
¶ModTime = mtimevaluesource
¶IsDir = fn(path)source
IsDir reports whether path is a directory. A path that isn't there is not.
¶ReadDir = fn(path)source
ReadDir returns the names inside the directory at path, sorted, without "." and "..".
¶MkdirAll = fn(path, perm)source
MkdirAll creates path and every directory missing above it.
¶RemoveAll = fn(path)source
RemoveAll removes path and everything under it.