fs

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ErrTimeout = errors.New("timeout")

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 Fdatasync

func Fdatasync(f *os.File) error

fdatasync flushes written data to a file descriptor.

func Flock

func Flock(f *os.File, exclusive bool, timeout time.Duration) error

Flock acquires an advisory lock on a file descriptor.

func Funlock

func Funlock(f *os.File) error

Funlock releases an advisory lock on a file descriptor.

func IsFileExist

func IsFileExist(filename string) bool

IsFileExist test if file exist

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.

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

func (w *FileWriter) Sync() error

立即刷新

func (*FileWriter) Write

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

type WriterMode

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