system

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

README

System I/O

Documentation

Index

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 New

func New(root ...string) *File

New create a new file struct

func (*File) Allow

func (f *File) Allow(patterns ...string) *File

Allow allow rel path

func (*File) AllowAbs

func (f *File) AllowAbs(patterns ...string) *File

AllowAbs allow abs path

func (*File) Chmod

func (f *File) Chmod(name string, mode uint32) error

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) Copy

func (f *File) Copy(src string, dest string) error

Copy copy from src to dst

func (*File) Deny

func (f *File) Deny(patterns ...string) *File

Deny deny rel path

func (*File) DenyAbs

func (f *File) DenyAbs(patterns ...string) *File

DenyAbs deny abs path

func (*File) Exists

func (f *File) Exists(name string) (bool, error)

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) IsDir

func (f *File) IsDir(name string) bool

IsDir check the given path is dir

func (*File) IsFile

func (f *File) IsFile(name string) bool

IsFile check the given path is file

func (f *File) IsLink(name string) bool

IsLink check the given path is symbolic link

func (*File) MimeType

func (f *File) MimeType(name string) (string, error)

MimeType return the MimeType

func (*File) Mkdir

func (f *File) Mkdir(dir string, perm uint32) error

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

func (f *File) MkdirAll(dir string, perm uint32) error

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

func (f *File) MkdirTemp(dir string, pattern string) (string, error)

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) ModTime

func (f *File) ModTime(name string) (time.Time, error)

ModTime return the file modification time

func (*File) Mode

func (f *File) Mode(name string) (uint32, error)

Mode return the file mode bits

func (*File) Move

func (f *File) Move(oldpath string, newpath string) error

Move move from oldpath to newpath

func (*File) ReadDir

func (f *File) ReadDir(dir string, recursive bool) ([]string, error)

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

func (f *File) ReadFile(file string) ([]byte, error)

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

func (f *File) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*File) RemoveAll

func (f *File) RemoveAll(name string) error

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) Size

func (f *File) Size(name string) (int, error)

Size return the length in bytes for regular files; system-dependent for others

func (*File) WriteFile

func (f *File) WriteFile(file string, data []byte, perm uint32) (int, error)

WriteFile writes data to the named file, creating it if necessary.

If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL