123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package sharefs
- import (
- "errors"
- "io"
- "os"
- "path/filepath"
- "strings"
- "time"
- "imuslab.com/arozos/mod/filesystem/fserror"
- )
- /*
- filesystemAbstraction.go
- This file contains all the abstraction funtion of a local file system.
- */
- type ShareFileSystemAbstraction struct {
- UUID string
- ShareUUIDToVpathResolver func(string) (string, error)
- }
- func NewShareFileSystemAbstraction(uuid string, resolverFunction func(string) (string, error)) ShareFileSystemAbstraction {
- return ShareFileSystemAbstraction{
- UUID: uuid,
- ShareUUIDToVpathResolver: resolverFunction,
- }
- }
- func (l ShareFileSystemAbstraction) Chmod(filename string, mode os.FileMode) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Chown(filename string, uid int, gid int) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Chtimes(filename string, atime time.Time, mtime time.Time) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Create(filename string) (*os.File, error) {
- return nil, nil
- }
- func (l ShareFileSystemAbstraction) Mkdir(filename string, mode os.FileMode) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) MkdirAll(filename string, mode os.FileMode) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Name() string {
- return ""
- }
- func (l ShareFileSystemAbstraction) Open(filename string) (*os.File, error) {
- return nil, nil
- }
- func (l ShareFileSystemAbstraction) OpenFile(filename string, flag int, perm os.FileMode) (*os.File, error) {
- return nil, nil
- }
- func (l ShareFileSystemAbstraction) Remove(filename string) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) RemoveAll(path string) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Rename(oldname, newname string) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) {
- return nil, nil
- }
- /*
- Abstraction Utilities
- */
- func (l ShareFileSystemAbstraction) VirtualPathToRealPath(subpath string, username string) (string, error) {
- subpath = filepath.ToSlash(filepath.Clean(subpath))
- if strings.HasPrefix(subpath, l.UUID+":") {
- subpath = strings.TrimPrefix(subpath, l.UUID+":")
- }
- subpath = subpath[1:] //Trim off the first / from the subpath
- uuid := subpath
- if strings.Contains(subpath, "/") {
- uuid = strings.Split(subpath, "/")[0]
- }
- redirectVpath, err := l.ShareUUIDToVpathResolver(uuid)
- if err != nil {
- return "", err
- }
- return "", fserror.NewRedirectionError(redirectVpath)
- }
- func (l ShareFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) {
- return "", errors.New("SHAREFS WORK IN PROGRESS")
- }
- func (l ShareFileSystemAbstraction) FileExists(realpath string) bool {
- return false
- }
- func (l ShareFileSystemAbstraction) IsDir(realpath string) bool {
- return false
- }
- func (l ShareFileSystemAbstraction) Glob(realpathWildcard string) ([]string, error) {
- return []string{}, nil
- }
- func (l ShareFileSystemAbstraction) GetFileSize(realpath string) int64 {
- return 0
- }
- func (l ShareFileSystemAbstraction) GetModTime(realpath string) (int64, error) {
- return 0, fserror.ErrNullOperation
- }
- func (l ShareFileSystemAbstraction) WriteFile(filename string, content []byte, mode os.FileMode) error {
- return nil
- }
- func (l ShareFileSystemAbstraction) ReadFile(filename string) ([]byte, error) {
- return []byte(""), fserror.ErrNullOperation
- }
- func (l ShareFileSystemAbstraction) WriteStream(filename string, stream io.Reader, mode os.FileMode) error {
- return fserror.ErrOperationNotSupported
- }
- func (l ShareFileSystemAbstraction) ReadStream(filename string) (io.ReadCloser, error) {
- return nil, fserror.ErrOperationNotSupported
- }
- func (l ShareFileSystemAbstraction) Walk(root string, walkFn filepath.WalkFunc) error {
- return fserror.ErrOperationNotSupported
- }
|