fsutil

package
v1.3.22 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxFileBackup = 20   //
	DefaultMaxMBPerFile  = 100  // 100M
	DefaultCapacity      = 6000 //
)

Variables

This section is empty.

Functions

func ArchiveGzipFile

func ArchiveGzipFile(srcFile string) error

压缩文件 my.log --> my.log.tar.gz

func CompressBytes

func CompressBytes(data []byte) ([]byte, error)

压缩内容

func CopyFile

func CopyFile(dest, source string) error

CopyFile writes the contents of the given source file to dest.

func EnsureBaseDir

func EnsureBaseDir(baseDir, path string) string

EnsureBaseDir ensures that path is always prefixed by baseDir, allowing for the fact that path might have a Window drive letter in it.

func IsFileExist

func IsFileExist(filename string) bool

IsFileExist test if file exist

func LockFile

func LockFile(f *os.File) error

func ReadFileToLines

func ReadFileToLines(filename string) ([]string, error)

把文件内容按一行一行读取

func ReadToLines

func ReadToLines(rd io.Reader) ([]string, error)

func UncompressBytes

func UncompressBytes(data []byte) ([]byte, error)

解压内容

func UniqueDirectory

func UniqueDirectory(path, name string) (string, error)

UniqueDirectory returns "path/name" if that directory doesn't exist. If it does, the method starts appending .1, .2, etc until a unique name is found.

func UnlockFile

func UnlockFile(f *os.File) error

Types

type FileWriter

type FileWriter struct {
	// contains filtered or unexported fields
}

func NewFileWriter

func NewFileWriter(filename string, maxMBPerFile int, mode WriterMode) *FileWriter

func (*FileWriter) Close

func (w *FileWriter) Close() error

func (*FileWriter) Sync added in v1.1.1

func (w *FileWriter) Sync() error

立即刷新

func (*FileWriter) Write

func (w *FileWriter) Write(data []byte) (int, error)

type WriterMode added in v1.1.1

type WriterMode int
const (
	WriterSync      WriterMode = 0
	WriterAsync     WriterMode = 1
	WriterAsyncCopy WriterMode = 2
)

Jump to

Keyboard shortcuts

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