github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libfs/file_info_file.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 libfs 6 7 import ( 8 "time" 9 10 "github.com/keybase/client/go/kbfs/data" 11 "github.com/keybase/client/go/kbfs/libkbfs" 12 "golang.org/x/net/context" 13 ) 14 15 type fileInfoFile struct { 16 libkbfs.NodeMetadata 17 data.PrevRevisions 18 } 19 20 // GetFileInfo returns serialized JSON containing status information 21 // for a file or directory entry. 22 func GetFileInfo( 23 ctx context.Context, config libkbfs.Config, dir libkbfs.Node, name string) ( 24 data []byte, t time.Time, err error) { 25 node, ei, err := config.KBFSOps().Lookup(ctx, dir, dir.ChildName(name)) 26 if err != nil { 27 return nil, time.Time{}, err 28 } 29 nmd, err := config.KBFSOps().GetNodeMetadata(ctx, node) 30 if err != nil { 31 return nil, time.Time{}, err 32 } 33 data, err = PrettyJSON(fileInfoFile{nmd, ei.PrevRevisions}) 34 if err != nil { 35 return nil, time.Time{}, err 36 } 37 return data, time.Unix(0, ei.Mtime), nil 38 }