|
@@ -1,11 +1,12 @@
|
|
|
package emptyfs
|
|
|
|
|
|
import (
|
|
|
- "errors"
|
|
|
"io"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
"time"
|
|
|
+
|
|
|
+ "imuslab.com/arozos/mod/filesystem/fserror"
|
|
|
)
|
|
|
|
|
|
/*
|
|
@@ -23,43 +24,43 @@ func NewEmptyFileSystemAbstraction() EmptyFileSystemAbstraction {
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) Chmod(filename string, mode os.FileMode) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Chown(filename string, uid int, gid int) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Chtimes(filename string, atime time.Time, mtime time.Time) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Create(filename string) (*os.File, error) {
|
|
|
- return nil, nil
|
|
|
+ return nil, fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Mkdir(filename string, mode os.FileMode) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) MkdirAll(filename string, mode os.FileMode) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Name() string {
|
|
|
return ""
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Open(filename string) (*os.File, error) {
|
|
|
- return nil, nil
|
|
|
+ return nil, fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) OpenFile(filename string, flag int, perm os.FileMode) (*os.File, error) {
|
|
|
- return nil, nil
|
|
|
+ return nil, fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Remove(filename string) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) RemoveAll(path string) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Rename(oldname, newname string) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) {
|
|
|
- return nil, nil
|
|
|
+ return nil, fserror.ErrNullOperation
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -67,11 +68,11 @@ func (l EmptyFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) {
|
|
|
*/
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) VirtualPathToRealPath(subpath string, username string) (string, error) {
|
|
|
- return "", errors.New("empty filesystem abstraction")
|
|
|
+ return "", fserror.ErrVpathResolveFailed
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) {
|
|
|
- return "", errors.New("empty filesystem abstraction")
|
|
|
+ return "", fserror.ErrRpathResolveFailed
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) FileExists(realpath string) bool {
|
|
@@ -83,7 +84,7 @@ func (l EmptyFileSystemAbstraction) IsDir(realpath string) bool {
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) Glob(realpathWildcard string) ([]string, error) {
|
|
|
- return []string{}, nil
|
|
|
+ return []string{}, fserror.ErrNullOperation
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) GetFileSize(realpath string) int64 {
|
|
@@ -91,22 +92,22 @@ func (l EmptyFileSystemAbstraction) GetFileSize(realpath string) int64 {
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) GetModTime(realpath string) (int64, error) {
|
|
|
- return 0, errors.New("empty filesystem abstraction")
|
|
|
+ return 0, fserror.ErrOperationNotSupported
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) WriteFile(filename string, content []byte, mode os.FileMode) error {
|
|
|
- return nil
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) ReadFile(filename string) ([]byte, error) {
|
|
|
- return []byte(""), errors.New("empty filesystem abstraction")
|
|
|
+ return []byte(""), fserror.ErrOperationNotSupported
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) WriteStream(filename string, stream io.Reader, mode os.FileMode) error {
|
|
|
- return errors.New("operation not supported on dummy file system")
|
|
|
+ return fserror.ErrNullOperation
|
|
|
}
|
|
|
func (l EmptyFileSystemAbstraction) ReadStream(filename string) (io.ReadCloser, error) {
|
|
|
- return nil, errors.New("operation not supported on dummy file system")
|
|
|
+ return nil, fserror.ErrOperationNotSupported
|
|
|
}
|
|
|
|
|
|
func (l EmptyFileSystemAbstraction) Walk(root string, walkFn filepath.WalkFunc) error {
|
|
|
- return errors.New("empty filesystem abstraction")
|
|
|
+ return fserror.ErrOperationNotSupported
|
|
|
}
|