Documentation
¶
Overview ¶
package vfs provides a set of utilities for working with virtual file systems in Go.
Index ¶
- type BaseFile
- type BaseVFS
- func (b *BaseVFS) Copy(src, dst *url.URL) (err error)
- func (b *BaseVFS) CopyRaw(src, dst string) (err error)
- func (b *BaseVFS) CreateRaw(u string) (file VFile, err error)
- func (b *BaseVFS) Delete(src *url.URL) (err error)
- func (b *BaseVFS) DeleteMatching(location *url.URL, filter FileFilter) (err error)
- func (b *BaseVFS) DeleteRaw(u string) (err error)
- func (b *BaseVFS) Find(location *url.URL, filter FileFilter) (files []VFile, err error)
- func (b *BaseVFS) List(src *url.URL) (files []VFile, err error)
- func (b *BaseVFS) ListRaw(src string) (files []VFile, err error)
- func (b *BaseVFS) MkdirAllRaw(u string) (vFile VFile, err error)
- func (b *BaseVFS) MkdirRaw(u string) (vFile VFile, err error)
- func (b *BaseVFS) Move(src, dst *url.URL) (err error)
- func (b *BaseVFS) MoveRaw(src, dst string) (err error)
- func (b *BaseVFS) OpenRaw(l string) (file VFile, err error)
- func (b *BaseVFS) Walk(u *url.URL, fn WalkFn) (err error)
- func (b *BaseVFS) WalkRaw(raw string, fn WalkFn) (err error)
- type FileFilter
- type Manager
- type OsFile
- func (o *OsFile) AddProperty(name string, value string) error
- func (o *OsFile) Close() error
- func (o *OsFile) ContentType() string
- func (o *OsFile) Delete() error
- func (o *OsFile) DeleteAll() error
- func (o *OsFile) GetProperty(name string) (v string, err error)
- func (o *OsFile) Info() (VFileInfo, error)
- func (o *OsFile) ListAll() (files []VFile, err error)
- func (o *OsFile) Parent() (file VFile, err error)
- func (o *OsFile) Read(b []byte) (int, error)
- func (o *OsFile) Seek(offset int64, whence int) (int64, error)
- func (o *OsFile) Url() *url.URL
- func (o *OsFile) Write(b []byte) (int, error)
- type OsFs
- type VFile
- type VFileContent
- type VFileInfo
- type VFileSystem
- type WalkFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseVFS ¶
type BaseVFS struct {
VFileSystem
}
func (*BaseVFS) DeleteMatching ¶
func (b *BaseVFS) DeleteMatching(location *url.URL, filter FileFilter) (err error)
type FileFilter ¶
type Manager ¶
type Manager interface {
VFileSystem
Register(vfs VFileSystem)
IsSupported(scheme string) bool
}
func GetManager ¶
func GetManager() Manager
type OsFile ¶
func (*OsFile) ContentType ¶
type VFile ¶
type VFile interface {
//Closer interface included from io package
io.Closer
//VFileContent provider interface included
VFileContent
//ListAll children of this file instance. can be nil in case of file object instead of directory
ListAll() ([]VFile, error)
//Delete the file object. If the file type is directory all files and subdirectories will be deleted
Delete() error
//DeleteAll deletes all the files and it's subdirectories
DeleteAll() error
//Info Get the file ifo
Info() (VFileInfo, error)
//Parent of the file system
Parent() (VFile, error)
//Url of the file
Url() *url.URL
// AddProperty will add a property to the file
AddProperty(name string, value string) error
// GetProperty will add a property to the file
GetProperty(name string) (string, error)
}
VFile interface provides the basic functions required to interact
type VFileContent ¶
type VFileContent interface {
io.ReadWriteSeeker
//AsString content of the file. This should be used very carefully as it is not wise to load a large file in to string
AsString() (string, error)
//AsBytes content of the file.This should be used very carefully as it is not wise to load a large file into an array
AsBytes() ([]byte, error)
//WriteString method with write the string
WriteString(s string) (int, error)
//ContentType of the underlying content. If not set defaults to UTF-8 for text files
ContentType() string
}
VFileContent interface providers access to the content
type VFileSystem ¶
type VFileSystem interface {
//Copy File from one location to another. If the source resolves to a directory, then all its nested children
//will be copied. The source and destination can be of different filesystems.
//Since the FS can be different it cannot guarantee to carry forward any symbolic links/shortcuts from source
//instead it may try to create regular files/directories for the same even if the source and destination have
//the same schemes
Copy(src, dst *url.URL) error
//CopyRaw is same as Copy except it accepts url as string
CopyRaw(src, dst string) error
//Create will create a new file this in the specified url. This is a
Create(u *url.URL) (VFile, error)
//CreateRaw is same as Create except it accepts the url as a string
CreateRaw(raw string) (VFile, error)
//Delete file . if the src resolves to a directory then all the files and directories under this will be deleted
Delete(src *url.URL) error
//DeleteRaw is same as Delete except that it will accept url as a string
DeleteRaw(src string) error
//List function will list all the files if the type is a directory
List(url *url.URL) ([]VFile, error)
//ListRaw lists the file in the filesystem for a specific url
ListRaw(url string) ([]VFile, error)
//Mkdir will create the directory and will throw an error if exists or has permission issues or unable to create
Mkdir(u *url.URL) (VFile, error)
//MkdirRaw same as Mkdir, however it accepts url as string
MkdirRaw(u string) (VFile, error)
//MkdirAll will create all directories missing in the path
//If the directory already exists it will not throw error, however if the path resolves to a file instead
//it should error
MkdirAll(u *url.URL) (VFile, error)
//MkdirAllRaw same as MkdirAll, however it accepts url as string
MkdirAllRaw(u string) (VFile, error)
//Move will
Move(src, dst *url.URL) error
//MoveRaw same as Move except it accepts url as string
MoveRaw(src, dst string) error
//Open a file based on the url of the file
Open(u *url.URL) (VFile, error)
// OpenRaw is same as Open function, however it accepts the url as string
OpenRaw(u string) (VFile, error)
//Schemes is the list of schemes supported by this file system
Schemes() []string
//Walk will walk through each of the files in the directory recursively.
//If the URL resolves to a file it's not expected to throw an error instead the fn just be invoked with the VFile
//representing the url once
Walk(url *url.URL, fn WalkFn) error
//Find files based on filter only works if the file.IsDir() is true
Find(location *url.URL, filter FileFilter) ([]VFile, error)
//WalkRaw is same as Walk except that it will accept the url as a string
WalkRaw(raw string, fn WalkFn) error
//DeleteMatching will delete only the files that match the filter.
//If one of the file deletion fails with an error then it stops processing and returns error
DeleteMatching(location *url.URL, filter FileFilter) error
}
Click to show internal directories.
Click to hide internal directories.