Documentation ¶
Index ¶
- Variables
- func Chdir(dir string) error
- func Chmod(name string, mode FileMode) error
- func CopyFile(src string, dst string) error
- func DirExists(dir string) error
- func DirIsEmpty(dir string) error
- func FileExists(file string) error
- func FileSize(file string) (int64, error)
- func Mkdir(name string, perm FileMode) error
- func MkdirAll(path string, perm FileMode) error
- func ReadFile(filename string) ([]byte, error)
- func ReadString(filename string) (string, error)
- func Remove(name string) error
- func RemoveAll(path string) error
- func RemoveGlob(path string) error
- func RemoveGlobAll(path string) error
- func WriteFile(filename string, data []byte, perm FileMode) error
- func WriteReader(filename string, src io.Reader, perm FileMode) error
- func WriteString(filename string, data string, perm FileMode) error
- type DirEntry
- type FileInfo
- type FileMode
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalid = fs.ErrInvalid // "invalid argument" ErrPermission = fs.ErrPermission // "permission denied" ErrExist = fs.ErrExist // "file already exists" ErrNotExist = fs.ErrNotExist // "file does not exist" ErrClosed = fs.ErrClosed // "file already closed" ErrIsDir = errors.New("file is directory") ErrNotDir = syscall.ENOTDIR )
Functions ¶
func Chdir ¶
Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.
func Chmod ¶
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 0200 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 0400 for a read-only file and 0600 for a readable+writable file.
On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive, and ModeTemporary are used.
func DirExists ¶
DirExists check if the directory dir exists return ErrIsNotDir if dir is not directory
func DirIsEmpty ¶
DirIsEmpty check if the directory dir contains sub folders or files
func FileExists ¶
FileExists check if the file exists return ErrIsDir if file is directory
func Mkdir ¶
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.
func MkdirAll ¶
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.
func ReadFile ¶
ReadFile reads the file named by filename 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.
func ReadString ¶
ReadString reads the file named by filename and returns the contents as string. A successful call returns err == nil, not err == EOF. Because ReadString reads the whole file, it does not treat an EOF from Read as an error to be reported.
func Remove ¶
Remove removes the named file or directory. If there is an error, it will be of type *PathError.
func RemoveAll ¶
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.
func RemoveGlob ¶
Remove removes all files return the by filepath.Glob().
func RemoveGlobAll ¶
Remove removes all files and children return the by filepath.Glob().
func WriteFile ¶
WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions.
func WriteReader ¶
WriteReader writes reader data to a file named by filename. If the file does not exist, WriteReader creates it with permissions perm (before umask); otherwise WriteReader truncates it before writing, without changing permissions.
func WriteString ¶
WriteString writes string data to a file named by filename. If the file does not exist, WriteString creates it with permissions perm (before umask); otherwise WriteString truncates it before writing, without changing permissions.
Types ¶
type DirEntry ¶
A DirEntry is an entry read from a directory (using the ReadDir function or a File's ReadDir method).