fs

package
v0.0.0-...-9c21ab8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func GetLastModifyTime

func GetLastModifyTime(path string) (ts int64, err error)

func IsDir

func IsDir(path string) bool

判断所给路径是否为文件夹

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func SaveFile

func SaveFile(fileName string, fileContent string) bool

将给定文本保存为文件

func WatchConfigFiles

func WatchConfigFiles(parsers map[string]IConfigParser)

周期性监测文件变化,调用Parser的回调

Types

type IConfigParser

type IConfigParser interface {
	ReloadConfig(path string, init bool) bool //重载配置
	GetConfig() interface{}                   //获取配置
}

解析器需要实现的接口

type NeuteredFileSystem

type NeuteredFileSystem struct {
	FileSystem http.FileSystem
}

加强版静态文件服务 如果打开文件夹里面有index.html则返回内容,否则直接返回文件

func (NeuteredFileSystem) Open

func (nfs NeuteredFileSystem) Open(path string) (http.File, error)

type ParserMixIn

type ParserMixIn struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

解析器的默认实现,用于嵌套

func (*ParserMixIn) CheckModify

func (pmi *ParserMixIn) CheckModify(path string) (bool, int64)

CheckModify return if modified and last modify time

func (*ParserMixIn) GetPathModifyTime

func (pmi *ParserMixIn) GetPathModifyTime(path string) int64

GetPathLastModifyTime

func (*ParserMixIn) SetLastModifyTime

func (pmi *ParserMixIn) SetLastModifyTime(path string, ts int64)

SetLastModifyTime update lastModifyTime

Jump to

Keyboard shortcuts

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