Documentation ¶
Overview ¶
Package fs provides helper functions to assist with common operations on files and directories.
Index ¶
- Constants
- func AppendFile(path string) (*os.File, error)
- func AppendFilePerm(path string, perm os.FileMode) (*os.File, error)
- func DirExists(path string) (bool, os.FileInfo)
- func ExeFile() string
- func FileExists(path string) (bool, os.FileInfo)
- func GetFileSize(path string) int64
- func Mkdir(path string, perm os.FileMode) error
- func OpenFile(path string) (*os.File, error)
- func OpenFilePerm(path string, perm os.FileMode) (*os.File, error)
- type SearchDir
Constants ¶
const DEFAULT_PERM = 0750
Default permissions for simple file operations (u:rwx, g:rx, o: ).
Variables ¶
This section is empty.
Functions ¶
func AppendFile ¶
AppendFile creates or opens the specified path with append+write-only flags and DEFAULT_PERM permissions.
func AppendFilePerm ¶
AppendFilePerm creates or opens the sepcified path with append+write-only flags at the requested permissions level.
func DirExists ¶
DirExists tests to see if a given directory exists on disk and returns true, along with a relevant os.FileInfo object if so.
func ExeFile ¶
func ExeFile() string
ExeFile attempts to find and return the executing binary's full path.
func FileExists ¶
FileExists tests to see if a given file exists on disk and returns true, along with a relevant os.FileInfo object if so.
func GetFileSize ¶
GetFileSize stats a file on disk and returns its length. If no file exists then zero is returned.
func Mkdir ¶
Mkdir wraps os.Mkdir with a simple DirExists check for more succinct use in making sure a directory should exist.
Types ¶
type SearchDir ¶
SearchDir encapsulates file system search functionality along with 3 communication channels for use in concurrent code. DoneChan is written to when a search operation is complete. ErrChan is written to when any errors are encountered during the search. FileChan is written to for each matching file or directory.
func NewSearchDir ¶
func NewSearchDir() *SearchDir
NewSearchDir is a helper function which returns a pointer to a new SearchDir object.
func (*SearchDir) Search ¶
Search performs a recursive file system search for files and directories starting in the specified root directory, matching the given pattern.
func (*SearchDir) SearchDirs ¶
SearchDirs performs a recursive file system search for directories starting in the specified root directory, matching the given pattern.
func (*SearchDir) SearchFiles ¶
SearchFiles performs a recursive file system search for files starting in the specified root directory, matching the given pattern.