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