aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/entry.go
blob: 82bc00b2736006d2d93ab39e4fe3fd5999581194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package filer2

import (
	"os"
	"time"

	"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)

type Attr struct {
	Mtime       time.Time   // time of last modification
	Crtime      time.Time   // time of creation (OS X only)
	Mode        os.FileMode // file mode
	Uid         uint32      // owner uid
	Gid         uint32      // group gid
	Mime        string      // mime type
	Replication string      // replication
	Collection  string      // collection name
	TtlSec      int32       // ttl in seconds
}

func (attr Attr) IsDirectory() bool {
	return attr.Mode&os.ModeDir > 0
}

type Entry struct {
	FullPath

	Attr

	// the following is for files
	Chunks []*filer_pb.FileChunk `json:"chunks,omitempty"`
}

func (entry *Entry) Size() uint64 {
	return TotalSize(entry.Chunks)
}

func (entry *Entry) Timestamp() time.Time {
	if entry.IsDirectory() {
		return entry.Crtime
	} else {
		return entry.Mtime
	}
}