Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/model/object.go
1560 views
1
package model
2
3
import (
4
"time"
5
6
"github.com/alist-org/alist/v3/pkg/utils"
7
)
8
9
type ObjWrapName struct {
10
Name string
11
Obj
12
}
13
14
func (o *ObjWrapName) Unwrap() Obj {
15
return o.Obj
16
}
17
18
func (o *ObjWrapName) GetName() string {
19
return o.Name
20
}
21
22
type Object struct {
23
ID string
24
Path string
25
Name string
26
Size int64
27
Modified time.Time
28
Ctime time.Time // file create time
29
IsFolder bool
30
HashInfo utils.HashInfo
31
}
32
33
func (o *Object) GetName() string {
34
return o.Name
35
}
36
37
func (o *Object) GetSize() int64 {
38
return o.Size
39
}
40
41
func (o *Object) ModTime() time.Time {
42
return o.Modified
43
}
44
func (o *Object) CreateTime() time.Time {
45
if o.Ctime.IsZero() {
46
return o.ModTime()
47
}
48
return o.Ctime
49
}
50
51
func (o *Object) IsDir() bool {
52
return o.IsFolder
53
}
54
55
func (o *Object) GetID() string {
56
return o.ID
57
}
58
59
func (o *Object) GetPath() string {
60
return o.Path
61
}
62
63
func (o *Object) SetPath(path string) {
64
o.Path = path
65
}
66
67
func (o *Object) GetHash() utils.HashInfo {
68
return o.HashInfo
69
}
70
71
type Thumbnail struct {
72
Thumbnail string
73
}
74
75
type Url struct {
76
Url string
77
}
78
79
func (w Url) URL() string {
80
return w.Url
81
}
82
83
func (t Thumbnail) Thumb() string {
84
return t.Thumbnail
85
}
86
87
type ObjThumb struct {
88
Object
89
Thumbnail
90
}
91
92
type ObjectURL struct {
93
Object
94
Url
95
}
96
97
type ObjThumbURL struct {
98
Object
99
Thumbnail
100
Url
101
}
102
103