fsutil

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	O_ModePerm fs.FileMode = 511

	// O_TRUNC = os.O_WRONLY|os.O_TRUNC|os.O_CREATE
	O_TRUNC int = 577

	// O_RDWTRUNC = os.O_RDWR|os.O_CREATE|os.O_TRUNC
	O_RDWTRUNC int = 578

	// O_RDONLY = os.O_RDONLY
	O_RDONLY int = 0

	// O_WROC = os.O_WRONLY|os.O_CREATE
	O_WROC int = 65
)

Variables

View Source
var (
	ErrNotExist error = errors.New("ulib.fsutil: no file/folder found")
	ErrMethods  error = errors.New("ulib.fsutil: don't use weird methods")
)

Functions

func CleanFile added in v1.19.0

func CleanFile(path string) error

func Copy added in v1.11.0

func Copy(src, dst string) error

func CopyAll added in v1.5.0

func CopyAll(src, dst string) error

func Create added in v1.13.0

func Create(v string) (*os.File, error)

func CreateTemp added in v1.13.0

func CreateTemp(dir string, pattern string) (*os.File, error)

CreateTemp creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting file.

The filename is generated by taking pattern and adding a random string to the end.

If pattern includes a "*", the random string replaces the last "*".

If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by TempDir.

Multiple programs or goroutines calling CreateTemp simultaneously will not choose the same file.

The caller can use the file's Name method to find the pathname of the file.

It is the caller's responsibility to remove the file when it is no longer needed.

func IsDir added in v0.0.11

func IsDir(path string) bool

This function will check if the target is a directory.

**When the target does not exist or other errors occur, it will return `false`**

func IsExist added in v1.5.0

func IsExist(path string) bool

This function checks if the target exists.

func IsFile added in v0.0.11

func IsFile(path string) bool

func Mkdir added in v1.5.0

func Mkdir(path string, mode ...fs.FileMode) error

func Move added in v1.11.0

func Move(src, dst string) error

func NewWriter added in v1.15.0

func NewWriter(path string) (*nn, error)

Higher performance sustainable file write operations.

Example Files: `writer_test.go`

func Open added in v1.7.0

func Open(v string) (*os.File, error)

Open opens the named file for reading.

If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.

If there is an error, it will be of type *PathError.

func OpenFile added in v1.7.0

func OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)

OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask). If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func OpenRead added in v1.7.0

func OpenRead(v string) ([]byte, error)

func ReadAll added in v1.11.0

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.

func ReadDir added in v1.5.0

func ReadDir(path string) (f []string)

func ReadDirAll added in v1.5.0

func ReadDirAll(path string) (f []string)

func ReadDirInfo added in v1.17.0

func ReadDirInfo(path string) (r []fs.FileInfo)

func ReadDirRaw added in v1.5.0

func ReadDirRaw(path string) ([]fs.DirEntry, error)

func ReaderWriter added in v1.19.0

func ReaderWriter(w io.Reader, r io.Writer) (*bufio.Reader, *bufio.Writer)

func Remove added in v1.6.0

func Remove(v string) error

func Rename added in v1.14.0

func Rename(old, new string) error

func Stat added in v1.16.0

func Stat(w string) (os.FileInfo, error)

func TruncWrite

func TruncWrite(path string, d any) error

func Write

func Write(path string, d any) error

Types

This section is empty.

Directories

Path Synopsis
zip
The GIF package provides encoding/decoding and other functions.
The GIF package provides encoding/decoding and other functions.

Jump to

Keyboard shortcuts

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