osutil

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MkFile

func MkFile(path string, data []byte) error

func PurgeFile

func PurgeFile(path string) error

删除文件, 并清理空目录. 如果文件不存在则返回 nil

func RemoveEmptyDirectories

func RemoveEmptyDirectories(dirPath string) error

递归删除空目录

func RemoveNow

func RemoveNow(path string) error

RemoveNow 立即删除文件(无论是否被引用)

func SanitizeFileName

func SanitizeFileName(fileName string) string

func SetCacheTTL

func SetCacheTTL(d time.Duration)

SetCacheTTL 设置全局文件缓存延迟删除时间

func SetOnRemoveError

func SetOnRemoveError(f func(path string, err error))

Types

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

func CreateCache

func CreateCache(path string) (*File, error)

func MkCache

func MkCache(path string, data []byte) (*File, error)

MkCache 创建文件并自动加入缓存管理

func OpenCache

func OpenCache(path string) (*File, error)

OpenCache 打开一个文件并增加引用计数。 使用全局默认 TTL。

func OpenCacheWithTTL

func OpenCacheWithTTL(path string, ttl time.Duration) (*File, error)

OpenCacheWithTTL 打开一个文件并增加引用计数,使用自定义 TTL。

func (*File) Close

func (f *File) Close() error

type TempFile

type TempFile struct {
	*os.File
}

func OpenTemp

func OpenTemp(path string) (*TempFile, error)

func (*TempFile) Close

func (t *TempFile) Close() error

Jump to

Keyboard shortcuts

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