files

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url string, dest string) error

func DownloadAndUnzipRegistry added in v0.4.0

func DownloadAndUnzipRegistry() error

DownloadAndUnzipRegistry downloads the registry from the default URL and unzips it This is used to ensure the registry is available for commands that need it

func DownloadWithCache added in v0.4.0

func DownloadWithCache(url string, cachePath string, maxAge time.Duration) error

DownloadWithCache downloads a file with caching support

func EnsureDirExists

func EnsureDirExists(path string) string

func FileExists added in v0.4.0

func FileExists(path string) bool

func GenerateZanaGitIgnore added in v0.4.0

func GenerateZanaGitIgnore() bool

GenerateZanaGitIgnore creates a .gitignore file at the top level of the zana config directory if it doesn't exist. The .gitignore ignores *.zip files and the /bin directory.

func GetAppBinPath added in v0.4.0

func GetAppBinPath() string

GetAppBinPath returns the path to the bin directory e.g. /home/user/.config/zana/bin

func GetAppDataPath

func GetAppDataPath() string

GetAppDataPath returns the path to the app data directory If the ZANA_HOME environment variable is set, it will use that path otherwise it will use the user's config directory e.g. /home/user/.config/zana

func GetAppLocalPackagesFilePath

func GetAppLocalPackagesFilePath() string

GetAppLocalPackagesFilePath returns the path to the local packages file e.g. /home/user/.config/zana/zana-lock.json

func GetAppPackagesPath

func GetAppPackagesPath() string

GetAppPackagesPath returns the path to the packages directory e.g. /home/user/.config/zana/packages

func GetAppRegistryFilePath

func GetAppRegistryFilePath() string

GetAppRegistryFilePath returns the path to the registry file e.g. /home/user/.config/zana/zana-registry.json

func GetRegistryCachePath added in v0.4.0

func GetRegistryCachePath() string

GetRegistryCachePath returns the path to the registry cache file e.g. /home/user/.config/zana/registry-cache.json.zip

func GetTempPath

func GetTempPath() string

GetTempPath returns the path to the temp directory e.g. /tmp

func IsCacheValid added in v0.4.0

func IsCacheValid(cachePath string, maxAge time.Duration) bool

IsCacheValid checks if the cache file exists and is newer than the specified duration

func ResetDependencies added in v0.7.0

func ResetDependencies()

ResetDependencies resets all dependencies to their default implementations

func SetFileSystem added in v0.7.0

func SetFileSystem(fs FileSystem)

SetFileSystem sets the file system implementation

func SetHTTPClient added in v0.7.0

func SetHTTPClient(client HTTPClient)

SetHTTPClient sets the HTTP client implementation

func SetZipFileOpener added in v0.7.0

func SetZipFileOpener(zfo ZipFileOpener)

SetZipFileOpener sets the zip file opener implementation

func Unzip

func Unzip(src, dest string) error

Types

type FileSystem added in v0.7.0

type FileSystem interface {
	Create(name string) (afero.File, error)
	MkdirAll(path string, perm os.FileMode) error
	OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
	Stat(name string) (os.FileInfo, error)
	UserConfigDir() (string, error)
	TempDir() string
	Getenv(key string) string
	WriteString(file afero.File, s string) (int, error)
	Close(file afero.File) error
}

FileSystem interface for filesystem operations

type HTTPClient added in v0.7.0

type HTTPClient interface {
	Get(url string) (*http.Response, error)
}

HTTPClient interface for HTTP operations

type RealZipArchive added in v0.7.0

type RealZipArchive struct {
	*zip.ReadCloser
}

RealZipArchive is a wrapper for a real *zip.ReadCloser

func (*RealZipArchive) Close added in v0.7.0

func (r *RealZipArchive) Close() error

Close closes the underlying zip.ReadCloser

func (*RealZipArchive) File added in v0.7.0

func (r *RealZipArchive) File() []*zip.File

File provides access to the embedded zip.ReadCloser's File field

type RealZipFileOpener added in v0.7.0

type RealZipFileOpener struct{}

RealZipFileOpener implements the ZipFileOpener interface using the real zip package.

func (*RealZipFileOpener) Open added in v0.7.0

func (o *RealZipFileOpener) Open(name string) (ZipArchive, error)

type ZipArchive added in v0.7.0

type ZipArchive interface {
	File() []*zip.File
	Close() error
}

ZipArchive is an interface that abstracts the functionality of a *zip.ReadCloser.

type ZipFileOpener added in v0.7.0

type ZipFileOpener interface {
	Open(name string) (ZipArchive, error)
}

ZipFileOpener is the interface for opening a zip file.

Jump to

Keyboard shortcuts

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