emptyfs.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package emptyfs
  2. import (
  3. "io"
  4. "os"
  5. "path/filepath"
  6. "time"
  7. "imuslab.com/arozos/mod/filesystem/fsdef"
  8. )
  9. /*
  10. filesystemAbstraction.go
  11. This file contains all the abstraction funtion of a local file system.
  12. */
  13. type EmptyFileSystemAbstraction struct {
  14. }
  15. func NewEmptyFileSystemAbstraction() EmptyFileSystemAbstraction {
  16. return EmptyFileSystemAbstraction{}
  17. }
  18. func (l EmptyFileSystemAbstraction) Chmod(filename string, mode os.FileMode) error {
  19. return fsdef.ErrNullOperation
  20. }
  21. func (l EmptyFileSystemAbstraction) Chown(filename string, uid int, gid int) error {
  22. return fsdef.ErrNullOperation
  23. }
  24. func (l EmptyFileSystemAbstraction) Chtimes(filename string, atime time.Time, mtime time.Time) error {
  25. return fsdef.ErrNullOperation
  26. }
  27. func (l EmptyFileSystemAbstraction) Create(filename string) (*os.File, error) {
  28. return nil, fsdef.ErrNullOperation
  29. }
  30. func (l EmptyFileSystemAbstraction) Mkdir(filename string, mode os.FileMode) error {
  31. return fsdef.ErrNullOperation
  32. }
  33. func (l EmptyFileSystemAbstraction) MkdirAll(filename string, mode os.FileMode) error {
  34. return fsdef.ErrNullOperation
  35. }
  36. func (l EmptyFileSystemAbstraction) Name() string {
  37. return ""
  38. }
  39. func (l EmptyFileSystemAbstraction) Open(filename string) (*os.File, error) {
  40. return nil, fsdef.ErrNullOperation
  41. }
  42. func (l EmptyFileSystemAbstraction) OpenFile(filename string, flag int, perm os.FileMode) (*os.File, error) {
  43. return nil, fsdef.ErrNullOperation
  44. }
  45. func (l EmptyFileSystemAbstraction) Remove(filename string) error {
  46. return fsdef.ErrNullOperation
  47. }
  48. func (l EmptyFileSystemAbstraction) RemoveAll(path string) error {
  49. return fsdef.ErrNullOperation
  50. }
  51. func (l EmptyFileSystemAbstraction) Rename(oldname, newname string) error {
  52. return fsdef.ErrNullOperation
  53. }
  54. func (l EmptyFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) {
  55. return nil, fsdef.ErrNullOperation
  56. }
  57. /*
  58. Abstraction Utilities
  59. */
  60. func (l EmptyFileSystemAbstraction) VirtualPathToRealPath(subpath string, username string) (string, error) {
  61. return "", fsdef.ErrVpathResolveFailed
  62. }
  63. func (l EmptyFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) {
  64. return "", fsdef.ErrRpathResolveFailed
  65. }
  66. func (l EmptyFileSystemAbstraction) FileExists(realpath string) bool {
  67. return false
  68. }
  69. func (l EmptyFileSystemAbstraction) IsDir(realpath string) bool {
  70. return false
  71. }
  72. func (l EmptyFileSystemAbstraction) Glob(realpathWildcard string) ([]string, error) {
  73. return []string{}, fsdef.ErrNullOperation
  74. }
  75. func (l EmptyFileSystemAbstraction) GetFileSize(realpath string) int64 {
  76. return 0
  77. }
  78. func (l EmptyFileSystemAbstraction) GetModTime(realpath string) (int64, error) {
  79. return 0, fsdef.ErrOperationNotSupported
  80. }
  81. func (l EmptyFileSystemAbstraction) WriteFile(filename string, content []byte, mode os.FileMode) error {
  82. return fsdef.ErrNullOperation
  83. }
  84. func (l EmptyFileSystemAbstraction) ReadFile(filename string) ([]byte, error) {
  85. return []byte(""), fsdef.ErrOperationNotSupported
  86. }
  87. func (l EmptyFileSystemAbstraction) WriteStream(filename string, stream io.Reader, mode os.FileMode) error {
  88. return fsdef.ErrNullOperation
  89. }
  90. func (l EmptyFileSystemAbstraction) ReadStream(filename string) (io.ReadCloser, error) {
  91. return nil, fsdef.ErrOperationNotSupported
  92. }
  93. func (l EmptyFileSystemAbstraction) Walk(root string, walkFn filepath.WalkFunc) error {
  94. return fsdef.ErrOperationNotSupported
  95. }