fileutil

package
v10.0.37 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFileToZip added in v10.0.5

func AddFileToZip(zipWriter *zip.Writer, dir string, filename string) error

AddFileToZip will add a file to a zip (writer), dir is the directory inside the zip archive that you want the file to exist in. If dir is `""`, then the file will be in the root of the archive

func Checksum added in v10.0.5

func Checksum(fn string) (string, error)

Checksum will return the sha256 checksum of a file

func FileExists

func FileExists(filename ...string) bool

FileExists returns true if the path components exist

func FindFiles

func FindFiles(dir string, pattern *regexp.Regexp) ([]string, error)

FindFiles helper

func IsZeroLengthFile

func IsZeroLengthFile(fn string) bool

IsZeroLengthFile returns true if the filename specified is empty (0 bytes)

func OpenFile

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

OpenFile will open a file and if it's gzipped return a gzipped reader as io.ReadCloser but will close both streams on close

func OpenNestedZip added in v10.0.5

func OpenNestedZip(parent, child string) (*zip.Reader, error)

OpenNestedZip opens zip archive parent and searches it for child, then opens child and returns a zip.Reader. Useful for zip files inside zip files

func Resolve

func Resolve(filename string) (string, error)

Resolve with resolve a relative file path

func ResolveFileName

func ResolveFileName(fn string) string

ResolveFileName will attempt to resolve a filename attempting to look at both the basic name or the name + .gz extension

func ShaFiles added in v10.0.5

func ShaFiles(dir string, outfile string, re *regexp.Regexp) error

ShaFiles will calculate the checksum for all files in dir that match re and write them out to outfile. Useful for code releases.

func Unzip added in v10.0.6

func Unzip(src, dest string) error

Unzip will unzip archive src into folder dest

func ZipDir added in v10.0.5

func ZipDir(filename string, dir string, pattern *regexp.Regexp) (int, error)

ZipDir will zip create a zip archive named filename and fill it with files that match the pattern from dir

Types

This section is empty.

Jump to

Keyboard shortcuts

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