gopkg.in/tools/godep.v67@v67.0.0-20160513230433-2d182dfe781d/Godeps/_workspace/src/github.com/kr/fs/filesystem.go (about)

     1  package fs
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  )
     8  
     9  // FileSystem defines the methods of an abstract filesystem.
    10  type FileSystem interface {
    11  
    12  	// ReadDir reads the directory named by dirname and returns a
    13  	// list of directory entries.
    14  	ReadDir(dirname string) ([]os.FileInfo, error)
    15  
    16  	// Lstat returns a FileInfo describing the named file. If the file is a
    17  	// symbolic link, the returned FileInfo describes the symbolic link. Lstat
    18  	// makes no attempt to follow the link.
    19  	Lstat(name string) (os.FileInfo, error)
    20  
    21  	// Join joins any number of path elements into a single path, adding a
    22  	// separator if necessary. The result is Cleaned; in particular, all
    23  	// empty strings are ignored.
    24  	//
    25  	// The separator is FileSystem specific.
    26  	Join(elem ...string) string
    27  }
    28  
    29  // fs represents a FileSystem provided by the os package.
    30  type fs struct{}
    31  
    32  func (f *fs) ReadDir(dirname string) ([]os.FileInfo, error) { return ioutil.ReadDir(dirname) }
    33  
    34  func (f *fs) Lstat(name string) (os.FileInfo, error) { return os.Lstat(name) }
    35  
    36  func (f *fs) Join(elem ...string) string { return filepath.Join(elem...) }