github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libgit/browser_file_info.go (about) 1 // Copyright 2018 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libgit 6 7 import ( 8 "os" 9 "time" 10 11 "gopkg.in/src-d/go-git.v4/plumbing/object" 12 ) 13 14 type browserFileInfo struct { 15 entry *object.TreeEntry 16 size int64 17 mtime time.Time 18 } 19 20 var _ os.FileInfo = (*browserFileInfo)(nil) 21 22 func (bfi *browserFileInfo) Name() string { 23 return bfi.entry.Name 24 } 25 26 func (bfi *browserFileInfo) Size() int64 { 27 return bfi.size 28 } 29 30 func (bfi *browserFileInfo) Mode() os.FileMode { 31 mode, err := bfi.entry.Mode.ToOSFileMode() 32 if err != nil { 33 panic(err) 34 } 35 // Make it read-only. 36 return mode &^ 0222 37 } 38 39 func (bfi *browserFileInfo) ModTime() time.Time { 40 // Unfortunately go-git doesn't give us a good way to get the time 41 // of this entry, so we have to rely on the caller. 42 return bfi.mtime 43 } 44 45 func (bfi *browserFileInfo) IsDir() bool { 46 return !bfi.entry.Mode.IsFile() 47 } 48 49 func (bfi *browserFileInfo) Sys() interface{} { 50 return nil 51 }