github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/dokan/error_file.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 dokan 6 7 import ( 8 "context" 9 "fmt" 10 "time" 11 12 "github.com/keybase/client/go/kbfs/dokan/winacl" 13 ) 14 15 type errorFile struct { // nolint 16 fs FileSystem 17 } 18 19 func (ef *errorFile) print(method string, fi *FileInfo) error { 20 ef.fs.ErrorPrint(fmt.Errorf("INVALID FILE: %s %q", method, fi.Path())) 21 return ErrAccessDenied 22 } 23 24 func (ef *errorFile) ReadFile(ctx context.Context, fi *FileInfo, bs []byte, offset int64) (int, error) { 25 return 0, ef.print("ReadFile", fi) 26 } 27 func (ef *errorFile) WriteFile(ctx context.Context, fi *FileInfo, bs []byte, offset int64) (int, error) { 28 return 0, ef.print("WriteFile", fi) 29 } 30 func (ef *errorFile) FlushFileBuffers(ctx context.Context, fi *FileInfo) error { 31 return ef.print("FlushFileBuffers", fi) 32 } 33 func (ef *errorFile) GetFileInformation(ctx context.Context, fi *FileInfo) (*Stat, error) { 34 return nil, ef.print("GetFileInformation", fi) 35 } 36 func (ef *errorFile) FindFiles(ctx context.Context, fi *FileInfo, pattern string, fillStatCallback func(*NamedStat) error) error { 37 return ef.print("FindFiles", fi) 38 } 39 func (ef *errorFile) SetFileTime(ctx context.Context, fi *FileInfo, creation time.Time, lastAccess time.Time, lastWrite time.Time) error { 40 return ef.print("SetFileTime", fi) 41 } 42 func (ef *errorFile) SetFileAttributes(ctx context.Context, fi *FileInfo, fileAttributes FileAttribute) error { 43 return ef.print("SetFileAttributes", fi) 44 } 45 func (ef *errorFile) SetEndOfFile(ctx context.Context, fi *FileInfo, length int64) error { 46 return ef.print("SetEndOfFile", fi) 47 } 48 func (ef *errorFile) SetAllocationSize(ctx context.Context, fi *FileInfo, length int64) error { 49 return ef.print("SetAllocationSize", fi) 50 } 51 func (ef *errorFile) LockFile(ctx context.Context, fi *FileInfo, offset int64, length int64) error { 52 return ef.print("LockFile", fi) 53 } 54 func (ef *errorFile) UnlockFile(ctx context.Context, fi *FileInfo, offset int64, length int64) error { 55 return ef.print("UnlockFile", fi) 56 } 57 func (ef *errorFile) GetFileSecurity(ctx context.Context, fi *FileInfo, si winacl.SecurityInformation, sd *winacl.SecurityDescriptor) error { 58 return ef.print("GetFileSecurity", fi) 59 } 60 func (ef *errorFile) SetFileSecurity(ctx context.Context, fi *FileInfo, si winacl.SecurityInformation, sd *winacl.SecurityDescriptor) error { 61 return ef.print("SetFileSecurity", fi) 62 } 63 func (ef *errorFile) CanDeleteFile(ctx context.Context, fi *FileInfo) error { 64 return ef.print("CanDeleteFile", fi) 65 } 66 func (ef *errorFile) CanDeleteDirectory(ctx context.Context, fi *FileInfo) error { 67 return ef.print("CanDeleteDirectory", fi) 68 } 69 func (ef *errorFile) Cleanup(ctx context.Context, fi *FileInfo) { 70 ef.print("Cleanup", fi) 71 } 72 func (ef *errorFile) CloseFile(ctx context.Context, fi *FileInfo) { 73 ef.print("CloseFile", fi) 74 }