You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.8 KiB

  1. package flat_namespace
  2. import (
  3. "errors"
  4. "github.com/chrislusf/seaweedfs/weed/filer"
  5. "path/filepath"
  6. )
  7. type FlatNamespaceFiler struct {
  8. master string
  9. store FlatNamespaceStore
  10. }
  11. var (
  12. ErrNotImplemented = errors.New("Not Implemented for flat namespace meta data store")
  13. )
  14. func NewFlatNamespaceFiler(master string, store FlatNamespaceStore) *FlatNamespaceFiler {
  15. return &FlatNamespaceFiler{
  16. master: master,
  17. store: store,
  18. }
  19. }
  20. func (filer *FlatNamespaceFiler) CreateFile(fullFileName string, fid string) (err error) {
  21. return filer.store.Put(fullFileName, fid)
  22. }
  23. func (filer *FlatNamespaceFiler) FindFile(fullFileName string) (fid string, err error) {
  24. return filer.store.Get(fullFileName)
  25. }
  26. func (filer *FlatNamespaceFiler) LookupDirectoryEntry(dirPath string, name string) (found bool, fileId string, err error) {
  27. if fileId, err = filer.FindFile(filepath.Join(dirPath, name)); err == nil {
  28. return true, fileId, nil
  29. }
  30. return false, "", err
  31. }
  32. func (filer *FlatNamespaceFiler) ListDirectories(dirPath string) (dirs []filer.DirectoryName, err error) {
  33. return nil, ErrNotImplemented
  34. }
  35. func (filer *FlatNamespaceFiler) ListFiles(dirPath string, lastFileName string, limit int) (files []filer.FileEntry, err error) {
  36. return nil, ErrNotImplemented
  37. }
  38. func (filer *FlatNamespaceFiler) DeleteDirectory(dirPath string, recursive bool) (err error) {
  39. return ErrNotImplemented
  40. }
  41. func (filer *FlatNamespaceFiler) DeleteFile(fullFileName string) (fid string, err error) {
  42. fid, err = filer.FindFile(fullFileName)
  43. if err != nil {
  44. return "", err
  45. }
  46. err = filer.store.Delete(fullFileName)
  47. if err != nil {
  48. return "", err
  49. }
  50. return fid, nil
  51. //return filer.store.Delete(fullFileName)
  52. //are you kidding me!!!!
  53. }
  54. func (filer *FlatNamespaceFiler) Move(fromPath string, toPath string) error {
  55. return ErrNotImplemented
  56. }