Documentation ¶
Index ¶
- Constants
- func AppendBytesToFile(data []byte, filename string) error
- func AppendStringToFile(data string, filename string) error
- func BytesToFile(data []byte, filename string) error
- func CleanDir(dir string) error
- func CopyDir(src string, dst string) (err error)
- func CopyDirEx(src string, dst string, dirSizeCallback DirCopiedSizeCallback) (err error)
- func CopyFile(src, dst string) (err error)
- func CopyFileEx(src, dst string, sizeCallback gio.CopiedSizeCallback) (size int64, err error)
- func CreateAppendFile(path string) (*os.File, error)
- func DirExits(dir string) bool
- func DirSize(dir string) (int64, map[string]int64, error)
- func DirSlash() string
- func FileExits(filename string) bool
- func FileSize(path string) (int64, error)
- func FileToBytes(filename string) ([]byte, error)
- func FileToJson(filename string, ptrJsonStruct interface{}) error
- func FileToString(filename string) (string, error)
- func FilenameToReader(filename string) (io.Reader, *os.File, error)
- func FilenameToWriter(filename string) (io.Writer, *os.File, error)
- func GetFileByteSize(filename string) (int64, error)
- func GetFileSize(filename string) (gvolume.Volume, error)
- func JsonToFile(jsonStruct interface{}, indent bool, filename string) error
- func ListDir(dir string) (dirs []string, files []string, err error)
- func ListDirContains(dir, contains string) (dirs []string, files []string, err error)
- func MakeDir(dir string) error
- func MoveFile(src, dst string) error
- func NewTempFilename() (string, error)
- func PathBase(path string) string
- func PathJoin(source, target string) string
- func ReadLines(path string) ([]string, error)
- func RefactShortPathName(path string) string
- func RemoveDir(dir string) error
- func StringToFile(data string, filename string) error
- func WriteLines(lines []string, path string) error
- type ChangedEvent
- type DirCopiedSizeCallback
- type FsWatcher
- type PathInfo
- type WatchEvent
Constants ¶
const (
InvalidFilenameCharsWindows = "\"\\:/*?<>|“”"
)
Variables ¶
This section is empty.
Functions ¶
func AppendBytesToFile ¶
func AppendStringToFile ¶
func BytesToFile ¶
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.
func CopyDirEx ¶
func CopyDirEx(src string, dst string, dirSizeCallback DirCopiedSizeCallback) (err error)
func CopyFileEx ¶
func CopyFileEx(src, dst string, sizeCallback gio.CopiedSizeCallback) (size int64, err error)
copy file and notify copied size
func DirSize ¶
get total size of directory os.Stat(dir string) read index size of dir, not total size
func FileToBytes ¶
func FileToJson ¶
func FileToString ¶
func GetFileByteSize ¶
func JsonToFile ¶
func ListDirContains ¶
func NewTempFilename ¶
Generate a new temp filename for cache
func PathBase ¶
"/root/home/abc.txt" -> "abc.txt" note: this function doesn't work if file name contains '/', like "mydir/a/b.txt" and real file name is "a/b.txt"
func RefactShortPathName ¶
Replace illegal chars for short filename / dir name, not multi-level directory
func StringToFile ¶
func WriteLines ¶
writeLines writes the lines to the given file.
Types ¶
type ChangedEvent ¶
type ChangedEvent struct { Path string Event WatchEvent Err error }
type DirCopiedSizeCallback ¶
type FsWatcher ¶
type FsWatcher struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
func NewWatcher() *FsWatcher
func (*FsWatcher) Loop ¶
func (w *FsWatcher) Loop(path string, evts WatchEvent, interval time.Duration, notifyCh chan ChangedEvent) (err error)
this function is block
type PathInfo ¶
func GetPathInfo ¶
type WatchEvent ¶
type WatchEvent uint32
An WatchEvent is a type that is used to describe what type of event has occurred during the watching process.
const ( Create WatchEvent = WatchEvent(watcher.Create) Write WatchEvent = WatchEvent(watcher.Write) Remove WatchEvent = WatchEvent(watcher.Remove) Rename WatchEvent = WatchEvent(watcher.Rename) Chmod WatchEvent = WatchEvent(watcher.Chmod) Move WatchEvent = WatchEvent(watcher.Move) )
Ops