github.com/MetalBlockchain/metalgo@v1.11.9/utils/filesystem/io.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package filesystem 5 6 import ( 7 "io/fs" 8 "os" 9 ) 10 11 var _ Reader = reader{} 12 13 // Reader is an interface for reading the filesystem. 14 type Reader interface { 15 // ReadDir reads a given directory. 16 // Returns the files in the directory. 17 ReadDir(string) ([]fs.DirEntry, error) 18 } 19 20 type reader struct{} 21 22 // NewReader returns an instance of Reader 23 func NewReader() Reader { 24 return reader{} 25 } 26 27 // This is just a wrapper around os.ReadDir to make testing easier. 28 func (reader) ReadDir(dirname string) ([]fs.DirEntry, error) { 29 return os.ReadDir(dirname) 30 }