fsu

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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"
	ErrNotDir      = syscall.ENOTDIR
	ErrIsDir       = errors.New("file is directory")
	ErrDirNotEmpty = errors.New("directory not empty")
)

Functions

func Chdir

func Chdir(dir string) error

Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.

func Chmod

func Chmod(name string, mode FileMode) 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 CopyFile

func CopyFile(src string, dst string) error

CopyFile copy src file to des file

func DirExists

func DirExists(dir string) error

DirExists check if the directory dir exists return ErrIsNotDir if dir is not directory

func DirIsEmpty

func DirIsEmpty(dir string) error

DirIsEmpty check if the directory dir contains sub folders or files

func FileExists

func FileExists(file string) error

FileExists check if the file exists return ErrIsDir if file is directory

func FileSize

func FileSize(file string) (int64, error)

FileSize get the file size

func Mkdir

func Mkdir(name string, perm FileMode) 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 MkdirAll

func MkdirAll(path string, perm FileMode) 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 ReadFile

func ReadFile(filename string) ([]byte, error)

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

func ReadString(filename string) (string, error)

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

func Remove(name string) error

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

func RemoveAll

func RemoveAll(path 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 RemoveGlob

func RemoveGlob(path string) error

Remove removes all files return the by filepath.Glob().

func RemoveGlobAll

func RemoveGlobAll(path string) error

Remove removes all files and children return the by filepath.Glob().

func WriteFile

func WriteFile(filename string, data []byte, perm FileMode) error

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

func WriteReader(filename string, src io.Reader, perm FileMode) error

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

func WriteString(filename string, data string, perm FileMode) error

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

type DirEntry = fs.DirEntry

A DirEntry is an entry read from a directory (using the ReadDir function or a File's ReadDir method).

func ReadDir

func ReadDir(dirname string) ([]DirEntry, 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.

type FileInfo

type FileInfo = fs.FileInfo

A FileInfo describes a file and is returned by Stat and Lstat.

type FileMode

type FileMode = fs.FileMode

A FileMode represents a file's mode and permission bits. The bits have the same definition on all systems, so that information about files can be moved from one system to another portably. Not all bits apply to all systems. The only required bit is ModeDir for directories.

Jump to

Keyboard shortcuts

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