Documentation
¶
Index ¶
- Variables
- func BaseName(name string) string
- func Chmod(xfs FileSystem, name string, mode uint32) error
- func Copy(xfs FileSystem, name string, dst string) error
- func DirName(name string) string
- func Exists(xfs FileSystem, name string) (bool, error)
- func ExtName(name string) string
- func IsDir(xfs FileSystem, name string) bool
- func IsFile(xfs FileSystem, name string) bool
- func IsLink(xfs FileSystem, name string) bool
- func MimeType(xfs FileSystem, name string) (string, error)
- func Mkdir(xfs FileSystem, dir string, perm uint32) error
- func MkdirAll(xfs FileSystem, dir string, perm uint32) error
- func MkdirTemp(xfs FileSystem, dir string, pattern string) (string, error)
- func ModTime(xfs FileSystem, name string) (time.Time, error)
- func Mode(xfs FileSystem, name string) (uint32, error)
- func Move(xfs FileSystem, name string, dst string) error
- func ReadDir(xfs FileSystem, dir string, recursive bool) ([]string, error)
- func ReadFile(xfs FileSystem, file string) ([]byte, error)
- func RegisterConnector(c connector.Connector) error
- func Remove(xfs FileSystem, name string) error
- func RemoveAll(xfs FileSystem, name string) error
- func Size(xfs FileSystem, name string) (int, error)
- func WriteFile(xfs FileSystem, file string, data []byte, perm uint32) (int, error)
- type FileSystem
Constants ¶
This section is empty.
Variables ¶
var DownloadWhitelist = map[string]bool{ "pdf": true, "ppt": true, "pptx": true, "xls": true, "xlsx": true, "doc": true, "docx": true, "png": true, "jpg": true, "bmp": true, "svg": true, "tif": true, "mp3": true, "mid": true, "wma": true, "wav": true, "mp4": true, "swf": true, "rm": true, "rmvb": true, "mpg": true, "mpeg": true, "avi": true, "mov": true, "wmv": true, "rar": true, "zip": true, "tar": true, "gz": true, "tar.gz": true, "7z": true, "pkg": true, "dmg": true, "dep": true, "txt": true, "json": true, "jsonc": true, "html": true, "conf": true, "css": true, "js": true, "htm": true, }
DownloadWhitelist the file system allow download
var FileSystemHandlers = map[string]process.Handler{
"readfile": processReadFile,
"readfilebuffer": processReadFileBuffer,
"writefile": processWirteFile,
"writefilebuffer": processWriteFileBuffer,
"readdir": processReadDir,
"mkdir": processMkdir,
"mkdirall": processMkdirAll,
"mkdirtemp": processMkdirTemp,
"remove": processRemove,
"removeall": processRemoveAll,
"exists": processExists,
"isdir": processIsDir,
"isfile": processIsFile,
"islink": processIsLink,
"chmod": processChmod,
"size": processSize,
"mode": processMode,
"modtime": processModTime,
"basename": processBaseName,
"dirname": processDirName,
"extname": processExtName,
"mimetype": processMimeType,
"move": processMove,
"copy": processCopy,
"upload": processUpload,
"download": processDownload,
}
FileSystemHandlers the file system handlers
var FileSystems = map[string]FileSystem{ "system": system.New(), }
FileSystems Register filesystems
var RootFileSystems = map[string]FileSystem{}
RootFileSystems high-level filesystem
Functions ¶
func Chmod ¶
func Chmod(xfs FileSystem, name string, mode uint32) error
Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target. If there is an error, it will be of type *PathError. A different subset of the mode bits are used, depending on the operating system. On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and ModeSticky are used. On Windows, only the 0200 bit (owner writable) of mode is used; it controls whether the file's read-only attribute is set or cleared. The other bits are currently unused. For compatibility with Go 1.12 and earlier, use a non-zero mode. Use mode 0400 for a read-only file and 0600 for a readable+writable file. On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive, and ModeTemporary are used.
func Exists ¶
func Exists(xfs FileSystem, name string) (bool, error)
Exists returns a boolean indicating whether the error is known to report that a file or directory already exists. It is satisfied by ErrExist as well as some syscall errors.
func IsLink ¶
func IsLink(xfs FileSystem, name string) bool
IsLink check the given path is symbolic link
func MimeType ¶
func MimeType(xfs FileSystem, name string) (string, error)
MimeType return the MimeType
func Mkdir ¶
func Mkdir(xfs FileSystem, dir string, perm uint32) error
Mkdir creates a new directory with the specified name and permission bits (before umask). If there is an error, it will be of type *PathError.
func MkdirAll ¶
func MkdirAll(xfs FileSystem, dir string, perm uint32) error
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
func MkdirTemp ¶
func MkdirTemp(xfs FileSystem, dir string, pattern string) (string, error)
MkdirTemp creates a new temporary directory in the directory dir and returns the pathname of the new directory. The new directory's name is generated by adding a random string to the end of pattern. If pattern includes a "*", the random string replaces the last "*" instead. If dir is the empty string, MkdirTemp uses the default directory for temporary files, as returned by TempDir. Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when it is no longer needed.
func ModTime ¶
func ModTime(xfs FileSystem, name string) (time.Time, error)
ModTime return the file modification time
func ReadDir ¶
func ReadDir(xfs FileSystem, dir string, recursive bool) ([]string, error)
ReadDir reads the named directory, returning all its directory entries sorted by filename. If an error occurs reading the directory, ReadDir returns the entries it was able to read before the error, along with the error.
func ReadFile ¶
func ReadFile(xfs FileSystem, file string) ([]byte, error)
ReadFile reads the named file and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.
func RegisterConnector ¶
RegisterConnector register a fileSystem via connector
func Remove ¶
func Remove(xfs FileSystem, name string) error
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func RemoveAll ¶
func RemoveAll(xfs FileSystem, name string) error
RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). If there is an error, it will be of type *PathError.
func Size ¶
func Size(xfs FileSystem, name string) (int, error)
Size return the length in bytes for regular files; system-dependent for others
Types ¶
type FileSystem ¶
type FileSystem interface {
ReadFile(file string) ([]byte, error)
WriteFile(file string, data []byte, perm uint32) (int, error)
ReadDir(dir string, recursive bool) ([]string, error)
Mkdir(dir string, perm uint32) error
MkdirAll(dir string, perm uint32) error
MkdirTemp(dir string, pattern string) (string, error)
Remove(name string) error
RemoveAll(name string) error
Exists(name string) (bool, error)
Size(name string) (int, error)
Mode(name string) (uint32, error)
ModTime(name string) (time.Time, error)
Chmod(name string, mode uint32) error
IsDir(name string) bool
IsFile(name string) bool
IsLink(name string) bool
Move(oldpath string, newpath string) error
Copy(src string, dest string) error
MimeType(name string) (string, error)
}
FileSystem the filesystem io interface
func MustRootGet ¶
func MustRootGet(name string) FileSystem
MustRootGet pick a filesystem via the given name
func RootGet ¶
func RootGet(name string) (FileSystem, error)
RootGet pick a filesystem via the given name (root first)
func RootRegister ¶
func RootRegister(id string, fs FileSystem) FileSystem
RootRegister Register a root FileSystem