Documentation ¶
Index ¶
- Constants
- func ChangeOwner(path, owner, group string) error
- func ChangeOwnerExecWithSudo(path, owner, group string) error
- func GetFileUIDAndGID(file string) (uid, gid uint32, err error)
- func Md5HashFromReader(source io.Reader) (hashSum []byte, err error)
- func Md5HashMatch(expectedHashSum []byte, path string, fileAPI FileAPI) (match bool, err error)
- func MoveExecWithSudo(sourcePath, targetPath string) error
- func Rename(oldPath, newPath string) error
- type FileAPI
- type FileSystem
- func (f *FileSystem) ChangeMode(path string, targetMode os.FileMode) error
- func (f *FileSystem) ChangeOwner(path, owner, group string) error
- func (f *FileSystem) CreateDirIfNotExists(path string, mode os.FileMode) (wasCreated bool, err error)
- func (f *FileSystem) CreateFile(path string, sourceReader io.Reader) (writtenBytes int64, err error)
- func (f *FileSystem) Exist(path string) (bool, error)
- func (f *FileSystem) GetFileMode(file string) (os.FileMode, error)
- func (f *FileSystem) GetFileOwnerAndGroup(file string) (uid, gid uint32, err error)
- func (f *FileSystem) MakeDirAll(dir string) error
- func (f *FileSystem) Open(file string) (io.ReadWriteCloser, error)
- func (f *FileSystem) ReadDir(dir string) ([]os.FileInfo, error)
- func (f *FileSystem) ReadJSON(file string, dest interface{}) error
- func (f *FileSystem) Remove(name string) error
- func (f *FileSystem) Rename(oldPath, newPath string) error
- func (f *FileSystem) Write(fileName string, content string) error
- func (f *FileSystem) WriteJSON(fileName string, content interface{}) error
Constants ¶
const DefaultMode = os.FileMode(0764)
const DefaultUploadTempFolder = "filepush"
Variables ¶
This section is empty.
Functions ¶
func ChangeOwner ¶
func ChangeOwnerExecWithSudo ¶
func GetFileUIDAndGID ¶
func Md5HashMatch ¶
func MoveExecWithSudo ¶
Types ¶
type FileAPI ¶
type FileAPI interface { ReadDir(dir string) ([]os.FileInfo, error) MakeDirAll(dir string) error WriteJSON(file string, content interface{}) error Write(file string, content string) error ReadJSON(file string, dest interface{}) error Open(file string) (io.ReadWriteCloser, error) Exist(path string) (bool, error) CreateFile(path string, sourceReader io.Reader) (writtenBytes int64, err error) ChangeOwner(path, owner, group string) error ChangeMode(path string, targetMode os.FileMode) error CreateDirIfNotExists(path string, mode os.FileMode) (wasCreated bool, err error) Remove(name string) error Rename(oldPath, newPath string) error GetFileMode(file string) (os.FileMode, error) GetFileOwnerAndGroup(file string) (uid, gid uint32, err error) }
type FileSystem ¶
type FileSystem struct { }
func NewFileSystem ¶
func NewFileSystem() *FileSystem
func (*FileSystem) ChangeMode ¶
func (f *FileSystem) ChangeMode(path string, targetMode os.FileMode) error
func (*FileSystem) ChangeOwner ¶
func (f *FileSystem) ChangeOwner(path, owner, group string) error
func (*FileSystem) CreateDirIfNotExists ¶
func (*FileSystem) CreateFile ¶
func (*FileSystem) Exist ¶
func (f *FileSystem) Exist(path string) (bool, error)
Exist returns a boolean indicating whether a file or directory with a given path exists.
func (*FileSystem) GetFileMode ¶
func (f *FileSystem) GetFileMode(file string) (os.FileMode, error)
func (*FileSystem) GetFileOwnerAndGroup ¶
func (f *FileSystem) GetFileOwnerAndGroup(file string) (uid, gid uint32, err error)
func (*FileSystem) MakeDirAll ¶
func (f *FileSystem) MakeDirAll(dir string) error
MakeDirAll creates a given directory along with any necessary parents. If path is already a directory, it does nothing and returns nil. It is created with mode 0777.
func (*FileSystem) Open ¶
func (f *FileSystem) Open(file string) (io.ReadWriteCloser, error)
func (*FileSystem) ReadDir ¶
func (f *FileSystem) ReadDir(dir string) ([]os.FileInfo, error)
ReadDir reads the given directory and returns a list of directory entries sorted by filename.
func (*FileSystem) ReadJSON ¶
func (f *FileSystem) ReadJSON(file string, dest interface{}) error
ReadJSON reads a given file and stores the parsed content into a destination value. A successful call returns err == nil, not err == EOF.
func (*FileSystem) Remove ¶
func (f *FileSystem) Remove(name string) error
func (*FileSystem) Rename ¶
func (f *FileSystem) Rename(oldPath, newPath string) error
func (*FileSystem) Write ¶
func (f *FileSystem) Write(fileName string, content string) error
Write creates or truncates a given file and writes a given content to it. If the file does not exist, it is created with mode 0666.
func (*FileSystem) WriteJSON ¶
func (f *FileSystem) WriteJSON(fileName string, content interface{}) error
WriteJSON creates or truncates a given file and writes a given content to it as JSON with indentation. If the file does not exist, it is created with mode 0666.