global.go 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package storage
  2. import (
  3. "io"
  4. "os"
  5. )
  6. var (
  7. globalStorage FSOperator = &Local{}
  8. )
  9. func Read(path string) ([]byte, error) {
  10. return globalStorage.Read(path)
  11. }
  12. func ReadStream(path string) (io.ReadCloser, error) {
  13. return globalStorage.ReadStream(path)
  14. }
  15. func Write(path string, data []byte) error {
  16. return globalStorage.Write(path, data)
  17. }
  18. func WriteStream(path string, data io.Reader) error {
  19. return globalStorage.WriteStream(path, data)
  20. }
  21. func List(path string) ([]FileInfo, error) {
  22. return globalStorage.List(path)
  23. }
  24. func Stat(path string) (FileInfo, error) {
  25. return globalStorage.Stat(path)
  26. }
  27. func Delete(path string) error {
  28. return globalStorage.Delete(path)
  29. }
  30. func Mkdir(path string, perm os.FileMode) error {
  31. return globalStorage.Mkdir(path, perm)
  32. }
  33. func Rename(oldpath, newpath string) error {
  34. return globalStorage.Rename(oldpath, newpath)
  35. }
  36. func Exists(path string) (bool, error) {
  37. return globalStorage.Exists(path)
  38. }
  39. func SetGlobalStorage(storage FSOperator) {
  40. globalStorage = storage
  41. }