Documentation ¶
Index ¶
- func AppendContent(path string, content string) (int, error)
- func CopyFile(src, dst string, isFirstDel ...bool) (err error)
- func Create(path string) (*os.File, error)
- func CronParseLogFile(collectLog string, offset ...int) ([]string, error)
- func Exists(path string) bool
- func GetContent(path string) (string, error)
- func GetProjectDir(projectName string) string
- func Open(path string) (*os.File, error)
- func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)
- func ParseFileFormat(fileName string) string
- func PutContent(path string, content string) (int, error)
- func Remove(path string) error
- func SetLogger(l Logger)
- type FileHandle
- func (fh *FileHandle) AppendContent(content string) (int, error)
- func (fh *FileHandle) Clean() error
- func (fh *FileHandle) Close() error
- func (fh *FileHandle) Exists() bool
- func (fh *FileHandle) GetContent() (string, error)
- func (fh *FileHandle) GetFile(flag ...int) *os.File
- func (fh *FileHandle) Initf(flag int, perm ...os.FileMode) error
- func (fh *FileHandle) IsExpire() bool
- func (fh *FileHandle) PutContent(content string) (int, error)
- func (fh *FileHandle) ResetSeek(seekFlag ...int) (int64, error)
- type FilePool
- func (fp *FilePool) Close()
- func (fp *FilePool) Get(path string, flag int, perm ...os.FileMode) (*FileHandle, error)
- func (fp *FilePool) GetFile2Open(fh *FileHandle) int
- func (fp *FilePool) GetFile2OpenMap() map[string]int
- func (fp *FilePool) MaxFhCount(count int) *FilePool
- func (fp *FilePool) Print(is bool) *FilePool
- func (fp *FilePool) Put(fh *FileHandle, expire ...time.Time)
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendContent ¶ added in v1.1.3
AppendContent 向文件里追加内容
func CronParseLogFile ¶ added in v1.1.9
CronParseLogFile 定时解析增量 log, 返回每行的内容
func PutContent ¶ added in v1.1.3
PutContents 向文件里追加内容
Types ¶
type FileHandle ¶ added in v1.0.2
type FileHandle struct {
// contains filtered or unexported fields
}
FileHandle
func NewFileHandle ¶ added in v1.1.3
func NewFileHandle(path string, expire ...time.Time) *FileHandle
NewFileHandle
func (*FileHandle) AppendContent ¶ added in v1.2.11
func (fh *FileHandle) AppendContent(content string) (int, error)
AppendContent 向文件写入内容, 内容追加
func (*FileHandle) GetContent ¶ added in v1.2.11
func (fh *FileHandle) GetContent() (string, error)
GetContent 查询内容
func (*FileHandle) GetFile ¶ added in v1.0.2
func (fh *FileHandle) GetFile(flag ...int) *os.File
GetFile 获取文件操作句柄
func (*FileHandle) Initf ¶ added in v1.1.3
func (fh *FileHandle) Initf(flag int, perm ...os.FileMode) error
Initf 初始化文件句柄
func (*FileHandle) PutContent ¶ added in v1.2.11
func (fh *FileHandle) PutContent(content string) (int, error)
PutContent 向文件里写内容, 只会覆写
type FilePool ¶
type FilePool struct {
// contains filtered or unexported fields
}
FilePool 文件池
func NewFilePool ¶
NewFilePool 初始化文件池, 最大 256 个 默认会按 defaultExpireDur 进行淘汰 注: 使用结束需要调用 Close 释放还在内存中的句柄
func (*FilePool) Get ¶
Get 获取文件句柄; 如果不存在就会新打开文件句柄; 如果文件/目录不存在会自动创建 注: 1. 调用完需要调用 Put 才能进行复用, 同时句柄不能 Close
- 如果打算不用了的话, 必须调用 *FileHandle.Close 方法进行释放句柄, 防止内存泄露
func (*FilePool) GetFile2Open ¶ added in v1.2.26
func (fp *FilePool) GetFile2Open(fh *FileHandle) int
GetFile2Open 获取文件对应的文件句柄打开数
func (*FilePool) GetFile2OpenMap ¶ added in v1.2.26
GetFile2OpenMap 获取池中所有文件打开的句柄数
func (*FilePool) MaxFhCount ¶ added in v1.2.6
MaxFhCount 设置相同 path 时, 最大文件句柄数
Click to show internal directories.
Click to hide internal directories.