Documentation ¶
Index ¶
- Constants
- func AppendBytesToFile(data []byte, filename string) error
- func AppendPathSeparatorIfNecessary(dir string, as ProcessPathAs) string
- 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 DetectPathOS(path string) (string, bool)
- func DirEmpty(dir string) (bool, error)
- func DirExits(dir string) bool
- func DirJoinDir(srcDir, targetPath string) (string, error)
- func DirJoinFile(srcDir, targetPath string) (string, error)
- 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 IsAbs(path string) bool
- func Join(elem ...string) (string, error)
- func JsonToFile(jsonStruct interface{}, indent bool, filename string) error
- func ListDirContains(dir, contains string) (dirs []string, files []string, err error)
- func ListDirEndWith(dir, tail 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 ReadLines(path string) ([]string, error)
- func RefactShortPathName(path string) string
- func RemoveAllEmptyDirs(rootDir string) error
- func RemoveDir(dir string) error
- func StringToFile(data string, filename string) error
- func WalkDir(dir string) (dirs []string, files []string, err error)
- func WalkDirTopLevel(dir string) (dirs []string, files []string, err error)
- func WriteLines(lines []string, path string) error
- type ChangedEvent
- type DirCopiedSizeCallback
- type FsWatcher
- type PathInfo
- type ProcessPathAs
- type WatchEvent
Constants ¶
const ( AsDirOS = ProcessPathAs("AsDirOS") AsRuntimeOS = ProcessPathAs("AsRuntimeOS") )
const ( Create = WatchEvent(watcher.Create) Write = WatchEvent(watcher.Write) Remove = WatchEvent(watcher.Remove) Rename = WatchEvent(watcher.Rename) Chmod = WatchEvent(watcher.Chmod) Move = WatchEvent(watcher.Move) )
Ops
const (
InvalidFilenameCharsWindows = "\"\\:/*?<>|“”"
)
Variables ¶
This section is empty.
Functions ¶
func AppendBytesToFile ¶
func AppendPathSeparatorIfNecessary ¶
func AppendPathSeparatorIfNecessary(dir string, as ProcessPathAs) string
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 DetectPathOS ¶
func DirJoinDir ¶
srcDir must be detectable Notice: PathJoin("/Users/tony", "test.js") = "/Users/test.js" Notice: DirJoinDir("/Users/tony", "test.js") = "/Users/tony/test.js/" Combine absolute dir path and relative dir path to get a new absolute dir path
func DirJoinFile ¶
srcDir must be detectable Notice: PathJoin("/Users/tony", "test.js") = "/Users/test.js" Notice: DirJoinFile("/Users/tony", "test.js") = "/Users/tony/test.js" Combine absolute dir path and relative file path to get a new absolute file path
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 IsAbs ¶
IsAbs reports whether the path is absolute. This function differs from filepath.IsAbs(), this function can handle paths to different os than the runtime.GOOS, while filepath.IsAbs() can only handle paths to same os as the current runtime.GOOS.
func JsonToFile ¶
func ListDirContains ¶
func ListDirEndWith ¶
func NewTempFilename ¶
Generate a new temp filename for cache
func PathBase ¶
PathBase returns last element of `path`. "/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 WalkDir ¶
WalkDir walks the file tree rooted at dir, it will automatically scan each subdirectory in `dir`.
func WalkDirTopLevel ¶
WalkDirTopLevel lists the top level file/dir at dir, it will NOT scan any subdirectory in `dir`.
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 ProcessPathAs ¶
type ProcessPathAs string
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.