Documentation ¶
Overview ¶
Package fs provides file-system utilities and an implementation of os.FileInfo that implements the GobEncode, GobDecode, MarshalJSON and UnmarshalJSON interfaces.
Index ¶
- Constants
- func FilterGo(s string) bool
- func FilterList(list []string, fn FilterFunc) []string
- func IsDir(name string) bool
- func IsFile(name string) bool
- func IsPathErr(err error) bool
- func Lstat(name string) (os.FileInfo, error)
- func OpenFile(path string) (io.ReadCloser, error)
- func ReadFile(path string) ([]byte, error)
- func Readdir(path string) ([]os.FileInfo, error)
- func ReaddirFunc(path string, fn FilterFunc) ([]os.FileInfo, error)
- func Readdirnames(path string) ([]string, error)
- func SameFile(fi1, fi2 os.FileInfo) bool
- func Stat(name string) (os.FileInfo, error)
- type FS
- func (fs *FS) IsDir(name string) bool
- func (fs *FS) IsFile(name string) bool
- func (fs *FS) Lstat(name string) (os.FileInfo, error)
- func (fs *FS) OpenFile(path string) (io.ReadCloser, error)
- func (fs *FS) ReadFile(path string) ([]byte, error)
- func (fs *FS) Readdir(path string) ([]os.FileInfo, error)
- func (fs *FS) ReaddirFunc(path string, fn FilterFunc) ([]os.FileInfo, error)
- func (fs *FS) Readdirnames(path string) ([]string, error)
- func (fs *FS) Stat(name string) (os.FileInfo, error)
- type FilterFunc
Constants ¶
const ( DefaultMaxOpenFiles = 200 DefaultMaxOpenDirs = 50 )
Limit the number of simultaneously open files and directories.
Variables ¶
This section is empty.
Functions ¶
func FilterList ¶
func FilterList(list []string, fn FilterFunc) []string
FilterList, returns all of the members of list that satisfy fn().
func OpenFile ¶
func OpenFile(path string) (io.ReadCloser, error)
OpenFile, returns the file named by path for reading using the standard FS.
func ReadFile ¶
ReadFile reads the file named by filename using the standard FS and returns the contents.
func ReaddirFunc ¶
func ReaddirFunc(path string, fn FilterFunc) ([]os.FileInfo, error)
ReaddirFunc calls ReaddirFunc of the default FS.
func Readdirnames ¶
Readdirnames, uses the default FS to read and return a slice of names from the directory f, in sorted order.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
An FS provides gated access to the file system. If maxOpenFiles or maxOpenDirs are not set the defaults are used.
func New ¶
New, returns a new FS with maxOpenFiles and maxOpenDirs.
If maxOpenFiles or maxOpenDirs are less than zero, the number of simultaneously open files or directories is not limited.
If maxOpenFiles or maxOpenDirs are equal to zero, the default max open files and directories are used.
func (*FS) Lstat ¶
Lstat returns a os.FileInfo describing the named file. If the file is a symbolic link, the returned os.FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type *os.PathError.
func (*FS) OpenFile ¶
func (fs *FS) OpenFile(path string) (io.ReadCloser, error)
OpenFile, returns the file named by path for reading.
func (*FS) Readdir ¶
Readdir reads reads the directory named by path and returns a slice of os.FileInfo values as would be returned by Lstat, in sorted order.
func (*FS) ReaddirFunc ¶
ReaddirFunc reads reads the directory named by path and returns a slice of os.FileInfo matched by FilterFunc fn, in sorted order.
Note: Behavior is undefined if path is not absolute.
func (*FS) Readdirnames ¶
Readdirnames reads and returns a slice of names from directory path, in sorted order.
type FilterFunc ¶
FilterFunc, returns if a file name should be included.