github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libfuse/open_file_count_file.go (about) 1 // Copyright 2019 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 "strconv" 12 "time" 13 14 "golang.org/x/net/context" 15 ) 16 17 // NewOpenFileCountFile returns a special read file that contains the 18 // number of files and directories currently being held open by the OS. 19 func NewOpenFileCountFile( 20 folder *Folder, entryValid *time.Duration) *SpecialReadFile { 21 *entryValid = 0 22 return &SpecialReadFile{ 23 read: func(_ context.Context) ([]byte, time.Time, error) { 24 count := folder.fs.root.openFileCount() 25 return []byte(strconv.FormatInt(count, 10)), 26 folder.fs.config.Clock().Now(), nil 27 }, 28 } 29 }