files

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package files contains helper functions related to the file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalPath

func CanonicalPath(path string, basePath string) (string, error)

Return the canonical version of the given path, relative to the given base path. That is, if the given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.

func CanonicalPaths

func CanonicalPaths(paths []string, basePath string) ([]string, error)

Return the canonical version of the given paths, relative to the given base path. That is, if a given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.

func CopyFile

func CopyFile(source string, destination string) error

Copy a file from source to destination

func FileExists

func FileExists(path string) bool

Return true if the given file exists

func GetPathRelativeTo

func GetPathRelativeTo(path string, basePath string) (string, error)

GetPathRelativeTo returns the relative path you would have to take to get from basePath to path. If either path or basePath are symbolic links, they will be evaluated before the relative path between them is calculated.

func Grep

func Grep(regex *regexp.Regexp, glob string) (bool, error)

Returns true if the given regex can be found in any of the files matched by the given glob

func IsDir

func IsDir(path string) bool

Return true if the path points to a directory

func ReadFileAsString

func ReadFileAsString(path string) (string, error)

Return the contents of the file at the given path as a string

func WriteFileWithSamePermissions

func WriteFileWithSamePermissions(source string, destination string, contents []byte) error

Write a file to the given destination with the given contents using the same permissions as the file at source

Types

This section is empty.

Jump to

Keyboard shortcuts

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