fsutil

package
v0.0.0-...-784c0f6 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FsCWAFlags = os.O_CREATE | os.O_WRONLY | os.O_APPEND // create, append write-only
	FsCWTFlags = os.O_CREATE | os.O_WRONLY | os.O_TRUNC  // create, override write-only
	FsCWFlags  = os.O_CREATE | os.O_WRONLY               // create, write-only
	FsRFlags   = os.O_RDONLY                             // read-only
)

some commonly flag consts for open file

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(srcPath, dstPath string) error

CopyFile copy a file to another file path.

func Download

func Download(filepath string, url string) (err error)

Download downloads file from url and saves it to filepath

func ExtName

func ExtName(fpath string) string

ExtName is ...

func IsDir

func IsDir(path string) bool

IsDir reports whether the named directory exists.

func IsFile

func IsFile(path string) bool

IsFile reports whether the named file or directory exists.

func MkDirs

func MkDirs(perm os.FileMode, dirPaths ...string) error

MkDirs batch make multi dirs at once

func MkSubDirs

func MkSubDirs(perm os.FileMode, parentDir string, subDirs ...string) error

MkSubDirs batch make multi sub-dirs at once

func MustReadFile

func MustReadFile(filePath string) []byte

MustReadFile read file contents, will panic on error

func OpenFile

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

OpenFile like os.OpenFile, but will auto create dir.

func RemoveDir

func RemoveDir(dir string) error

RemoveDir is ...

func Workdir

func Workdir() string

Workdir get

func WriteOSFile

func WriteOSFile(f *os.File, data any) (n int, err error)

WriteOSFile write data to give os.File, then close file. data type allow: string, []byte, io.Reader

Types

This section is empty.

Jump to

Keyboard shortcuts

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