Documentation
¶
Overview ¶
Package os provides a few functions used throughout the grw package for interfacing with the local file system.
Index ¶
- Constants
- Variables
- func CheckURIRead(uri string) error
- func CheckURIWrite(uri string, appendToFile bool, overwrite bool) error
- func Exit(code int)
- func MkdirAll(p string, flag os.FileMode) error
- func OpenDevice(name string) io.Writer
- func OpenFile(path string) (*os.File, error)
- func Remove(name string) error
- func Stat(uri string) (bool, stat.Info, error)
- type Signal
Constants ¶
const ( // Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified. //lint:ignore ST1003 keep identical to standard library O_RDONLY int = os.O_RDONLY // open the file read-only. //lint:ignore ST1003 keep identical to standard library O_WRONLY int = os.O_WRONLY // open the file write-only. //lint:ignore ST1003 keep identical to standard library O_RDWR int = os.O_RDWR // open the file read-write. // The remaining values may be or'ed in to control behavior. //lint:ignore ST1003 keep identical to standard library O_APPEND int = os.O_APPEND // append data to the file when writing. //lint:ignore ST1003 keep identical to standard library O_CREATE int = os.O_CREATE // create a new file if none exists. //lint:ignore ST1003 keep identical to standard library O_EXCL int = os.O_EXCL // used with O_CREATE, file must not exist. //lint:ignore ST1003 keep identical to standard library O_SYNC int = os.O_SYNC // open for synchronous I/O. //lint:ignore ST1003 keep identical to standard library O_TRUNC int = os.O_TRUNC // truncate regular writable file when opened. )
Variables ¶
var (
ErrPathMissing = errors.New("path missing")
)
Functions ¶
func CheckURIRead ¶
func Exit ¶
func Exit(code int)
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.
func MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. Wraps the standard library os.MkdirAll function to add support for expanding the user's home directory. 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. Mkdirs expands the home directory and resolves the path given. Flag is the permissions flag, e.g., 0770.
func OpenDevice ¶
OpenDevice returns a pointer to the device indicated by name. Matches the following names as case insensitive:
- stdout, /dev/stdout => os.Stdout
- stderr, /dev/stderr => os.Stderr
- stdin, /dev/stdin => os.Stdin
- null, /dev/null => io.Discard
func Remove ¶
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func Stat ¶
Stat stats the given resource. Returns a bool indicating whether the file exists, file info, and an error if any. If the underlying error was a "does not exist" error, then the error is supressed and returns false, nil, nil If the underlying error was any other type of error, then the existence value is not guaranteed. Do check the error returned and do not ignore the error with "exists, _, _ := Stat(/path/tofile)".