fs

package
v0.0.0-...-2ce8548 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2015 License: BSD-2-Clause Imports: 4 Imported by: 4

Documentation

Overview

Package fs provides helper functions to assist with common operations on files and directories.

Index

Constants

View Source
const DEFAULT_PERM = 0750

Default permissions for simple file operations (u:rwx, g:rx, o: ).

Variables

This section is empty.

Functions

func AppendFile

func AppendFile(path string) (*os.File, error)

AppendFile creates or opens the specified path with append+write-only flags and DEFAULT_PERM permissions.

func AppendFilePerm

func AppendFilePerm(path string, perm os.FileMode) (*os.File, error)

AppendFilePerm creates or opens the sepcified path with append+write-only flags at the requested permissions level.

func DirExists

func DirExists(path string) (bool, os.FileInfo)

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

func FileExists(path string) (bool, os.FileInfo)

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

func GetFileSize(path string) int64

GetFileSize stats a file on disk and returns its length. If no file exists then zero is returned.

func Mkdir

func Mkdir(path string, perm os.FileMode) error

Mkdir wraps os.Mkdir with a simple DirExists check for more succinct use in making sure a directory should exist.

func OpenFile

func OpenFile(path string) (*os.File, error)

OpenFile creates or opens the specified path with the read-only flag and DEFAULT_PERM permissions.

func OpenFilePerm

func OpenFilePerm(path string, perm os.FileMode) (*os.File, error)

OpenFilePerm creates or opens the specified path with the read-only flag at the requested permissions level.

Types

type SearchDir

type SearchDir struct {
	DoneChan chan bool
	ErrChan  chan string
	FileChan chan string
}

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

func (this *SearchDir) Search(root, pattern string)

Search performs a recursive file system search for files and directories starting in the specified root directory, matching the given pattern.

func (*SearchDir) SearchDirs

func (this *SearchDir) SearchDirs(root, pattern string)

SearchDirs performs a recursive file system search for directories starting in the specified root directory, matching the given pattern.

func (*SearchDir) SearchFiles

func (this *SearchDir) SearchFiles(root, pattern string)

SearchFiles performs a recursive file system search for files starting in the specified root directory, matching the given pattern.

Jump to

Keyboard shortcuts

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