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.

41 lines
717 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package filer2
  2. import (
  3. "os"
  4. "time"
  5. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  6. )
  7. type Attr struct {
  8. Mtime time.Time // time of last modification
  9. Crtime time.Time // time of creation (OS X only)
  10. Mode os.FileMode // file mode
  11. Uid uint32 // owner uid
  12. Gid uint32 // group gid
  13. }
  14. func (attr Attr) IsDirectory() bool {
  15. return attr.Mode&os.ModeDir > 0
  16. }
  17. type Entry struct {
  18. FullPath
  19. Attr
  20. // the following is for files
  21. Chunks []*filer_pb.FileChunk `json:"chunks,omitempty"`
  22. }
  23. func (entry *Entry) Size() uint64 {
  24. return TotalSize(entry.Chunks)
  25. }
  26. func (entry *Entry) Timestamp() time.Time {
  27. if entry.IsDirectory() {
  28. return entry.Crtime
  29. } else {
  30. return entry.Mtime
  31. }
  32. }