Documentation ¶
Index ¶
- Variables
- func CopyFile(dst string, src string) (written int64, err error)
- func CopyFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)
- func CreateFolder(p string, ignoreExists bool) error
- func FileExists(filename string) bool
- func FileNameWithoutExt(filename string) string
- func FolderExists(filename string) bool
- func GetGoroutineId() uint64
- func MoveFile(dst string, src string) (written int64, err error)
- func MoveFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)
- func NewFilename(filename string, tries int, rule func(name string) string) (string, error)
- func ReadDir(name string, ignoreDotFiles bool) (files []os.DirEntry, err error)
- func TouchFile(p string, ignoreExists bool, createFolder bool) error
- type FileInfo
- type IOProgressListener
- type ProgressEvent
- type ProgressEventType
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidWrite = errors.New("invalid write result")
Functions ¶
func CopyFile ¶
CopyFile copies from src to dst until either an error occurs. It returns the number of bytes copied and the first error encountered while copying, if any.
A successful CopyFile returns err == nil, not err == EOF. Because CopyFile is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
func CopyFileWatcher ¶
func CopyFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)
CopyFileWatcher is identical to CopyBuffer except that it provided listener (if one is required).
func CreateFolder ¶
func FileExists ¶
func FileNameWithoutExt ¶
FileNameWithoutExt filename without extension
func FolderExists ¶
func GetGoroutineId ¶
func GetGoroutineId() uint64
func MoveFile ¶
MoveFile move from src to dst until either an error occurs. It returns the number of bytes move and the first error encountered while moving, if any.
A successful MoveFile returns err == nil, not err == EOF. Because MoveFile is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
func MoveFileWatcher ¶
func MoveFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)
MoveFileWatcher is identical to CopyFileWatcher except that it remove the source file when completes
func NewFilename ¶
NewFilename filename exists return new name rule custom name rule
Types ¶
type FileInfo ¶
type FileInfo struct { Name string Path string Mime types.Type Head []byte Width float64 Height float64 Stat os.FileInfo }
func GetFileInfo ¶
GetFileInfo returns a FileInfo describing the named file. If there is an error, fi = nil.
type IOProgressListener ¶
type IOProgressListener interface {
ProgressChanged(event *ProgressEvent)
}
type ProgressEvent ¶
type ProgressEvent struct { ConsumedBytes int64 TotalBytes int64 EventType ProgressEventType }
type ProgressEventType ¶
type ProgressEventType int
const ( // TransferStartedEvent transfer started, set TotalBytes TransferStartedEvent ProgressEventType = 1 + iota // TransferDataEvent transfer data, set ConsumedBytes anmd TotalBytes TransferDataEvent // TransferCompletedEvent transfer completed TransferCompletedEvent // TransferFailedEvent transfer encounters an error TransferFailedEvent )