Documentation
¶
Overview ¶
Package fs provides filesystem operations.
To get a handle to existing fs-entry, you can use:
- `fs.GetFileHandle(path string)` for a file handle
- `fs.GetDirHandle(path string)` for a directory handle
this operations fail if the request entry does not exists.
To get or create a directory handle use
- `fs.GetOrCreateDirHandle(path string, perm os.FilePerm)`
- `fs.GetOrCreateSubDirHandle(name string, perm os.FilePerm)`
Index ¶
- type DirHandle
- func (self *DirHandle) CreateArchive(name string) (FileHandle, error)
- func (self *DirHandle) GetFileHandle(name string) (FileHandle, error)
- func (self *DirHandle) GetOrCreateSubDirHandle(name string, perm os.FileMode) (DirHandle, error)
- func (self *DirHandle) GetSubDirHandle(name string) (DirHandle, error)
- func (self *DirHandle) Ls() ([]FSHandle, error)
- func (self *DirHandle) ReadFile(name string) ([]byte, error)
- func (self *DirHandle) WriteFile(name string, data []byte, perm os.FileMode) (FileHandle, error)
- type FSHandle
- type FileHandle
- func (self *FileHandle) Backup() (string, error)
- func (fh *FileHandle) Copy(path string) (err error)
- func (self *FileHandle) CopyTo(w io.Writer) error
- func (self *FileHandle) MimeType() (string, error)
- func (self *FileHandle) Read() ([]byte, error)
- func (self *FileHandle) ReadString() (string, error)
- func (self *FileHandle) Remove() error
- type Kind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirHandle ¶
type DirHandle struct {
FSHandle
}
DirHandle represents a directory
func GetDirHandle ¶
GetDirHandle returns a handle to a existing directory. If the directory does not exists, a error is returned.
func GetOrCreateDirHandle ¶
GetOrCreateDirHandle returns a handle to a existing or a new created directory.
func (*DirHandle) CreateArchive ¶
func (self *DirHandle) CreateArchive(name string) (FileHandle, error)
func (*DirHandle) GetFileHandle ¶
func (self *DirHandle) GetFileHandle(name string) (FileHandle, error)
GetFileHandle returns a handle to a existing file in the current dir-handle
func (*DirHandle) GetOrCreateSubDirHandle ¶
GetOrCreateSubDirHandle returns a handle to a existing or a new created child-dir of the current dir-handle.
func (*DirHandle) GetSubDirHandle ¶
GetSubDirHandle returns a child-dir of the current dir-handle. This operation fails if the requested directory does not exists.
func (*DirHandle) Ls ¶
Ls returns a directory listing of the current dir-handle. Directory and filenames are grouped and sorted by names.
type FSHandle ¶
type FSHandle struct { Name string `json:"name"` Path string `json:"path"` Kind Kind `json:"kind"` Size int64 `json:"size"` MTime time.Time `json:"mtime"` }
FSHandle represents a handle to a filesystem entry
This can be a file, a directory or anything else.
func (*FSHandle) AsDirHandle ¶
func (*FSHandle) AsFileHandle ¶
func (self *FSHandle) AsFileHandle() (FileHandle, error)
type FileHandle ¶
type FileHandle struct {
FSHandle
}
FileHandle represents a file
func GetFileHandle ¶
func GetFileHandle(path string) (FileHandle, error)
GetFileHandle returns a handle to a existing file. If the file does not exists, a error is returned. To create a file, use 'DirHandle.WriteFile'.
func (*FileHandle) Backup ¶
func (self *FileHandle) Backup() (string, error)
Backup create a backup of the file in the backup location.
func (*FileHandle) CopyTo ¶
func (self *FileHandle) CopyTo(w io.Writer) error
CopyTo copies the whole file content into a given writer.
func (*FileHandle) MimeType ¶
func (self *FileHandle) MimeType() (string, error)
MimeType returns file mime-type. This functions makes io-operations to read a part of the file.
func (*FileHandle) Read ¶
func (self *FileHandle) Read() ([]byte, error)
Read returns the whole file content as a byte array.
func (*FileHandle) ReadString ¶
func (self *FileHandle) ReadString() (string, error)
ReadString returns the whole file content as a string.
type Kind ¶
type Kind int