Documentation ¶
Index ¶
- type ConfigFile
- func (cf *ConfigFile) Backup() error
- func (cf *ConfigFile) BackupDir() string
- func (cf *ConfigFile) BackupPath() string
- func (cf *ConfigFile) DeleteBackup(restore bool) error
- func (cf *ConfigFile) HardRestore() error
- func (cf *ConfigFile) Hash() string
- func (cf *ConfigFile) HashShort() string
- func (cf *ConfigFile) InternalsDir() string
- func (cf *ConfigFile) MakeBrowsable(baseDir string) error
- func (cf *ConfigFile) Name() string
- func (cf *ConfigFile) PathAbs() string
- func (cf *ConfigFile) Restore() error
- func (cf *ConfigFile) SavePerm() error
- func (cf *ConfigFile) String() string
- func (cf *ConfigFile) UpdateSymlink() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigFile ¶
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) 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 (*ConfigFile) UpdateSymlink ¶ added in v1.5.0
func (cf *ConfigFile) UpdateSymlink() error
Updates existing symlink to the new browsable path if it exists.