pathutil

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: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDir

func BuildDir(absDir string) error

BuildDir 创建目录

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist 检查目录是否存在

func CheckPermission

func CheckPermission(src string) bool

CheckPermission check if the file has permission

func Copy

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

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func DirName

func DirName(argv ...string) string

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 GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 获取程序运行路径

func GetModelPath

func GetModelPath() string

GetModelPath 获取目录地址

func GetPathDirs

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

GetPathDirs 获取目录所有文件夹

func GetPathFiles

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

GetPathFiles 获取目录所有文件

func GetProPath

func GetProPath() string

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

func IsNotExist(src string) bool

IsNotExist check if the file exists

func IsNotExistMkDir

func IsNotExistMkDir(src string) (err error)

IsNotExistMkDir create a directory if it does not exist

func List

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

List list file

func ListDir

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

ListDir list dir

func MkDir

func MkDir(src string) (err error)

MkDir create a directory

func PathExists

func PathExists(path string) (bool, error)

PathExists path is exist

func Realpath

func Realpath(fpath string) (string, error)

Realpath returns the real path of a given file in the os

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

Search Search a file in paths.

func TempFile

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

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

Walk walk file

func WalkDir

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

WalkDir walk dir

Types

This section is empty.

Jump to

Keyboard shortcuts

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