filesystem

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package filesystem contains utilities for working with filesystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFileIfExists

func CopyFileIfExists(fs afero.Fs, src, dst string) error

CopyFileIfExists copies a file from src to dst if the src file exists.

func CopyFilesBetweenFs

func CopyFilesBetweenFs(fromFS, toFS afero.Fs) error

CopyFilesBetweenFs copies all files from the source filesystem (fromFS) to the destination filesystem (toFS).

func CopyFolder

func CopyFolder(fs afero.Fs, sourceDir, targetDir string) error

CopyFolder recursively copies directory and all its contents from sourceDir to targetDir.

func CreateSymlink(targetFS *afero.BasePathFs, targetPath string, sourceFS *afero.BasePathFs, sourcePath string) error

CreateSymlink creates a symlink in a BasePathFs, potentially to another BasePathFs that shares the same underlying filesystem.

func FSToTar

func FSToTar(f afero.Fs, prefix string, opts ...FSToTarOption) ([]byte, error)

FSToTar produces a tarball of all the files in a filesystem.

func FindNestedFoldersWithPattern

func FindNestedFoldersWithPattern(fs afero.Fs, root string, pattern string) ([]string, error)

FindNestedFoldersWithPattern finds nested folders containing files that match a specified pattern.

func FullPath

func FullPath(fs afero.Fs, path string) string

FullPath returns the full path to path within the given filesystem. If fs is not an afero.BasePathFs the original path is returned.

func MemOverlay

func MemOverlay(fs afero.Fs) afero.Fs

MemOverlay returns a filesystem that uses the given filesystem as a base layer but writes changes to an in-memory overlay filesystem.

func Walk

func Walk(fs afero.Fs, root string, walkFn filepath.WalkFunc) error

Walk is a replacement for afero.Walk that ensures paths are normalized for in-memory filesystem compatibility on Windows. This reimplementation uses path.Join instead of filepath.Join to always use forward slashes.

Types

type FSToTarOption

type FSToTarOption func(*fsToTarConfig)

FSToTarOption configures the behavior of FSToTar.

func WithExcludePrefix

func WithExcludePrefix(prefix string) FSToTarOption

WithExcludePrefix excludes files with the given prefix from the tar archive.

func WithGIDOverride

func WithGIDOverride(gid int) FSToTarOption

WithGIDOverride sets the owner GID to use in the tar archive.

func WithSymlinkBasePath

func WithSymlinkBasePath(bp string) FSToTarOption

WithSymlinkBasePath provides the real base path of the filesystem, for use in symlink resolution.

func WithUIDOverride

func WithUIDOverride(uid int) FSToTarOption

WithUIDOverride sets the owner UID to use in the tar archive.

Jump to

Keyboard shortcuts

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