Documentation
¶
Index ¶
- func CopyEmbedDir(fs embed.FS, src, dst string) error
- func CopyToTempFile(r io.Reader, name, ext string) (string, int64, error)
- func EnsureTrailingDelim(p string, delim byte) string
- func ExpandHome(path string) (string, error)
- func ForceRemoveFiles(paths []string)
- func FullExt(path string) string
- func GlobPrefix(p string) (prefix string)
- func IsDoubleStarGlob(path string) bool
- func IsGlob(path string) bool
- func OpenTempFileInDir(dir, filePath string) (*os.File, error)
- func PathLevel(p string, delim byte) int
- func PrefixUntilLevel(p string, level int, delim byte) string
- func ResolveLocalPath(path, root string, allowHostAccess bool) (string, error)
- func ShellEscape(s string) string
- func Stem(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyEmbedDir ¶ added in v0.16.0
CopyEmbedDir copies an embedded directory to the local file system.
func CopyToTempFile ¶
CopyToTempFile pipes a reader to a temporary file. The caller must delete the temporary file when it's no longer needed.
func EnsureTrailingDelim ¶ added in v0.85.0
EnsureTrailingDelim returns p with a trailing delimiter. If p already ends with delim, it is returned unchanged.
func ExpandHome ¶ added in v0.19.0
func ForceRemoveFiles ¶ added in v0.19.0
func ForceRemoveFiles(paths []string)
ForceRemoveFiles deletes multiple files ignores path errors if any
func FullExt ¶
FullExt returns all of path's extensions. For example, for "foo.csv.zip" it returns ".csv.zip", not just ".zip" as filepath.Ext from the standard library does.
func GlobPrefix ¶ added in v0.85.0
GlobPrefix returns the literal (non-glob) prefix of p.
It returns the substring of p up to (but not including) the first unescaped glob meta character: '*', '?', '[', or '{'. Escaped meta characters (preceded by '\') are treated as literals. If p contains no unescaped meta characters, p is returned unchanged.
Examples:
GlobPrefix("a/b/c/*.txt") → "a/b/c/"
GlobPrefix("a/b/c/file*.go") → "a/b/c/file"
GlobPrefix("meta*/**") → "meta"
func IsDoubleStarGlob ¶ added in v0.85.0
IsDoubleStarGlob reports whether path contains an unescaped "**".
A backslash '\' escapes the following character, so "\**" does not count as a double-star glob.
func IsGlob ¶ added in v0.19.0
IsGlob reports whether path contains any unescaped glob meta characters: '*', '?', '[', or '{'. A backslash '\' escapes the following character.
func OpenTempFileInDir ¶ added in v0.21.0
OpenTempFileInDir opens a temp file in given dir If dir doesn't exist it creates full dir path (recursively if required)
func PathLevel ¶ added in v0.85.0
PathLevel returns the number of path components in p separated by delim. Empty components (from repeated delimiters) are ignored. Leading and trailing delimiters do not create extra components.
Examples (delim = '/'):
"a" → 1 "a/b" → 2 "a/b/c" → 3 "a/b/c/" → 3 "a/b//c" → 3 "/a/b/c/" → 3
func PrefixUntilLevel ¶ added in v0.85.0
PrefixUntilLevel returns the prefix of p that contains the first `level` path components separated by delim. Empty components (from repeated delimiters) are ignored.
If p has fewer than `level` components, p is returned unchanged.
Examples (delim = '/'):
"a/b/c/d.txt", level=1 → "a/" "a/b/c/d.txt", level=2 → "a/b/" "a/b/c/d.txt", level=3 → "a/b/c/" "a/b/c/d.txt", level=4 → "a/b/c/d.txt" "a/b//c/d.txt", level=3 → "a/b//c/" "/a/b/c", level=2 → "/a/b/"
func ResolveLocalPath ¶ added in v0.32.0
func ShellEscape ¶ added in v0.84.0
ShellEscape returns s wrapped in single quotes if it contains characters that are special in POSIX shells (spaces, globs, etc.). Safe strings are returned unchanged.
Types ¶
This section is empty.