Documentation
¶
Overview ¶
Helpers for working with files and filesystems
Index ¶
- Variables
- func AddMimeTypeFile(filename string)
- func CopyDir(root string, fn CopyEntryFunc) error
- func GetMimeType(filenameOrReader interface{}, fallback ...string) string
- func InitMime()
- func IsModifiedAfter(stat os.FileInfo, current string) bool
- func IsTerminal() bool
- func MustExpandUser(path string) string
- func MustReadAll(filename string) []byte
- func MustReadAllString(filename string) string
- func MustWriteFile(reader io.Reader, filename string) int64
- func ReadAll(filename string) ([]byte, error)
- func ReadAllLines(filename string) ([]string, error)
- func ReadAllString(filename string) (string, error)
- func ReadFirstLine(filename string) (string, error)
- func WriteFile(reader io.Reader, filename string) (int64, error)
- type CopyEntryFunc
- type DirReader
- type DirReaderOption
- type DirReaderOptions
- type RewriteFileSystem
- type SkipFunc
Constants ¶
This section is empty.
Variables ¶
var DirExists = pathutil.DirExists
Alias functions from pathutil as a convenience
var Exists = pathutil.Exists
var ExpandUser = pathutil.ExpandUser
var FileExists = pathutil.FileExists
var IsAppend = pathutil.IsAppend
var IsAppendable = pathutil.IsAppendable
var IsCharDevice = pathutil.IsCharDevice
var IsDevice = pathutil.IsDevice
var IsExclusive = pathutil.IsExclusive
var IsNamedPipe = pathutil.IsNamedPipe
var IsNonemptyDir = pathutil.IsNonemptyDir
var IsNonemptyExecutableFile = pathutil.IsNonemptyExecutableFile
var IsNonemptyFile = pathutil.IsNonemptyFile
var IsReadable = pathutil.IsReadable
var IsSetgid = pathutil.IsSetgid
var IsSetuid = pathutil.IsSetuid
var IsSocket = pathutil.IsSocket
var IsSticky = pathutil.IsSticky
var IsSymlink = pathutil.IsSymlink
var IsTemporary = pathutil.IsTemporary
var IsWritable = pathutil.IsWritable
var LinkExists = pathutil.LinkExists
Functions ¶
func AddMimeTypeFile ¶ added in v1.6.14
func AddMimeTypeFile(filename string)
func CopyDir ¶ added in v1.6.33
func CopyDir(root string, fn CopyEntryFunc) error
Recursively walk the entries of a given directory, calling CopyEntryFunc for each entry. The io.Writer returned from the function will have that file's contents written to it. If the io.Writer is nil, the file will not be written anywhere but no error will be returned. If CopyEntryFunc returns an error, the behavior will be consistent with filepath.WalkFunc
func GetMimeType ¶ added in v1.6.14
GetMimeType goes out of its way to really, really try to figure out the MIME type of a given filename or io.Reader. If the first argument satisfies the io.Seeker interface, the seeker will Seek() back to the beginning. If it satisfies the io.Closer interface, it will be closed.
func IsModifiedAfter ¶ added in v1.6.27
Return true if the given FileInfo sports a ModTime later than the current file.
func IsTerminal ¶
func IsTerminal() bool
func MustExpandUser ¶ added in v1.6.27
func MustReadAll ¶
func MustReadAllString ¶
func MustWriteFile ¶ added in v1.6.26
Same as WriteFile, but will panic if the file cannot be written.
func ReadAllLines ¶ added in v1.6.13
func ReadAllString ¶
func ReadFirstLine ¶ added in v1.6.13
func WriteFile ¶ added in v1.6.26
Write the contents of the given reader to the specified filename. Filename paths containing tilde (~) will automatically expand to the current user's home directory, and all intermediate parent directories will be automatically created. Will return the number of bytes written, or an error.
Types ¶
type CopyEntryFunc ¶ added in v1.6.33
type DirReader ¶ added in v1.6.32
type DirReader struct {
// contains filtered or unexported fields
}
A DirReader provides a streaming io.Reader interface to all files in a given directory, with options for handling unreadable entries and recursion.
func NewDirReader ¶ added in v1.6.32
func NewDirReader(path string, options ...DirReaderOption) *DirReader
func (*DirReader) SetSkipFunc ¶ added in v1.6.32
Set a function that will be called for each path encountered while reading. If this function returns true, that path (and its descedants) will not be read.
type DirReaderOption ¶ added in v1.6.32
type DirReaderOption int
const ( NoRecursive DirReaderOption = iota FailOnError )
type DirReaderOptions ¶ added in v1.6.32
type DirReaderOptions []DirReaderOption
func (DirReaderOptions) Has ¶ added in v1.6.32
func (self DirReaderOptions) Has(option DirReaderOption) bool