configfile

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFile

type ConfigFile struct {
	Path      string
	Perm      os.FileMode
	Browsable bool
}

func NewConfigFile added in v1.2.0

func NewConfigFile(path string) (file *ConfigFile, err error)

Tidies the path before initializing the object.

cf, _ := NewConfigFile("~/path/../path/.config")
// cf.Path = "path/.config"

func (*ConfigFile) Backup added in v1.4.0

func (cf *ConfigFile) Backup() error

func (*ConfigFile) BackupDir added in v1.4.0

func (cf *ConfigFile) BackupDir() string

Finds the backup dir from the config.

func (*ConfigFile) BackupPath added in v1.4.0

func (cf *ConfigFile) BackupPath() string

Constructs the backup file path.

func (*ConfigFile) DeleteBackup added in v1.4.0

func (cf *ConfigFile) DeleteBackup(restore bool) error

Deletes the backup file.

func (*ConfigFile) HardRestore added in v1.4.0

func (cf *ConfigFile) HardRestore() error

Creates a copy of the backup file at the restore location. This is usually used with the `DeleteBackup` method.

func (*ConfigFile) Hash

func (cf *ConfigFile) Hash() string

Returns the hash of the Path.

func (*ConfigFile) HashShort

func (cf *ConfigFile) HashShort() string

Returns a truncated hash of the Path.

func (*ConfigFile) InternalsDir added in v1.5.0

func (cf *ConfigFile) InternalsDir() string

func (*ConfigFile) MakeBrowsable added in v1.5.0

func (cf *ConfigFile) MakeBrowsable(baseDir string) error

Makes the backup file browsable by moving it into backup_dir/home and mimicking its original structure.

func (*ConfigFile) Name

func (cf *ConfigFile) Name() string

Returns the base name if the file.

For example if the Path = "/some/loc/somewhere/.config" -> Name = ".config"

func (*ConfigFile) PathAbs

func (cf *ConfigFile) PathAbs() string

Returns the absolute path of the file. Relies on there being a $HOME environment variable.

func (*ConfigFile) Restore added in v1.4.0

func (cf *ConfigFile) Restore() error

Creates a symlink to the backup file.

func (*ConfigFile) SavePerm added in v1.3.0

func (cf *ConfigFile) SavePerm() error

Save file permissions.

func (*ConfigFile) String

func (cf *ConfigFile) String() string

Makes it printable, functions like fmt.Println know to call this automatically.

func (cf *ConfigFile) UpdateSymlink() error

Updates existing symlink to the new browsable path if it exists.

Jump to

Keyboard shortcuts

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