Documentation
¶
Overview ¶
进行一些基本的文件操作 参考: https://colobu.com/2016/10/12/go-file-operations/
进行log封装,用于对cc log进行区分
进行归档时候的操作
Index ¶
- Variables
- func DMImageDecode(ext string, f *os.File) (img image.Image, e error)
- func DMImageEncode(ext string, img image.Image) (buf *bytes.Buffer, e error)
- func DMRootPath() string
- func Fail(val ...interface{})
- func Fatal(val ...interface{})
- func Info(val ...interface{})
- func Success(val ...interface{})
- type DMFileInfo
- type DMFileInfoViewModel
- type DMForableTaskSharedList
- type DMImage
- type DMImageFile
- type DMNotifyFile
- type DMResource
- func (R DMResource) Exists() bool
- func (pR *DMResource) GetBasicFileInfo() (dfi *DMFileInfo, e error)
- func (R DMResource) GetExt() (ext string, e error)
- func (R DMResource) GetGenre() string
- func (R DMResource) GetMD5() (md5str string, e error)
- func (R DMResource) GetMD5Mask() (md5str string, e error)
- func (R DMResource) GetSize() (int64, error)
- func (R DMResource) IsBinaryDirectory1() bool
- func (R DMResource) IsDire() bool
- func (R DMResource) IsFile() bool
- func (R DMResource) Ls() (rs []DMResource, e error)
- func (R DMResource) LsLimited(head, end int) (totalCount int, rs []DMResource, e error)
- func (R DMResource) LsRecruit(status *DMTaskStatus) []DMResource
- func (R DMResource) LsRecruitCount() int
- func (R DMResource) ToReadable() *DMFileInfoViewModel
- type DMTaskStatus
- func (pR *DMTaskStatus) Abort(e error)
- func (pR *DMTaskStatus) Error(e error)
- func (pR *DMTaskStatus) Finished()
- func (R DMTaskStatus) IsTimeout() bool
- func (pR *DMTaskStatus) Msg(msg string)
- func (pR *DMTaskStatus) MsgStage(msg string)
- func (R *DMTaskStatus) TryLock()
- func (R DMTaskStatus) UsedTime() time.Duration
- type DMTaskStatusList
- type DMWatchEventFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // http 请求-读写 // websocket 只读 )
View Source
var ( DMExts = map[string][]string{ "image": []string{ ".png", ".jpeg", ".jpg", ".gif", ".bmp", ".psd", ".ai", ".eps", ".tif", ".tiff", ".webp", ".raw", ".svg", ".svgz", }, "video": []string{ ".flv", ".mp4", ".mov", ".wmv", ".avi", ".flv", ".mkv", ".swf", }, "music": []string{ ".mp3", ".flac", ".wav", ".ape", }, "backup": []string{ ".rar", ".zip", ".tar", ".bk", ".backup", }, "document": []string{ ".doc", ".docx", ".pdf", ".ppt", ".pptx", ".xls", ".xlsx", ".xla", ".md", ".txt", ".text", }, } )
Functions ¶
func DMImageEncode ¶
有损格式均为默认选项
Types ¶
type DMFileInfo ¶
type DMFileInfo struct { Name string // base name of the file Size int64 // length in bytes for regular files; system-dependent for others Mode os.FileMode // file mode bits ModTime time.Time // modification time IsDir bool // abbreviation for Mode().IsDire() Sys interface{} // underlying data source (can return nil) }
详见os包中的 types.go 用于方便转化为json对象
type DMFileInfoViewModel ¶
type DMFileInfoViewModel struct { Name string Size int64 Mode string ModTime string IsDir bool Sys interface{} }
详见os包中的 types.go 用于方便转化为json对象
type DMForableTaskSharedList ¶
type DMForableTaskSharedList struct {}
type DMImage ¶
type DMImage struct {
DMResource
}
func (DMImage) Open ¶
func (R DMImage) Open() (If DMImageFile, e error)
type DMImageFile ¶
func (DMImageFile) Resize ¶
func (R DMImageFile) Resize(maxW, maxH uint) DMImageFile
func (DMImageFile) ToBase64 ¶
func (R DMImageFile) ToBase64() (b64 string, er error)
type DMNotifyFile ¶
type DMNotifyFile struct { Watch *fsnotify.Watcher Create, Write, Remove, Rename, Chmod DMWatchEventFunc }
func DMNewNotifyFileEmpty ¶
func DMNewNotifyFileEmpty() *DMNotifyFile
func (*DMNotifyFile) AddWatchDirRecruit ¶
func (pR *DMNotifyFile) AddWatchDirRecruit(dir string) (e error)
递归监控目录 dir
func (*DMNotifyFile) RemoveWatchDirRecruit ¶
func (pR *DMNotifyFile) RemoveWatchDirRecruit(dir string) (e error)
func (*DMNotifyFile) WatchEvent ¶
func (pR *DMNotifyFile) WatchEvent()
type DMResource ¶
type DMResource struct { DMFileInfo // 一个资源的绝对路径 Path string }
func DMRecruitLs ¶
func DMRecruitLs(r DMResource, taskStatus *DMTaskStatus) (rs []DMResource)
递归某个目录的所有文件 结果不包含 r 自身 不会递归二进制文件夹,见 IsBinaryDirectory1()
func (DMResource) Exists ¶
func (R DMResource) Exists() bool
func (*DMResource) GetBasicFileInfo ¶
func (pR *DMResource) GetBasicFileInfo() (dfi *DMFileInfo, e error)
获取文件的基本信息
func (DMResource) GetExt ¶
func (R DMResource) GetExt() (ext string, e error)
获取文件扩展名 返回形如 ".ext" e != nil 时表明路径非法或为一个目录
func (DMResource) GetMD5 ¶
func (R DMResource) GetMD5() (md5str string, e error)
获取某个文件的md5 路径直接返回空字符串
func (DMResource) GetSize ¶
func (R DMResource) GetSize() (int64, error)
获取文件或文件夹的大小 与属性Size不同,当接收者为路径时GetSize可以返回文件夹的递归大小
func (DMResource) IsBinaryDirectory1 ¶
func (R DMResource) IsBinaryDirectory1() bool
如果目录下有exe文件,说明这个目录为二进制软件的目录 判断方式1
func (DMResource) IsFile ¶
func (R DMResource) IsFile() bool
func (DMResource) Ls ¶
func (R DMResource) Ls() (rs []DMResource, e error)
枚举所有的子文件夹 ls会自动调用所有子资源的GetBasicFileInfo进行填充
func (DMResource) LsLimited ¶
func (R DMResource) LsLimited(head, end int) (totalCount int, rs []DMResource, e error)
枚举所有的子文件夹 ls会自动调用所有子资源的GetBasicFileInfo进行填充
func (DMResource) LsRecruit ¶
func (R DMResource) LsRecruit(status *DMTaskStatus) []DMResource
包含 R 自身
func (DMResource) ToReadable ¶
func (R DMResource) ToReadable() *DMFileInfoViewModel
type DMTaskStatus ¶
type DMTaskStatus struct { TaskName string IsUni bool Progress int ProgressMax int ProgressStage string IsFinished, Pause bool StartTime time.Time TimeoutSec float64 CurrentMsg string // 当前工作的信息 Errors []error // bad design Terminal bool SpanIntervalMSec int64 // 自旋时间间隔 }
func (*DMTaskStatus) Abort ¶
func (pR *DMTaskStatus) Abort(e error)
func (*DMTaskStatus) Error ¶
func (pR *DMTaskStatus) Error(e error)
func (*DMTaskStatus) Finished ¶
func (pR *DMTaskStatus) Finished()
func (DMTaskStatus) IsTimeout ¶
func (R DMTaskStatus) IsTimeout() bool
func (*DMTaskStatus) Msg ¶
func (pR *DMTaskStatus) Msg(msg string)
func (*DMTaskStatus) MsgStage ¶
func (pR *DMTaskStatus) MsgStage(msg string)
func (DMTaskStatus) UsedTime ¶
func (R DMTaskStatus) UsedTime() time.Duration
type DMTaskStatusList ¶
type DMTaskStatusList struct { Lists map[string][]DMTaskStatus Errors []error }
func (*DMTaskStatusList) AddTask ¶
func (pR *DMTaskStatusList) AddTask(taskName string, isUni bool, timeout float64, progressMax int, SpanIntervalMSec int64) error
尝试创建一个unique的任务时返回错误
func (DMTaskStatusList) ToForable ¶
func (R DMTaskStatusList) ToForable() (fs []DMForableTaskSharedList)
type DMWatchEventFunc ¶
Click to show internal directories.
Click to hide internal directories.