cmd

package
v0.0.0-...-f476f32 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

cmd/root.go

Index

Constants

View Source
const AppVersion = "1.0.0"
View Source
const H = "💯"
View Source
const NUMBER_CHARS = "0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣"
View Source
const NUMBER_CHARS_ALL = "0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟"

Variables

This section is empty.

Functions

func BytesMD5

func BytesMD5(data []byte) string

func CalcMD5

func CalcMD5(filePath string) string

计算文件的 MD5 值

func CheckFileExists

func CheckFileExists(filePath string) bool

func CopyDir

func CopyDir(src string, dst string) error

复制文件夹 src 到 dst

func CountChildren

func CountChildren(dirPath string) (int, int, int, int)

func CreateDirIfNotExists

func CreateDirIfNotExists(path string) error

func CreateParentDirectories

func CreateParentDirectories(filePath string) error

CreateParentDirectories 创建给定文件路径的所有父级文件夹

func DeduplicateUintSlice

func DeduplicateUintSlice(slice []uint, sortFlag int) []uint

DeduplicateUintSlice 删除重复元素. 可选是否对结果排序 slice: 待处理的切片 sortFlag: 0-不排序, 1-升序, 2-降序

func DeleteFileOrDir

func DeleteFileOrDir(path string) error

删除文件或整个文件夹

func DirExists

func DirExists(filePath string) bool

func Execute

func Execute()

func ExpandWildcards

func ExpandWildcards(pattern string) ([]string, error)

ExpandWildcards 接收一个可能包含通配符的路径字符串,并返回所有匹配的文件路径列表。

func ExpandWildcardsWithFilter

func ExpandWildcardsWithFilter(pattern string, filterFileTypes []string) ([]string, error)

ExpandWildcardsWithFilter 接收一个可能包含通配符的路径字符串,并返回所有匹配的文件路径列表。支持传入要过滤文件类型(例如: .png .jpg)

func FileExists

func FileExists(filePath string) bool

func FileMD5

func FileMD5(filePath string) string

func FileSHA1

func FileSHA1(filePath string) string

计算文件的 SHA1 值

func FileSHA256

func FileSHA256(filePath string) string

计算文件的 SHA256 值

func FilterFileTypes

func FilterFileTypes(paths []string, filterFileTypes []string) ([]string, error)

FilterFileTypes 过滤 []string 文件类型

func FilterFileTypesV1

func FilterFileTypesV1(paths []string, filterFileTypes []string) ([]string, error)

func GenerateRandomString

func GenerateRandomString() string

func GenerateUniqueFilePath

func GenerateUniqueFilePath(filePath string) string

GenerateUniqueFilePath 生成唯一的文件路径,通过在文件名后添加 _1, _2 等序号直到找到可用路径

func GetAbsolutePath

func GetAbsolutePath(dirPath, path string) string

func GetChildrenList

func GetChildrenList(dirPath string, relativePath bool) []string

GetChildrenList 获取文件夹下的所有文件和文件夹 如果输入参数 relativePath 为 true, 则返回相对于根文件夹的相对路径, 否则返回绝对路径

func GetDirList

func GetDirList(dirPath string, relativePath bool) []string

GetDirList 根据输入的文件夹路径, 输出一个文件夹列表(该文件夹内所有层级的文件夹在系统的绝对完整路径,不包括文件)

func GetFileHeaderHash

func GetFileHeaderHash(path string, limit int64) (uint32, error)

GetFileHeaderHash 获取文件的头部Hash

func GetFileList

func GetFileList(dirPath string, relativePath bool) []string

GetFileList 根据输入的文件夹路径, 输出一个文件列表(该文件夹内所有层级的文件在系统的绝对完整路径,不包括文件夹)

func GetFileSize

func GetFileSize(path string) int64

func GetFileSizeV2

func GetFileSizeV2(path string) (int64, error)

func GetFileSizeV8

func GetFileSizeV8(path string) (int64, error)

func GetRelativePath

func GetRelativePath(dirPath, path string) (string, error)

获取 path 相对于 dirPath 的相对路径

func GetRelativePathV1

func GetRelativePathV1(path, dirPath string) string

获取相对于dirPath的相对路径

func GetRootFiles

func GetRootFiles(dirPath string, relativePath bool, filterFileTypes []string) []string

GetRootFiles 获取指定目录下根目录中的文件列表 dirPath: 要遍历的目录路径 relativePath: 如果非空,则返回相对于此路径的相对路径;否则返回绝对路径 filterFileTypes: 要过滤的文件后缀名列表(如 ".txt", ".jpg"),为空或 nil 表示不过滤

func GetStdSizeInfo

func GetStdSizeInfo(size int64) string

func I2C

func I2C(num int) string

func IntToChars

func IntToChars(num int) string

func IsTmpFileOrNotExists

func IsTmpFileOrNotExists(filePath string) bool

func JoinUintSlice

func JoinUintSlice(slice []uint, sep string) string

func Percent

func Percent(a, b int) int

Percent 输入两个整数 a b, 计算 a 占 b 的 百分比, 不保留小数, 也就是返回结果为 0-100 之间的整数。

func PercentChars

func PercentChars(a, b int) string

func PercentText

func PercentText(a, b int) string

func ReadDirAndIgnoreTmpFiles

func ReadDirAndIgnoreTmpFiles(dirPath string) []os.DirEntry

func SortUintSlice

func SortUintSlice(slice []uint, sortFlag int) []uint

SortUintSlice 对切片排序 slice: 待处理的切片 sortFlag: 排序标志,1表示升序,2表示降序. 其他数值比如0表示不排序

func StringMD5

func StringMD5(str string) string

Types

type FileInfo

type FileInfo struct {
	FileName      string
	DirPath       string
	AbsPath       string
	RelPath       string
	FileSize      int
	FileData      []byte
	LzssData      []byte
	ModTime       time.Time
	Key           string
	HashAlgorithm string
}

文件元信息

func (*FileInfo) ReadFileData

func (f *FileInfo) ReadFileData() []byte

Jump to

Keyboard shortcuts

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