filex

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 23 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 CheckAndGetParentDir

func CheckAndGetParentDir(path string) string

CheckAndGetParentDir ...

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 CountLines

func CountLines(file string) (int, error)

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 Exists

func Exists(fpath string) bool

Exists return weather file existed

func FileExt

func FileExt(filePathName string) string

func FirstLine

func FirstLine(filename string) (string, error)

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory ...

func GetCurrentPackage

func GetCurrentPackage() string

GetCurrentPackage ...

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 IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory ...

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 IsFileChanged

func IsFileChanged(src, dest string) (bool, error)

IsFileChanged reports whether src and dest config files are equal. Two config files are equal when they have the same file contents and Unix permissions. The owner, group, and mode must match. Returns false in other cases.

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 LastLine

func LastLine(filename string) (string, error)

func ListFiles

func ListFiles(dir string, ext string) []string

ListFiles returns all file names in `dir`

func Lock

func Lock(name string) (io.Closer, error)

Lock ...

func MTime

func MTime(file string) (int64, error)

MTime returns file modified time and possible error.

func MakeDirectory

func MakeDirectory(dirs ...string) error

MakeDirectory ...

func MkDir

func MkDir(src string) (err error)

MkDir create a directory

func MkdirIfNecessary

func MkdirIfNecessary(createDir string) error

MkdirIfNecessary ...

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 RecursiveDirsLookup

func RecursiveDirsLookup(root string, pattern string) ([]string, error)

RecursiveDirsLookup ...

func RecursiveFilesLookup

func RecursiveFilesLookup(root string, pattern string) ([]string, error)

RecursiveFilesLookup ...

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 TempFileWithText

func TempFileWithText(text string) (*os.File, error)

TempFileWithText creates the temporary file with the given content, and returns the opened *os.File instance. The file is kept as open, the caller should close the file handle, and remove the file by name.

func TempFilenameWithText

func TempFilenameWithText(text string) (string, error)

TempFilenameWithText creates the file with the given content, and returns the filename (full path). The caller should remove the file after use.

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

type FileInfo

type FileInfo struct {
	Uid  uint32
	Gid  uint32
	Mode os.FileMode
	Md5  string
}

fileInfo describes a configuration file and is returned by fileStat.

func FileStat

func FileStat(name string) (fi FileInfo, err error)

FileStat return a FileInfo describing the named file.

Jump to

Keyboard shortcuts

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