filesystem

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileMainName

func FileMainName(filePath string) string

获取文件名, 不包含文件扩展名

@param filePath string 文件路径

@return string

func FileReExtName

func FileReExtName(filePath string, newExtName string) bool

修改文件扩展名

@param filePath string 文件原路径

@param newExtName string 新扩展名, 例如 ".exe", ".txt"

@return bool

func GetCurrentDirectory

func GetCurrentDirectory() string

获取当前路径

func GetExecPath

func GetExecPath() (string, error)

获取程序执行路径

func HasPrefixWithSuffixFilesFromDir

func HasPrefixWithSuffixFilesFromDir(path, prefix string, suffix string) ([]os.DirEntry, error)

从目录获取排序好的全部文件, 不包含目录, 不遍历子目录?

@parameter path 目录路径

@parameter prefix 过滤条件, 以`prefix`开始, 空字符串表示忽略该条件

@parameter suffix 过滤条件, 以`suffix`结束, 空字符串表示忽略该条件

@return []os.DirEntry 文件信息切片, 如失败则len()为0

@return error 错误信息, 如正常则为nil

func IsFileExists

func IsFileExists(path string) bool

判断文件是否存在

func ReExtName

func ReExtName(filePath string, newExtName string) string

修改文件扩展名, 只修改字符串, 不实际修改磁盘文件

@param filePath string 文件原路径

@param newExtName string 新扩展名, 例如 ".exe", ".txt"

@return string

func ReadFile

func ReadFile(filePath string) (*klists.KList[string], error)

func ReadLineFromLargeFile

func ReadLineFromLargeFile(filePath string, callback func(lineNo uint, line string, err error) error) error

@bref ReadLineFromLargeFile 从指定文件路径读取文件内容,并按行处理

参数:

@param filePath: 要读取的文件路径
@param callback: 每读取一行后调用的回调函数,参数为读取的行内容和错误对象

返回值:

@return error: 如果文件打开失败或读取文件时出现错误,则返回错误信息;否则返回nil

func ReadLines

func ReadLines(filePath string) (*klists.KList[string], error)

func ReadLinesDefaultBufferSize

func ReadLinesDefaultBufferSize(filePath string) (*klists.KList[string], error)

func ReadLinesWithBufferSize

func ReadLinesWithBufferSize(filePath string, bufferSize int) (*klists.KList[string], error)

func RemoveFile

func RemoveFile(path string) bool

func RenameFile

func RenameFile(path string, newPath string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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