trash

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 1 Imported by: 1

README

trash-go

The trash-go is the library for golang to move specified files to trashbox (recycle-bin/trash-can) of Microsoft Windows.

package trash // import "github.com/hymkor/trash-go"

func Throw(filenames ...string) error

in NON-Windows environments (experimental)

trash.Throw moves files to "the home trash" of the FreeDesktop.org Trash specification 1.0.

Sample

cmd/trash/main.go

package main

import (
    "fmt"
    "os"
    "path/filepath"

    "github.com/hymkor/trash-go"
)

func main() {
    args := os.Args[1:]
    if len(args) > 0 {
        filenames := make([]string, 0, len(args))
        for _, arg := range args {
            if matches, err := filepath.Glob(arg); err != nil {
                filenames = append(filenames, arg)
            } else {
                filenames = append(filenames, matches...)
            }
        }
        err := trash.Throw(filenames...)
        if err != nil {
            fmt.Fprintln(os.Stderr, err.Error())
            os.Exit(1)
        }
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Throw

func Throw(filenames ...string) error

Types

This section is empty.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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