utils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ignore        = 0 // Redirect to null
	Show          = 1 // Show on stdout/stderr as normal
	ShowIfVerbose = 2 // Show if verbose is set, Ignore otherwise
	Capture       = 3 // Capture into buffer
)

Variables

View Source
var FilterOutHiddenFiles = paths.FilterOutPrefixes(".")

FilterOutHiddenFiles is a ReadDirFilter that exclude files with a "." prefix in their name

View Source
var SOURCE_CONTROL_FOLDERS = map[string]bool{"CVS": true, "RCS": true, ".git": true, ".github": true, ".svn": true, ".hg": true, ".bzr": true, ".vscode": true, ".settings": true, ".pioenvs": true, ".piolibdeps": true}

Functions

func AbsolutizePaths

func AbsolutizePaths(files []string) ([]string, error)

func AppendIfNotPresent

func AppendIfNotPresent(target []string, elements ...string) []string

func CopyDir

func CopyDir(src string, dst string, extensions []string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func ExecCommand

func ExecCommand(ctx *types.Context, command *exec.Cmd, stdout int, stderr int) ([]byte, []byte, error)

func FilterDirs

func FilterDirs(files []os.FileInfo) []os.FileInfo

func FilterFiles

func FilterFiles() filterFiles

func FilterFilesWithExtensions

func FilterFilesWithExtensions(extensions ...string) filterFiles

func FilterOutSCCS

func FilterOutSCCS(file *paths.Path) bool

FilterOutSCCS is a ReadDirFilter that excludes known VSC or project files

func FilterReadableFiles

func FilterReadableFiles(file *paths.Path) bool

FilterReadableFiles is a ReadDirFilter that accepts only readable files

func FindFilesInFolder

func FindFilesInFolder(dir *paths.Path, recurse bool, extensions []string) (paths.PathList, error)

func IsHiddenFile

func IsHiddenFile(file os.FileInfo) bool

func IsSCCSFile

func IsSCCSFile(file os.FileInfo) bool

func IsSCCSOrHiddenFile

func IsSCCSOrHiddenFile(file os.FileInfo) bool

func LogIfVerbose

func LogIfVerbose(warn bool, msg string) types.Command

func MD5Sum

func MD5Sum(data []byte) string

func NormalizeUTF8

func NormalizeUTF8(buf []byte) []byte

Normalizes an UTF8 byte slice TODO: use it more often troughout all the project (maybe on logger interface?)

func PrintableCommand

func PrintableCommand(parts []string) string

Convert a command and argument slice back to a printable string. This adds basic escaping which is sufficient for debug output, but probably not for shell interpretation. This essentially reverses ParseCommandLine.

func ReadDirFiltered

func ReadDirFiltered(folder string, fn filterFiles) ([]os.FileInfo, error)

func WrapWithHyphenI

func WrapWithHyphenI(value string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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