/
browser_file_info.go
51 lines (40 loc) · 1010 Bytes
/
browser_file_info.go
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
46
47
48
49
50
51
// Copyright 2018 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package libgit
import (
"os"
"time"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)
type browserFileInfo struct {
entry *object.TreeEntry
size int64
mtime time.Time
}
var _ os.FileInfo = (*browserFileInfo)(nil)
func (bfi *browserFileInfo) Name() string {
return bfi.entry.Name
}
func (bfi *browserFileInfo) Size() int64 {
return bfi.size
}
func (bfi *browserFileInfo) Mode() os.FileMode {
mode, err := bfi.entry.Mode.ToOSFileMode()
if err != nil {
panic(err)
}
// Make it read-only.
return mode &^ 0222
}
func (bfi *browserFileInfo) ModTime() time.Time {
// Unfortunately go-git doesn't give us a good way to get the time
// of this entry, so we have to rely on the caller.
return bfi.mtime
}
func (bfi *browserFileInfo) IsDir() bool {
return !bfi.entry.Mode.IsFile()
}
func (bfi *browserFileInfo) Sys() interface{} {
return nil
}