gfs

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 17 Imported by: 52

Documentation

Index

Constants

View Source
const (
	InvalidFilenameCharsWindows = "\"\\:/*?<>|“”"
)

Variables

This section is empty.

Functions

func AppendBytesToFile

func AppendBytesToFile(data []byte, filename string) error

func AppendStringToFile

func AppendStringToFile(data string, filename string) error

func BytesToFile

func BytesToFile(data []byte, filename string) error

func CleanDir

func CleanDir(dir string) error

Remove all content under dir, but keep dir folder

func CopyDir

func CopyDir(src string, dst string) (err error)

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 CopyFile

func CopyFile(src, dst string) (err error)

func CopyFileEx

func CopyFileEx(src, dst string, sizeCallback gio.CopiedSizeCallback) (size int64, err error)

copy file and notify copied size

func CreateAppendFile

func CreateAppendFile(path string) (*os.File, error)

func DirExits

func DirExits(dir string) bool

func DirSize

func DirSize(dir string) (int64, map[string]int64, error)

get total size of directory os.Stat(dir string) read index size of dir, not total size

func DirSlash

func DirSlash() string

func FileExits

func FileExits(filename string) bool

func FileSize

func FileSize(path string) (int64, error)

func FileToBytes

func FileToBytes(filename string) ([]byte, error)

func FileToJson

func FileToJson(filename string, ptrJsonStruct interface{}) error

func FileToString

func FileToString(filename string) (string, error)

func FilenameToReader

func FilenameToReader(filename string) (io.Reader, *os.File, error)

func FilenameToWriter

func FilenameToWriter(filename string) (io.Writer, *os.File, error)

func GetFileByteSize

func GetFileByteSize(filename string) (int64, error)

func GetFileSize

func GetFileSize(filename string) (gvolume.Volume, error)

func JsonToFile

func JsonToFile(jsonStruct interface{}, indent bool, filename string) error

func ListDir

func ListDir(dir string) (dirs []string, files []string, err error)

func ListDirContains

func ListDirContains(dir, contains string) (dirs []string, files []string, err error)

func MakeDir

func MakeDir(dir string) error

func MoveFile

func MoveFile(src, dst string) error

func NewTempFilename

func NewTempFilename() (string, error)

Generate a new temp filename for cache

func PathBase

func PathBase(path string) string

"/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 PathJoin

func PathJoin(source, target string) string

Combine absolute path and relative path to get a new absolute path

func ReadLines

func ReadLines(path string) ([]string, error)

readLines reads a whole file into memory and returns a slice of its lines.

func RefactShortPathName

func RefactShortPathName(path string) string

Replace illegal chars for short filename / dir name, not multi-level directory

func RemoveDir

func RemoveDir(dir string) error

func StringToFile

func StringToFile(data string, filename string) error

func WriteLines

func WriteLines(lines []string, path string) error

writeLines writes the lines to the given file.

Types

type ChangedEvent

type ChangedEvent struct {
	Path  string
	Event WatchEvent
	Err   error
}

type DirCopiedSizeCallback

type DirCopiedSizeCallback func(currSrcFile, currDstFile string, copiedSizeOfCurrFile, copiedSizeOfDir int64)

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

type PathInfo struct {
	Exist        bool
	IsFolder     bool
	ModifiedTime time.Time
}

func GetPathInfo

func GetPathInfo(path string) (*PathInfo, error)

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.

Jump to

Keyboard shortcuts

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