github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libdokan/symlink.go (about) 1 // Copyright 2016 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 "github.com/keybase/client/go/kbfs/dokan" 9 "github.com/keybase/client/go/kbfs/libkbfs" 10 "golang.org/x/net/context" 11 ) 12 13 // Symlink represents KBFS symlinks. 14 type Symlink struct { 15 // The directory this symlink is in. This should be safe to store 16 // here, without fear of Renames etc making it stale, because we 17 // never persist a Symlink into Folder.nodes; it has no 18 // libkbfs.Node, so that's impossible. This should make FUSE 19 // Lookup etc always get new nodes, limiting the lifetime of a 20 // single Symlink value. 21 parent *Dir 22 // isTargetADirectory - Some Windows programs want to know. 23 isTargetADirectory bool 24 name string 25 emptyFile 26 } 27 28 // GetFileInformation does stat for dokan. 29 func (s *Symlink) GetFileInformation(ctx context.Context, fi *dokan.FileInfo) (a *dokan.Stat, err error) { 30 s.parent.folder.fs.logEnter(ctx, "Symlink GetFileInformation") 31 defer func() { s.parent.folder.reportErr(ctx, libkbfs.ReadMode, err) }() 32 33 _, _, err = s.parent.folder.fs.config.KBFSOps().Lookup( 34 ctx, s.parent.node, s.parent.node.ChildName(s.name)) 35 if err != nil { 36 return nil, errToDokan(err) 37 } 38 39 if s.isTargetADirectory { 40 return defaultSymlinkDirInformation() 41 } 42 return defaultSymlinkFileInformation() 43 }