filesystem

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveDir added in v0.2.3

func ArchiveDir(fs billy.Filesystem, srcPath, destTgzPath string) error

ArchiveDir archives a directory or a file into a tgz file and put it at destTgzPath which should end with .tgz

func CompareDirs

func CompareDirs(fs billy.Filesystem, leftDirpath, rightDirpath string, leftOnlyFunc, rightOnlyFunc RelativePathFunc, bothFunc RelativePathPairFunc) error

CompareDirs compares the contents of the directory at fromDirpath against that of the directory at toDirpath within a given filesystem It execute leftOnlyFunc on paths that only exist on the leftDirpath and rightOnlyFunc on paths that only exist on rightDirpath It executes bothFunc on paths that exist on both the left and the right. Order will be preserved in the function arguments

func CompareTgzs added in v0.3.0

func CompareTgzs(fs billy.Filesystem, leftTgzPath string, rightTgzPath string) (bool, error)

CompareTgzs checks to see if the file contents of the archive found at leftTgzPath matches that of the archive found at rightTgzPath It does this by comparing the sha256sum of the file contents, ignoring any other information (e.g. file modes, timestamps, etc.)

func CopyDir

func CopyDir(fs billy.Filesystem, srcDir string, dstDir string) error

CopyDir copies all files from srcDir to dstDir

func CopyFile

func CopyFile(fs billy.Filesystem, srcPath string, dstPath string) error

CopyFile copies a file from srcPath to dstPath within a filesystem. It creates any relevant directories along the way

func CreateFileAndDirs

func CreateFileAndDirs(fs billy.Filesystem, path string) (billy.File, error)

CreateFileAndDirs creates a file on the filesystem and all relevant directories along the way if they do not exist. The file that is created must be closed by the caller

func GetAbsPath

func GetAbsPath(fs billy.Filesystem, path string) string

GetAbsPath returns the absolute path given the relative path within a filesystem

func GetChartArchive

func GetChartArchive(fs billy.Filesystem, url string, path string) error

GetChartArchive gets a chart tgz file from a url and drops it into the path specified on the filesystem

func GetFilesystem

func GetFilesystem(path string) billy.Filesystem

GetFilesystem returns a filesystem rooted at the provided path

func GetRelativePath

func GetRelativePath(fs billy.Filesystem, abspath string) (string, error)

GetRelativePath returns the relative path given the absolute path within a filesystem

func GetRootPath

func GetRootPath(path string) (string, error)

GetRootPath returns the first directory in a given path

func IsEmptyDir

func IsEmptyDir(fs billy.Filesystem, path string) (bool, error)

IsEmptyDir returns whether the path provided is an empty directory or an error

func MakeSubdirectoryRoot

func MakeSubdirectoryRoot(fs billy.Filesystem, path, subdirectory string) error

MakeSubdirectoryRoot makes a particular subdirectory of a path its main directory

func MovePath

func MovePath(path string, fromDir string, toDir string) (string, error)

MovePath takes a path that is contained within fromDir and returns the same path contained within toDir

func PathExists

func PathExists(fs billy.Filesystem, path string) (bool, error)

PathExists checks if a path exists on the filesystem or returns an error

func PruneEmptyDirsInPath

func PruneEmptyDirsInPath(fs billy.Filesystem, path string) error

PruneEmptyDirsInPath removes all empty directories located within the path

func RemoveAll

func RemoveAll(fs billy.Filesystem, path string) error

RemoveAll removes all files and directories located at the path

func UnarchiveTgz

func UnarchiveTgz(fs billy.Filesystem, tgzPath, tgzSubdirectory, destPath string, overwrite bool) error

UnarchiveTgz attempts to unarchive the tgz file found at tgzPath in the filesystem

func UpdatePermissions

func UpdatePermissions(fs billy.Filesystem, path string, mode int64) error

UpdatePermissions updates the permissions for a given path to the mode provided

func WalkDir

func WalkDir(fs billy.Filesystem, dirPath string, doFunc RelativePathFunc) error

WalkDir walks through a directory given by dirPath rooted in the filesystem and performs doFunc at the path The path on each call will be relative to the filesystem provided.

Types

type RelativePathFunc

type RelativePathFunc func(fs billy.Filesystem, path string, isDir bool) error

RelativePathFunc is a function that is applied on a relative path within the given filesystem

type RelativePathPairFunc

type RelativePathPairFunc func(fs billy.Filesystem, leftPath, rightPath string, isDir bool) error

RelativePathPairFunc is a function that is applied on a pair of relative paths in a filesystem

Jump to

Keyboard shortcuts

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