trash

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package trash is a library following the FreeDesktop.org Trash specification. ref. https://specifications.freedesktop.org/trash-spec/trashspec-latest.html

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMakeTrashFilesDir             = errors.New("failed to make $XDG_DATA_HOME/Trash/files directory")
	ErrMakeTrashInfoDir              = errors.New("failed to make $XDG_DATA_HOME/Trash/info directory")
	ErrTrashFile                     = errors.New("failed to trash file")
	ErrOpenTrashInfoFile             = errors.New("failed to open trash information file under $XDG_DATA_HOME/Trash/info")
	ErrGetTrashTargetAbsPath         = errors.New("failed to get trash target absolute path")
	ErrWriteTrashInfoFile            = errors.New("failed to write trash information file under $XDG_DATA_HOME/Trash/info")
	ErrReadTrashFileDir              = errors.New("failed to read $XDG_DATA_HOME/Trash/files directory")
	ErrReadTrashInfoFile             = errors.New("failed to read trash info file")
	ErrRestoreTargetFileAlreadyExist = errors.New("attempted to restore, however same name file already exists")
	ErrOriginalLocationNotRecord     = errors.New("trashed file original location is not recorded")
	ErrRestoreFile                   = errors.New("failed to restore file at original location")
	ErrInvalidInfoFile               = errors.New("invalid trash info file format")
	ErrDecodePercentEncoding         = errors.New("decoding error for percent-encoding in path")
	ErrEraseFileInTrash              = errors.New("failed to erase file in trash")
)

Functions

This section is empty.

Types

type Info

type Info struct {
	Path string
}

func NewInfo

func NewInfo(trashPath string) *Info

func (*Info) MakeDir

func (i *Info) MakeDir() error

func (*Info) MakeInfoFile

func (i *Info) MakeInfoFile(trashSrcPath, trashDestPath string) error

type Trash

type Trash struct {
	// HomeTrashCanPath is "user home trash" directory - the storage of files that were trashed (“deleted”) by the user.
	// These files can be listed, undeleted, or cleaned from the trash can.
	// The trash can directory is located at $XDG_DATA_HOME/Trash.
	HomeTrashCanPath string
	Info             *Info
}

func NewTrash

func NewTrash() (*Trash, error)

func (*Trash) Erase

func (t *Trash) Erase(fileName string) error

func (*Trash) List

func (t *Trash) List() ([]string, error)

func (*Trash) Restore

func (t *Trash) Restore(fileName string, overwrite bool) error

func (*Trash) Trash

func (t *Trash) Trash(srcPath string) error

Jump to

Keyboard shortcuts

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