emptyfs.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package emptyfs
  2. import (
  3. "errors"
  4. "io"
  5. "os"
  6. "path/filepath"
  7. "time"
  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 nil
  20. }
  21. func (l EmptyFileSystemAbstraction) Chown(filename string, uid int, gid int) error {
  22. return nil
  23. }
  24. func (l EmptyFileSystemAbstraction) Chtimes(filename string, atime time.Time, mtime time.Time) error {
  25. return nil
  26. }
  27. func (l EmptyFileSystemAbstraction) Create(filename string) (*os.File, error) {
  28. return nil, nil
  29. }
  30. func (l EmptyFileSystemAbstraction) Mkdir(filename string, mode os.FileMode) error {
  31. return nil
  32. }
  33. func (l EmptyFileSystemAbstraction) MkdirAll(filename string, mode os.FileMode) error {
  34. return nil
  35. }
  36. func (l EmptyFileSystemAbstraction) Name() string {
  37. return ""
  38. }
  39. func (l EmptyFileSystemAbstraction) Open(filename string) (*os.File, error) {
  40. return nil, nil
  41. }
  42. func (l EmptyFileSystemAbstraction) OpenFile(filename string, flag int, perm os.FileMode) (*os.File, error) {
  43. return nil, nil
  44. }
  45. func (l EmptyFileSystemAbstraction) Remove(filename string) error {
  46. return nil
  47. }
  48. func (l EmptyFileSystemAbstraction) RemoveAll(path string) error {
  49. return nil
  50. }
  51. func (l EmptyFileSystemAbstraction) Rename(oldname, newname string) error {
  52. return nil
  53. }
  54. func (l EmptyFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) {
  55. return nil, nil
  56. }
  57. /*
  58. Abstraction Utilities
  59. */
  60. func (l EmptyFileSystemAbstraction) VirtualPathToRealPath(subpath string, username string) (string, error) {
  61. return "", errors.New("empty filesystem abstraction")
  62. }
  63. func (l EmptyFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) {
  64. return "", errors.New("empty filesystem abstraction")
  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{}, nil
  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, errors.New("empty filesystem abstraction")
  80. }
  81. func (l EmptyFileSystemAbstraction) WriteFile(filename string, content []byte, mode os.FileMode) error {
  82. return nil
  83. }
  84. func (l EmptyFileSystemAbstraction) ReadFile(filename string) ([]byte, error) {
  85. return []byte(""), errors.New("empty filesystem abstraction")
  86. }
  87. func (l EmptyFileSystemAbstraction) WriteStream(filename string, stream io.Reader, mode os.FileMode) error {
  88. return errors.New("operation not supported on dummy file system")
  89. }
  90. func (l EmptyFileSystemAbstraction) ReadStream(filename string) (io.ReadCloser, error) {
  91. return nil, errors.New("operation not supported on dummy file system")
  92. }
  93. func (l EmptyFileSystemAbstraction) Walk(root string, walkFn filepath.WalkFunc) error {
  94. return errors.New("empty filesystem abstraction")
  95. }