fileutil

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile

func AppendFile(filename string, data string)

func AppendLine

func AppendLine(path string, content string) error

func AppendTo

func AppendTo(fileName, content string) error

AppendTo append to file

func BuildDir

func BuildDir(absDir string) error

BuildDir 创建目录

func CheckFileIsExist

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 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

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func DirName

func DirName(argv ...string) string

func Empty

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

Empty empty the file

func Exist

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 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 GetProPath

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

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

IoSha file sha

func Is

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

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 MTime

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

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 ReadFile

func ReadFile(path string) (string, error)

Read read file and return string

func ReadLine

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

ReadFile 读取文件

func Save

func Save(filename string, r io.Reader) (err error)
func Search(fileName string, paths ...string) (fullpath string, err error)

Search Search a file in paths.

func Sha

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

Sha open file return sha

func Size

func Size(file string) (int64, error)

Size returns file size in bytes and possible error.

func Write

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

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

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