fileutil

package
v0.2.50 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile added in v0.2.25

func AppendFile(filename string, data string)

func AppendLine added in v0.2.32

func AppendLine(path string, content string) error

func AppendTo added in v0.2.39

func AppendTo(fileName, content string) error

AppendTo append to file

func BuildDir added in v0.2.19

func BuildDir(absDir string) error

BuildDir 创建目录

func CheckFileIsExist added in v0.2.19

func CheckFileIsExist(filename string) bool

CheckFileIsExist 检查目录是否存在

func CheckNotExist

func CheckNotExist(src string) bool

CheckNotExist check if the file exists

func CheckPermission

func CheckPermission(src string) bool

CheckPermission check if the file has permission

func Copy added in v0.1.25

func Copy(src, dst string) error

Copy copies file from source to target path.

func CopyDir

func CopyDir(source string, dest string) (err error)

CopyDir copies the source directory to the dest directory.

func CopyFile

func CopyFile(source string, dest string) (err error)

CopyFile copies the source file to the dest file.

func DeleteFile added in v0.2.19

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func DirName added in v0.2.25

func DirName(argv ...string) string

func Empty added in v0.2.39

func Empty(fileName string, args ...int64)

Empty empty the file

func Exist added in v0.2.39

func Exist(fileName string) bool

Exist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func FileExt

func FileExt(filePathName string) string

func GetCurrentDirectory added in v0.2.19

func GetCurrentDirectory() string

GetCurrentDirectory 获取程序运行路径

func GetExt

func GetExt(fileName string) string

GetExt get the file ext

func GetFileSize

func GetFileSize(path string) (i int64, err error)

GetFileSize get the length in bytes of file of the specified path.

func GetImageName

func GetImageName(name string) string

GetImageName get image hash name

func GetModelPath added in v0.2.19

func GetModelPath() string

GetModelPath 获取目录地址

func GetPathDirs added in v0.2.19

func GetPathDirs(absDir string) (re []string)

GetPathDirs 获取目录所有文件夹

func GetPathFiles added in v0.2.19

func GetPathFiles(absDir string) (re []string)

GetPathFiles 获取目录所有文件

func GetProPath added in v0.2.25

func GetProPath() string

func GetSize

func GetSize(r io.Reader) (i int, err error)

GetSize get the file size

func GrepFile

func GrepFile(patten string, filename string) (lines []string, err error)

GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read

func IoSha added in v0.2.39

func IoSha(fileIO *os.File, args ...string) (string, error)

IoSha file sha

func Is added in v0.2.39

func Is(filePath string) bool

Is returns true if path is a file, or returns false when it's a directory or not exist.

func IsBinary

func IsBinary(content string) bool

IsBinary determines whether the specified content is a binary file content.

func IsDir

func IsDir(path string) bool

IsDir determines whether the specified path is a directory.

func IsExist

func IsExist(path string) bool

IsExist determines whether the file spcified by the given path is exists.

func IsFile added in v0.2.25

func IsFile(f string) bool

func IsImg

func IsImg(extension string) bool

IsImg determines whether the specified extension is a image.

func IsNotExistMkDir

func IsNotExistMkDir(src string) (err error)

IsNotExistMkDir create a directory if it does not exist

func List added in v0.2.39

func List(dirPth, suffix string) (files []string, err error)

List list file

func ListDir added in v0.2.39

func ListDir(dirPth, suffix string) (files []string, err error)

ListDir list dir

func MTime added in v0.2.39

func MTime(file string) (int64, error)

MTime returns file modified time and possible error.

func MkDir

func MkDir(src string) (err error)

MkDir create a directory

func Mode added in v0.2.39

func Mode(filePath string) os.FileMode

Mode returns file mode if file is a exist.

func MustOpen

func MustOpen(fileName, filePath string) (f *os.File, err error)

MustOpen maximize trying to open the file

func Open

func Open(name string, flag int, perm os.FileMode) (f *os.File, err error)

Open a file according to a specific mode

func OpenCopy added in v0.2.39

func OpenCopy(srcName, dstName string) (int64, error)

OpenCopy open and copy file

func PathExists added in v0.2.32

func PathExists(path string) (bool, error)

PathExists path is exist

func ReadFile added in v0.2.19

func ReadFile(path string) (string, error)

Read read file and return string

func ReadLine added in v0.2.39

func ReadLine(path string) (src []string)

ReadFile 读取文件

func Search(fileName string, paths ...string) (fullpath string, err error)

Search Search a file in paths.

func Sha added in v0.2.39

func Sha(filePath string, args ...string) (sha string, err error)

Sha open file return sha

func Size added in v0.2.39

func Size(file string) (int64, error)

Size returns file size in bytes and possible error.

func TempFile added in v0.2.37

func TempFile(dir, prefix string, suffix string) (f *os.File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix and ending with suffix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

func Walk added in v0.2.39

func Walk(dirPth, suffix string) (files []string, err error)

Walk walk file

func WalkDir added in v0.2.39

func WalkDir(dirPth, suffix string) (files []string, err error)

WalkDir walk dir

func Write added in v0.2.39

func Write(fileName, writeStr string)

Write writes data to a file named by filename. If the file does not exist, WriteFile creates it and its upper level paths.

func WriteFile added in v0.2.19

func WriteFile(fileName string, data []byte) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it and its upper level paths.

func WriteString added in v0.2.32

func WriteString(path string, content string, append bool) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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