file

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableCache bool

DisableCache will disable caching of the home directory. Caching is enabled by default.

Functions

func Expand

func Expand(path string) (string, error)

Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func HomeDir

func HomeDir() (string, error)

Home returns the home directory for the executing user.

This uses an OS-specific method for discovering the home directory. An errors is returned if a home directory cannot be detected.

func Reset

func Reset()

Reset clears the cache, forcing the next call to Dir to re-detect the home directory. This generally never has to be called, but can be useful in tests if you're modifying the home directory via the HOME env var or something.

Types

type File

type File struct {
}

func (*File) Abs

func (f *File) Abs(path string) (string, *errorAVA.Error)

Abs returns an absolute representation of path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result.

func (*File) FileAppendBytes

func (f *File) FileAppendBytes(filename string, data []byte) *errorAVA.Error

func (*File) FileAppendPrintf

func (f *File) FileAppendPrintf(filename, format string, args ...interface{}) *errorAVA.Error

func (*File) FileAppendString

func (f *File) FileAppendString(filename string, data string) *errorAVA.Error

func (*File) FileCRC64

func (f *File) FileCRC64(filenameOrURL string) (uint64, *errorAVA.Error)

func (*File) FileCopy

func (f *File) FileCopy(source string, dest string) *errorAVA.Error

FileCopy copies file source to destination dest. Based on Jaybill McCarthy's code which can be found at http://jayblog.jaybill.com/post/id/26

func (*File) FileCopyDir

func (f *File) FileCopyDir(source string, dest string) *errorAVA.Error

FileCopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.

func (*File) FileExists

func (f *File) FileExists(filename string) *errorAVA.Error

func (*File) FileFind

func (f *File) FileFind(searchDirs []string, filenames ...string) (filePath string, found bool)

func (*File) FileFindModified

func (f *File) FileFindModified(searchDirs []string, filenames ...string) (filePath string, found bool, modified time.Time)

func (*File) FileGetBytes

func (f *File) FileGetBytes(filenameOrURL string, timeout ...time.Duration) ([]byte, *errorAVA.Error)

func (*File) FileGetCSV

func (f *File) FileGetCSV(filenameOrURL string, timeout ...time.Duration) ([][]string, *errorAVA.Error)

func (*File) FileGetGz

func (f *File) FileGetGz(filenameOrURL string) ([]byte, *errorAVA.Error)

func (*File) FileGetInflate

func (f *File) FileGetInflate(filenameOrURL string) ([]byte, *errorAVA.Error)

func (*File) FileGetJSON

func (f *File) FileGetJSON(filenameOrURL string, timeout ...time.Duration) (result interface{}, err *errorAVA.Error)

func (*File) FileGetLastLine

func (f *File) FileGetLastLine(filenameOrURL string, timeout ...time.Duration) (line string, err *errorAVA.Error)

FileGetLastLine reads the last line from a file. In case of a network file, the whole file is read. In case of a local file, the last 64kb are read, so if the last line is longer than 64kb it is not returned completely. The first optional timeout is used for network files only.

func (*File) FileGetLines

func (f *File) FileGetLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err *errorAVA.Error)

FileGetLines returns a string slice with the text lines of filenameOrURL. The lines can be separated by \n or \r\n.

func (*File) FileGetNonEmptyLines

func (f *File) FileGetNonEmptyLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err *errorAVA.Error)

FileGetNonEmptyLines returns a string slice with the non empty text lines of filenameOrURL. The lines can be separated by \n or \r\n.

func (*File) FileGetString

func (f *File) FileGetString(filenameOrURL string, timeout ...time.Duration) (string, *errorAVA.Error)

func (*File) FileGetXML

func (f *File) FileGetXML(filenameOrURL string, timeout ...time.Duration) (result interface{}, err *errorAVA.Error)

func (*File) FileIsDir

func (f *File) FileIsDir(dirname string) bool

func (*File) FileMD5Bytes

func (f *File) FileMD5Bytes(filenameOrURL string) ([]byte, *errorAVA.Error)

func (*File) FileMD5String

func (f *File) FileMD5String(filenameOrURL string) (string, *errorAVA.Error)

func (*File) FilePrintf

func (f *File) FilePrintf(filename, format string, args ...interface{}) *errorAVA.Error

func (*File) FileScanf

func (f *File) FileScanf(filename, format string, args ...interface{}) *errorAVA.Error

func (*File) FileSetBytes

func (f *File) FileSetBytes(filename string, data []byte) *errorAVA.Error

func (*File) FileSetCSV

func (f *File) FileSetCSV(filename string, records [][]string) *errorAVA.Error

func (*File) FileSetJSON

func (f *File) FileSetJSON(filename string, data interface{}) *errorAVA.Error

func (*File) FileSetJSONIndent

func (f *File) FileSetJSONIndent(filename string, data interface{}, indent string) *errorAVA.Error

func (*File) FileSetLines

func (f *File) FileSetLines(filename string, lines []string) *errorAVA.Error

func (*File) FileSetString

func (f *File) FileSetString(filename string, data string) *errorAVA.Error

func (*File) FileSetXML

func (f *File) FileSetXML(filename string, data interface{}) *errorAVA.Error

func (*File) FileSize

func (f *File) FileSize(filename string) int64

FileSize returns the size of a file or zero in case of an error.

func (*File) FileTimeModified

func (f *File) FileTimeModified(filename string) time.Time

FileTimeModified returns the modified time of a file, or the zero time value in case of an error.

func (*File) FileTouch

func (f *File) FileTouch(filename string) *errorAVA.Error

func (*File) FileUnmarshallJSON

func (f *File) FileUnmarshallJSON(filenameOrURL string, result interface{}, timeout ...time.Duration) *errorAVA.Error

func (*File) FileUnmarshallXML

func (f *File) FileUnmarshallXML(filenameOrURL string, result interface{}, timeout ...time.Duration) *errorAVA.Error

func (*File) ListDir

func (f *File) ListDir(dir string) ([]string, *errorAVA.Error)

func (*File) ListDirDirectories

func (f *File) ListDirDirectories(dir string) ([]string, *errorAVA.Error)

func (*File) ListDirFiles

func (f *File) ListDirFiles(dir string) ([]string, *errorAVA.Error)

type FileI

type FileI interface {
	FileGetBytes(filenameOrURL string, timeout ...time.Duration) ([]byte, *errorAVA.Error)
	FileSetBytes(filename string, data []byte) *errorAVA.Error
	FileAppendBytes(filename string, data []byte) *errorAVA.Error
	FileGetString(filenameOrURL string, timeout ...time.Duration) (string, *errorAVA.Error)
	FileSetString(filename string, data string) *errorAVA.Error
	FileAppendString(filename string, data string) *errorAVA.Error
	FileGetJSON(filenameOrURL string, timeout ...time.Duration) (result interface{}, err *errorAVA.Error)
	FileUnmarshallJSON(filenameOrURL string, result interface{}, timeout ...time.Duration) *errorAVA.Error
	FileSetJSON(filename string, data interface{}) *errorAVA.Error
	FileSetJSONIndent(filename string, data interface{}, indent string) *errorAVA.Error
	FileGetXML(filenameOrURL string, timeout ...time.Duration) (result interface{}, err *errorAVA.Error)
	FileUnmarshallXML(filenameOrURL string, result interface{}, timeout ...time.Duration) *errorAVA.Error
	FileSetXML(filename string, data interface{}) *errorAVA.Error
	FileGetCSV(filenameOrURL string, timeout ...time.Duration) ([][]string, *errorAVA.Error)
	FileSetCSV(filename string, records [][]string) *errorAVA.Error
	FileGetLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err *errorAVA.Error)
	FileSetLines(filename string, lines []string) *errorAVA.Error
	FileGetNonEmptyLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err *errorAVA.Error)
	FileGetLastLine(filenameOrURL string, timeout ...time.Duration) (line string, err *errorAVA.Error)
	FileTimeModified(filename string) time.Time
	FileExists(filename string) *errorAVA.Error
	FileIsDir(dirname string) bool
	FileFind(searchDirs []string, filenames ...string) (filePath string, found bool)
	FileFindModified(searchDirs []string, filenames ...string) (filePath string, found bool, modified time.Time)
	FileTouch(filename string) *errorAVA.Error
	FileMD5String(filenameOrURL string) (string, *errorAVA.Error)
	FileMD5Bytes(filenameOrURL string) ([]byte, *errorAVA.Error)
	FileCRC64(filenameOrURL string) (uint64, *errorAVA.Error)
	FileGetInflate(filenameOrURL string) ([]byte, *errorAVA.Error)
	FileGetGz(filenameOrURL string) ([]byte, *errorAVA.Error)
	FileSize(filename string) int64
	FilePrintf(filename, format string, args ...interface{}) *errorAVA.Error
	FileAppendPrintf(filename, format string, args ...interface{}) *errorAVA.Error
	FileScanf(filename, format string, args ...interface{}) *errorAVA.Error
	ListDir(dir string) ([]string, *errorAVA.Error)
	ListDirFiles(dir string) ([]string, *errorAVA.Error)
	ListDirDirectories(dir string) ([]string, *errorAVA.Error)
	FileCopy(source string, dest string) (err *errorAVA.Error)
	FileCopyDir(source string, dest string) (err *errorAVA.Error)
	Abs(path string) (string, *errorAVA.Error)
}

func NewFile

func NewFile() FileI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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