| 1 |
package trash |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/rkoesters/xdg/basedir" |
| 5 |
"path/filepath" |
| 6 |
) |
| 7 |
|
| 8 |
var hometrash *Dir |
| 9 |
|
| 10 |
func init() { |
| 11 |
hometrash = &Dir{filepath.Join(basedir.DataHome, "Trash")} |
| 12 |
} |
| 13 |
|
| 14 |
// Files returns a slice of the files in the default trash. |
| 15 |
func Files() ([]string, error) { return hometrash.Files() } |
| 16 |
|
| 17 |
// Stat returns the Info for the given file in the trash. |
| 18 |
func Stat(s string) (*Info, error) { return hometrash.Stat(s) } |
| 19 |
|
| 20 |
// Trash moves the given file to the trash. |
| 21 |
func Trash(p string) error { return hometrash.Trash(p) } |
| 22 |
|
| 23 |
// Restore moves the file from the trash to its original location. |
| 24 |
func Restore(s string) error { return hometrash.Restore(s) } |
| 25 |
|
| 26 |
// RestoreTo moves the file from the trash to the specified location. |
| 27 |
func RestoreTo(s, p string) error { return hometrash.RestoreTo(s, p) } |
| 28 |
|
| 29 |
// Erase removes the given file from the trash. |
| 30 |
func Erase(s string) error { return hometrash.Erase(s) } |
| 31 |
|
| 32 |
// EraseAll removes the given file and all children from the trash. |
| 33 |
func EraseAll(s string) error { return hometrash.EraseAll(s) } |
| 34 |
|
| 35 |
// Empty erases all files in the trash. |
| 36 |
func Empty() error { return hometrash.Empty() } |
| 37 |
|
| 38 |
// IsEmpty returns whether or not the trash is empty. |
| 39 |
func IsEmpty() bool { return hometrash.IsEmpty() } |