emptyfs.go 3.5 KB

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