files

package
v0.0.0-...-fcab2ad Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsUpdate

func AbsUpdate(paths ...*string)

AbsUpdate 尝试将路径转换为绝对路径, 如果成功则使用绝对路径赋值

func CopyFile

func CopyFile(source, target string) (err error)

func CreateDir

func CreateDir(dir string) (err error)

CreateDir 判断是否目录,如果不存在或者是软连接则删除软连接并创建目录,返回创建结果,如果不是目录,则返回目录已存在错误。

func CreateSymlink(source, link string, force bool, abs bool) (err error)

CreateSymlink creates a symlink at path pointing to target.

func IsShortcutStat

func IsShortcutStat(stat fs.FileInfo) bool

IsShortcutStat checks if the file is a shortcut.

func IsSymlinkStat

func IsSymlinkStat(stat fs.FileInfo) bool

IsSymlinkStat checks if the given file info is a symlink.

func OverwriteOnExist

func OverwriteOnExist(source, target string) error
func RemoveSymlink(path string, force bool) (err error)

RemoveSymlink deletes a symlink or a .lnk file, if force is true, it will delete the target file as well.

func SkipOnExist

func SkipOnExist(source, target string) error

func WalkDir

func WalkDir(root string, fn fs.WalkDirFunc, maxDepth ...int) (err error)

WalkDir 遍历目录,同 filepath.WalkDir,支持最大层级限定(maxDepth)。

Types

type CopyOptions

type CopyOptions struct {
	RemoveSource bool                              // 是否删除源文件(移动)
	OnExist      func(source, target string) error // 当目标存在时,如何处理
	OnSymlink    func(source, target string) error // 当源为软链接时,如何处理
	Error        func(err error) error
	Symlink      bool
}

Jump to

Keyboard shortcuts

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