Documentation
¶
Index ¶
- type File
- func (f *File) Allow(patterns ...string) *File
- func (f *File) AllowAbs(patterns ...string) *File
- func (f *File) Append(file string, reader io.Reader, perm uint32) (int, error)
- func (f *File) AppendFile(file string, data []byte, perm uint32) (int, error)
- func (f *File) Chmod(name string, mode uint32) error
- func (f *File) CleanCache()
- 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) Glob(pattern string) ([]string, error)
- func (f *File) Insert(file string, offset int64, reader io.Reader, perm uint32) (int, error)
- func (f *File) InsertFile(file string, offset int64, data []byte, perm uint32) (int, 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) List(path string, types []string, page, pageSize int, filter func(string) bool) ([]string, int, int, error)
- 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) ReadCloser(file string) (io.ReadCloser, error)
- func (f *File) ReadDir(dir string, recursive bool) ([]string, error)
- func (f *File) ReadFile(file string) ([]byte, error)
- func (f *File) ReadOnly() *File
- func (f *File) Remove(name string) error
- func (f *File) RemoveAll(name string) error
- func (f *File) Resize(inputPath, outputPath string, width, height uint) error
- func (f *File) Root() string
- func (f *File) Size(name string) (int, error)
- func (f *File) Walk(root string, handler func(root, file string, isdir bool) error, ...) error
- func (f *File) Write(file string, reader io.Reader, perm uint32) (int, error)
- func (f *File) WriteCloser(file string, perm uint32) (io.WriteCloser, error)
- func (f *File) WriteFile(file string, data []byte, perm uint32) (int, error)
- type Mode
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) Append ¶ added in v1.0.0
Append Append writes data to the named file, creating it if necessary.
func (*File) AppendFile ¶ added in v1.0.0
AppendFile Append writes data to the named file, creating it if necessary. If the file does not exist, AppendFile creates it with permissions perm (before umask); otherwise AppendFile truncates it before writing, without changing permissions.
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) Glob ¶ added in v1.0.0
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').
func (*File) Insert ¶ added in v1.0.0
Insert Insert writes data to the named file at the specified offset, creating it if necessary. @todo
- it should be improved to support large files and avoid reading the entire file into memory.
func (*File) InsertFile ¶ added in v1.0.0
InsertFile Insert writes data to the named file at the specified offset, creating it if necessary. If the file does not exist, InsertFile creates it with permissions perm (before umask); otherwise AppendFile truncates it before writing, without changing permissions. @todo
- It should be improved to support large files and avoid reading the entire file into memory.
func (*File) List ¶ added in v1.0.0
func (f *File) List(path string, types []string, page, pageSize int, filter func(string) bool) ([]string, int, int, error)
List list the files
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) ReadCloser ¶ added in v1.0.0
func (f *File) ReadCloser(file string) (io.ReadCloser, error)
ReadCloser returns a ReadCloser with the file content
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.
func (*File) Walk ¶ added in v1.0.0
func (f *File) Walk(root string, handler func(root, file string, isdir bool) error, patterns ...string) error
Walk traverse folders and read file contents
func (*File) WriteCloser ¶ added in v1.0.0
WriteCloser returns a WriteCloser with the file content