iofs

package
v0.0.0-...-2040d2c Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ModeExecutable fs.FileMode = 0o111

Variables

View Source
var B32 = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567").WithPadding(base32.NoPadding)

Functions

func Cat

func Cat(path string) string

Cat 以utf8编码读取文件文本内容

func CopyContext

func CopyContext(ctx context.Context, w io.Writer, r io.Reader) (err error)

func CopyFile

func CopyFile(srcPath, dstPath string, overwrite ...bool) (ok bool, err error)

CopyFile copies the named file from srcPath to dstPath.

func ErrRw

func ErrRw(err error) io.ReadWriteCloser

func IORE

func IORE(r io.Reader, err error) io.ReadCloser

func IsEmptyDir

func IsEmptyDir(dir string) (empty bool)

IsEmptyDir 判断路径是目录且为空

func IsExecutable

func IsExecutable(path string) bool

IsExecutable 判断路径是否可执行

func IsFile

func IsFile(path string) bool

IsFile 判断路径是否是文件

func Mkdir

func Mkdir(dir string, perm os.FileMode) (ok bool, err error)

Mkdir 创建文件夹

如果文件夹存在,跳过
如果目标是软链接,删除,再创建文件夹
其他情况,返回目标存在错误
返回值 ok 代表新建了文件夹

func NocWriter

func NocWriter(src io.Writer) io.WriteCloser

func RandText

func RandText(n int) (s string)

RandText 生成一个指定长度的随机字符串。

func ReadFile

func ReadFile(path string) (data []byte)

ReadFile reads the named file and returns the contents and ignore the error.

func ReaderContextWrap

func ReaderContextWrap(ctx context.Context, r io.Reader) io.Reader
func Readlink(linkname string) (dir, name string, err error)

Readlink 读取软链接信息

func Symlink(ctx context.Context, oldname, newname string, overwrite ...bool) (err error)

Symlink 创建文件系统软链接

如果目标是软链接,删除
如果目标是目录,判断是否为空,为空则删除
如果目标是文件,如果overwrite == false报存在错,否则删除

func WriteFileContext

func WriteFileContext(ctx context.Context, src io.Reader, dstPath string, perm fs.FileMode) (err error)

func WriteText

func WriteText[T ~string | ~[]byte](ctx context.Context, path string, data T, perm os.FileMode, overwrite ...bool) (err error)

WriteText 写入文件

func WriterContextWrap

func WriterContextWrap(ctx context.Context, w io.Writer) io.Writer

Types

This section is empty.

Jump to

Keyboard shortcuts

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