Skip to content

Commit

Permalink
Update readme, add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKovacs committed Apr 20, 2021
1 parent a94b4ce commit 4c1ece3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Unreleased

## Changed
- The "Linux" implementation was replaced by a custom Freedesktop implementation.

## Added
- `list`, `purge_all`, and `restore_all` to Windows and Freedesktop
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

The `trash` is a Rust library for moving files and folders to the operating system's Recycle Bin or Trash or Rubbish Bin or what have you :D

The library supports Windows, macOS, Linux, and BSD.
The library supports Windows, macOS, and all FreeDesktop Trash compliant environments (including GNOME, KDE, XFCE, and more). See more about the FreeDesktop Trash implementation in the `freedesktop.rs` file.

## Usage

```toml
# In Cargo.toml
[dependencies]
trash = "1.2"
trash = "2.0"
```

```rust
Expand All @@ -39,9 +39,3 @@ fn main() {
}
}
```

## Note on Version 2

Version 2 would add `list`, `purge_all`, and `restore_all` that would allow for listing, permanently removing or restoring trashed items.
Development for Version 2 is currently suspended as I couldn't manage to get these features to work on Mac. Contribution would be very welcome.
An imperfect alternative would be to release those features for Linux and Windows both of which at this point have a more or less complete implementation of these features on the `v2-dev` branch. The windows implementation depends on a custom fork of winapi, because the PR adding the required features cannot be merged before winapi 0.4. I would like to merge the branch adding `list`, `purge_all`, and `restore_all` only after the winapi PR is is merged and published.
19 changes: 19 additions & 0 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::fs::File;
use trash;

fn main() {
// Let's create and remove a single file
File::create("remove-me").unwrap();
trash::delete("remove-me").unwrap();
assert!(File::open("remove-me").is_err());

// Now let's remove multiple files at once
let the_others = ["remove-me-too", "dont-forget-about-me-either"];
for name in the_others.iter() {
File::create(name).unwrap();
}
trash::delete_all(&the_others).unwrap();
for name in the_others.iter() {
assert!(File::open(name).is_err());
}
}
20 changes: 9 additions & 11 deletions src/freedesktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
//! version 1.0 found at https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html
//!
//! Most -if not all- Linux based desktop operating systems implement the Trash according to this specification.
//! In other words: I looked, but I could not any Linux based desktop OS that used anything else than the
//! In other words: I looked, but I could not find any Linux based desktop OS that used anything else than the
//! Freedesktop Trash specification.
//!
//! If the target system uses a different method for handling trashed items and you would be
//! intrested in using this crate on said system, please open an issue/PR on the github page of `trash`.
//! https://github.com/ArturKovacs/trash-rs
//!

use std::collections::HashSet;
use std::ffi::{CStr, CString};
use std::fs::{File, OpenOptions};
use std::io::{BufRead, BufReader, Write};
use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
use std::{
collections::HashSet,
ffi::{CStr, CString},
fs::{File, OpenOptions},
io::{BufRead, BufReader, Write},
os::unix::fs::PermissionsExt,
path::{Path, PathBuf},
};

use chrono::{NaiveDateTime, TimeZone};
use log::{debug, error, warn};
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//!
//! This library implements version 1.0 of the [Freedesktop.org
//! Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html) specification and
//! aims to match the behaviour of Ubuntu 18.04 in cases of ambiguity. Most -if not all- Linux
//! aims to match the behaviour of Ubuntu 18.04 GNOME in cases of ambiguity. Most -if not all- Linux
//! distributions that ship with a desktop environment follow this specification. For example
//! GNOME, KDE, and XFCE all use this convention. This crate blindly assumes that the Linux
//! distribution it runs on, follows this specification.
Expand Down

0 comments on commit 4c1ece3

Please sign in to comment.