util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(url string, filePath string, mode os.FileMode, overwrite bool) error

DownloadFile places the contents of the given url into a local file at the given path with the given mode. If the overwrite flag is set then any existing files with conflicting names will be overwritten

func NewDirectory

func NewDirectory(path string, mode fs.FileMode) (err error)

NewDirectory wraps os.Mkdir to provide standardized directory creation and logging

func NewFileFromSource

func NewFileFromSource(path string, mode fs.FileMode, overwrite bool, source io.Reader) (int64, error)

NewFileFrom wraps os.OpenFile and io.Copy to standardize the way the package creates output files. The path argument accepts the file path to the given output file, the mode argument accepts an fs.FileMode which the file will be created with, and overwrite determines whether existing files should be overwritten or and error produced, the source provides the data that will be written to the new file. The bytes written are returned.

func NormalizeFilePath

func NormalizeFilePath(path string) string

NormalizeFilePath is a utility function that rewrites file paths specified to ensure that they are relative to the current working directory and don't have names that are potentially a nuisence for users (such as names composed only of whitespace characters, only dots, etc.)

Types

type FilterSet

type FilterSet []*regexp.Regexp

FilterSet contains compiled regular expressions which identify files to be selected. If the FilterSet is empty all files will be selected

func CompileFilters

func CompileFilters(filterStrings []string) (FilterSet, error)

compileFilters takes a list of regular expression strings and compiles them into a FilterSet.

Jump to

Keyboard shortcuts

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