file.go 559 B

12345678910111213141516171819202122232425262728293031323334
  1. package basefs
  2. import (
  3. "os"
  4. "time"
  5. )
  6. // This could be a struct
  7. // And service would be creating these
  8. type File struct {
  9. ID string
  10. Name string
  11. // Build Attr from this
  12. Size uint64
  13. CreatedTime time.Time
  14. ModifiedTime time.Time
  15. AccessedTime time.Time
  16. Mode os.FileMode
  17. Parents []string
  18. Data interface{} // Any thing
  19. }
  20. func (f *File) HasParent(parent *File) bool {
  21. parentID := ""
  22. if parent != nil {
  23. parentID = parent.ID
  24. }
  25. for _, p := range f.Parents {
  26. if p == parentID {
  27. return true
  28. }
  29. }
  30. return false
  31. }