github.com/google/osv-scalibr@v0.4.1/testing/fakefs/fake_fileinfo.go (about) 1 // Copyright 2025 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package fakefs provides a fake file system implementation for testing. 16 package fakefs 17 18 import ( 19 "io/fs" 20 "time" 21 ) 22 23 // FakeFileInfo is a fake implementation of fs.FileInfo. 24 type FakeFileInfo struct { 25 FileName string 26 FileSize int64 27 FileMode fs.FileMode 28 FileModTime time.Time 29 } 30 31 // Name returns the name of the file. 32 func (i FakeFileInfo) Name() string { 33 return i.FileName 34 } 35 36 // Size returns the size of the file. 37 func (i FakeFileInfo) Size() int64 { 38 return i.FileSize 39 } 40 41 // Mode returns the mode of the file. 42 func (i FakeFileInfo) Mode() fs.FileMode { 43 return i.FileMode 44 } 45 46 // ModTime returns the modification time of the file. 47 func (i FakeFileInfo) ModTime() time.Time { 48 return i.FileModTime 49 } 50 51 // IsDir returns true if the file is a directory. 52 func (i FakeFileInfo) IsDir() bool { 53 return i.FileMode.IsDir() 54 } 55 56 // Sys is an implementation of FileInfo.Sys() that returns nothing (nil). 57 func (i FakeFileInfo) Sys() any { 58 return nil 59 }