io

package
v3.3.7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chmod

func Chmod(path string, mode os.FileMode) error

Chmod 只改 path 自身,符号链接跟随到目标;mode 是 chmod 命令的原始八进制值

func ChmodR added in v3.3.7

func ChmodR(ctx context.Context, path string, mode os.FileMode) error

ChmodR 同 chmod -R:起点的符号链接跟随,遍历中遇到的跳过

func Chown

func Chown(path, owner, group string) error

Chown 只改 path 自身,owner/group 可为名称或数字 id

func ChownR added in v3.3.7

func ChownR(ctx context.Context, path, owner, group string) error

func Compress

func Compress(ctx context.Context, dir string, src []string, dst string) error

Compress src 为空时压缩整个 dir

func CompressShell added in v3.2.6

func CompressShell(dir string, src []string, dst string, verbose bool) (string, error)

CompressShell verbose 时逐文件输出,供后台任务日志查看进度

func Count added in v3.3.7

func Count(ctx context.Context, path string) (int64, error)

Count 统计条目数,含目录与 path 本身

func Cp

func Cp(ctx context.Context, src, dst string) error

Cp 语义同 Mv

func Empty

func Empty(path string) bool

Empty 判断路径是否为空

func Exists

func Exists(path string) bool

Exists 判断路径是否存在

func IsDir

func IsDir(path string) bool

func Mv

func Mv(ctx context.Context, src, dst string) error

Mv 目标是最终落点而非父目录,已存在的目录会被合并

func Read

func Read(path string) (string, error)

Read 读取文件

func Remove

func Remove(path string) error

Remove 撞上 +i/+a 属性时解锁子树重试

func Size

func Size(ctx context.Context, path string) (int64, error)

Size 用 du 统计,硬链接只计一次

func UnCompress

func UnCompress(ctx context.Context, src, dst string) error

func UnCompressShell added in v3.2.6

func UnCompressShell(src, dst string, verbose bool) (string, error)

func Write

func Write(path string, data string, perm os.FileMode) error

Write 目标带 +i/+a 时先解锁,写完恢复

Types

type ArchiveFormat added in v3.3.7

type ArchiveFormat string
const (
	Zip      ArchiveFormat = "zip"
	SevenZip ArchiveFormat = "7z"
	Tar      ArchiveFormat = "tar"
	TGz      ArchiveFormat = "tgz"
	TBz2     ArchiveFormat = "tbz2"
	TXz      ArchiveFormat = "txz"
	TZst     ArchiveFormat = "tzst"
	Gz       ArchiveFormat = "gz"
	Bz2      ArchiveFormat = "bz2"
	Xz       ArchiveFormat = "xz"
	Zst      ArchiveFormat = "zst"
)

type Entry added in v3.3.7

type Entry struct {
	Path string
	Info os.FileInfo
}
func Search(ctx context.Context, path, keyword string, sub bool) ([]Entry, error)

Search 文件名子串匹配,sub 为 true 时递归

Jump to

Keyboard shortcuts

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