locations

package
v1.8.12 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package locations implements a type that provides cross-platform access to standard filesystem locations, including config, cache and log directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultProvider

type DefaultProvider struct {
	// contains filtered or unexported fields
}

DefaultProvider is a locations provider using the system-default storage locations.

func NewDefaultProvider

func NewDefaultProvider(name string) (*DefaultProvider, error)

func (*DefaultProvider) UserCache

func (p *DefaultProvider) UserCache() string

func (*DefaultProvider) UserConfig

func (p *DefaultProvider) UserConfig() string

type Locations

type Locations struct {
	// contains filtered or unexported fields
}

Locations provides cross-platform access to standard locations. On linux: - settings: ~/.config/protonmail/<app> - logs: ~/.cache/protonmail/<app>/logs - cache: ~/.config/protonmail/<app>/cache - updates: ~/.config/protonmail/<app>/updates - lockfile: ~/.cache/protonmail/<app>/<app>.lock .

func New

func New(provider Provider, configName string) *Locations

New returns a new locations object.

func (*Locations) Clean

func (l *Locations) Clean() error

Clean removes any unexpected files from the app cache folder while leaving files in the standard locations untouched.

func (*Locations) Clear

func (l *Locations) Clear() error

Clear removes everything except the lock and update files.

func (*Locations) ClearUpdates

func (l *Locations) ClearUpdates() error

ClearUpdates removes update files.

func (*Locations) GetLicenseFilePath

func (l *Locations) GetLicenseFilePath() string

GetLicenseFilePath returns path to liense file.

func (*Locations) GetLockFile

func (l *Locations) GetLockFile() string

GetLockFile returns the path to the lock file (e.g. ~/.cache/<company>/<app>/<app>.lock).

func (*Locations) GetOldCachePath added in v1.7.0

func (l *Locations) GetOldCachePath() string

GetOldCachePath returns a former location for user cache dirs used for migration scripts only.

func (*Locations) GetOldUpdatesPath added in v1.7.0

func (l *Locations) GetOldUpdatesPath() string

GetOldUpdatesPath returns a former location for update files used for migration scripts only.

func (*Locations) GetUpdatesPath added in v1.7.0

func (l *Locations) GetUpdatesPath() string

GetUpdatesPath returns a new location for update files used for migration scripts only.

func (*Locations) ProvideCachePath

func (l *Locations) ProvideCachePath() (string, error)

ProvideCachePath returns a location for user cache dirs (e.g. ~/.config/<company>/<app>/cache). It creates it if it doesn't already exist.

func (*Locations) ProvideLogsPath

func (l *Locations) ProvideLogsPath() (string, error)

ProvideLogsPath returns a location for user logs (e.g. ~/.cache/<company>/<app>/logs). It creates it if it doesn't already exist.

func (*Locations) ProvideSettingsPath

func (l *Locations) ProvideSettingsPath() (string, error)

ProvideSettingsPath returns a location for user settings (e.g. ~/.config/<company>/<app>). It creates it if it doesn't already exist.

func (*Locations) ProvideUpdatesPath

func (l *Locations) ProvideUpdatesPath() (string, error)

ProvideUpdatesPath returns a location for update files (e.g. ~/.cache/<company>/<app>/updates). It creates it if it doesn't already exist.

type Provider

type Provider interface {
	UserConfig() string
	UserCache() string
}

Provider provides standard locations.

Jump to

Keyboard shortcuts

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