ostrash

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ostrash moves files to the system's trash, where the person can see, restore or empty them as any other deleted file (spec_029_files FIL-37a), and puts them back. On macOS it asks the system (NSFileManager's trashItemAtURL, through osascript, since Blitz is built without cgo), so Finder's Put Back works; on Linux and the BSDs it follows the freedesktop.org Trash specification. Elsewhere, and for a file the trash can't take, it says so (ErrUnavailable), and the caller keeps its own.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("the system's trash isn't available here")

ErrUnavailable is a trash this system doesn't have, or one that can't take the file (another disk than the home's, on Linux).

Functions

func Available

func Available() bool

Available reports whether this system has a trash Trash uses.

func Fake

func Fake(dir string) (undo func())

Fake makes Trash move files into dir, as the system's trash would, until the returned func is called: for tests, which otherwise get no system trash at all (ErrUnavailable), so they never fill the person's.

func Restore

func Restore(where, to string) error

Restore puts what Trash moved to where back at to, which must not exist; the freedesktop trash's record of it goes too.

func Trash

func Trash(ctx context.Context, path string) (string, error)

Trash moves path (a file or a folder) to the system's trash and returns where it is there, for Restore.

Types

This section is empty.

Jump to

Keyboard shortcuts

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