fs

package
v0.0.0-...-460bd45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2017 License: MIT Imports: 9 Imported by: 0

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

View Source
const (
	DefaultMaxOpenFiles = 200
	DefaultMaxOpenDirs  = 50
)

Limit the number of simultaneously open files and directories.

Variables

This section is empty.

Functions

func FilterGo

func FilterGo(s string) bool

FilterGo, is a filter func for Go source files.

func FilterList

func FilterList(list []string, fn FilterFunc) []string

FilterList, returns all of the members of list that satisfy fn().

func IsDir

func IsDir(name string) bool

IsDir, returns if path name is a directory, using the default FS.

func IsFile

func IsFile(name string) bool

IsDir, returns if path name is a file, using the default FS.

func IsPathErr

func IsPathErr(err error) bool

IsPathErr, returns if error err is a *os.PathError.

func Lstat

func Lstat(name string) (os.FileInfo, error)

Lstat calls Lstat of the default FS.

func OpenFile

func OpenFile(path string) (io.ReadCloser, error)

OpenFile, returns the file named by path for reading using the standard FS.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the file named by filename using the standard FS and returns the contents.

func Readdir

func Readdir(path string) ([]os.FileInfo, error)

Readdir uses the default FS to read the contents of the directory name.

func ReaddirFunc

func ReaddirFunc(path string, fn FilterFunc) ([]os.FileInfo, error)

ReaddirFunc calls ReaddirFunc of the default FS.

func Readdirnames

func Readdirnames(path string) ([]string, error)

Readdirnames, uses the default FS to read and return a slice of names from the directory f, in sorted order.

func SameFile

func SameFile(fi1, fi2 os.FileInfo) bool

SameFile, returns if os.FileInfo fi1 and fi2 have the same: name, size, modtime, directory mode or are both nil.

func Stat

func Stat(name string) (os.FileInfo, error)

Stat calls Stat of the default FS.

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

func New(maxOpenFiles, maxOpenDirs int) *FS

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) IsDir

func (fs *FS) IsDir(name string) bool

IsDir, returns if path name is a directory.

func (*FS) IsFile

func (fs *FS) IsFile(name string) bool

IsDir, returns if path name is a file.

func (*FS) Lstat

func (fs *FS) Lstat(name string) (os.FileInfo, error)

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) ReadFile

func (fs *FS) ReadFile(path string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*FS) Readdir

func (fs *FS) Readdir(path string) ([]os.FileInfo, error)

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

func (fs *FS) ReaddirFunc(path string, fn FilterFunc) ([]os.FileInfo, error)

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

func (fs *FS) Readdirnames(path string) ([]string, error)

Readdirnames reads and returns a slice of names from directory path, in sorted order.

func (*FS) Stat

func (fs *FS) Stat(name string) (os.FileInfo, error)

Stat returns a os.FileInfo describing the named file. If there is an error, it will be of type *os.PathError.

type FilterFunc

type FilterFunc func(string) bool

FilterFunc, returns if a file name should be included.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL