Documentation ¶
Index ¶
- type File
- func (f *File) Allow(patterns ...string) *File
- func (f *File) AllowAbs(patterns ...string) *File
- func (f *File) Chmod(name string, mode uint32) error
- func (f *File) Copy(src string, dest string) error
- func (f *File) Deny(patterns ...string) *File
- func (f *File) DenyAbs(patterns ...string) *File
- func (f *File) Exists(name string) (bool, error)
- func (f *File) IsDir(name string) bool
- func (f *File) IsFile(name string) bool
- func (f *File) IsLink(name string) bool
- func (f *File) MimeType(name string) (string, error)
- func (f *File) Mkdir(dir string, perm uint32) error
- func (f *File) MkdirAll(dir string, perm uint32) error
- func (f *File) MkdirTemp(dir string, pattern string) (string, error)
- func (f *File) ModTime(name string) (time.Time, error)
- func (f *File) Mode(name string) (uint32, error)
- func (f *File) Move(oldpath string, newpath string) error
- func (f *File) ReadDir(dir string, recursive bool) ([]string, error)
- func (f *File) ReadFile(file string) ([]byte, error)
- func (f *File) Remove(name string) error
- func (f *File) RemoveAll(name string) error
- func (f *File) Size(name string) (int, error)
- func (f *File) WriteFile(file string, data []byte, perm uint32) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File the file
func (*File) 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 (*File) Exists ¶
Exists returns a boolean indicating whether the error is known to report that a file or directory already exists. It is satisfied by ErrExist as well as some syscall errors.
func (*File) 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 (*File) 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 (*File) MkdirTemp ¶
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. 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.
func (*File) ReadDir ¶
ReadDir reads the named directory, returning all its directory entries sorted by filename. If an error occurs reading the directory, ReadDir returns the entries it was able to read before the error, along with the error.
func (*File) ReadFile ¶
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.
func (*File) Remove ¶
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func (*File) 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.