fsutil

package
v0.0.0-...-754e97a Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// sniff Length, use for detect file mime type
	MimeSniffLen = 512
)

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(fpath string, filePerm, dirPerm os.FileMode) (*os.File, error)

CreateFile if not exists Usage:

CreateFile("path/to/file.txt", 0664, 0666)

func DeleteIfFileExist

func DeleteIfFileExist(fpath string) error

DeleteIfFileExist operate

func FileExists

func FileExists(path string) bool

FileExists reports whether the named file or directory exists. Deprecated

please use PathExists() or IsFile() instead it

func IsAbsPath

func IsAbsPath(filepath string) bool

IsAbsPath is abs path.

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 IsImageFile

func IsImageFile(path string) bool

IsImageFile check file is image file.

func IsZipFile

func IsZipFile(filepath string) bool

IsZipFile check is zip file. from https://blog.csdn.net/wangshubo1989/article/details/71743374

func MimeType

func MimeType(path string) (mime string)

MimeType get File Mime Type name. eg "image/png"

func Mkdir

func Mkdir(dirPath string, perm os.FileMode) error

Mkdir alias of os.MkdirAll()

func PathExists

func PathExists(path string) bool

PathExists reports whether the named file or directory exists.

func ReaderMimeType

func ReaderMimeType(r io.Reader) (mime string)

ReaderMimeType get the io.Reader mimeType Usage:

file, err := os.Open(filepath)
if err != nil {
	return
}
mime := ReaderMimeType(file)

func Unzip

func Unzip(archive, targetDir string) (err error)

Unzip a zip archive from https://blog.csdn.net/wangshubo1989/article/details/71743374

Types

This section is empty.

Jump to

Keyboard shortcuts

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