github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libdokan/archive_reltime_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 libdokan 6 7 import ( 8 "time" 9 10 "github.com/keybase/client/go/kbfs/libfs" 11 "github.com/keybase/client/go/kbfs/tlfhandle" 12 "golang.org/x/net/context" 13 ) 14 15 // NewArchiveRelTimeFile returns a special read file that contains a 16 // by-revision directory name that corresponds to the given relative 17 // time string for the given folder. 18 func NewArchiveRelTimeFile( 19 fs *FS, handle *tlfhandle.Handle, filename string) *SpecialReadFile { 20 return &SpecialReadFile{ 21 read: func(ctx context.Context) ([]byte, time.Time, error) { 22 data, isRel, err := libfs.FileDataFromRelativeTimeString( 23 ctx, fs.config, handle, filename) 24 if err != nil { 25 return nil, time.Time{}, err 26 } 27 if !isRel { 28 panic("ArchiveRelTimeFile should only be used with " + 29 "reltime file names") 30 } 31 return data, time.Time{}, nil 32 }, 33 fs: fs, 34 } 35 }