dirs-dev / directories-rs

a mid-level library that provides config/cache/data paths, following the respective conventions on Linux, macOS and Windows
https://dirs.dev
Apache License 2.0
752 stars 33 forks source link

Trash dir #60

Closed lunacookies closed 4 years ago

lunacookies commented 4 years ago

Hi,

I was recently looking for a way to locate the user’s trash directory and noticed that some issues here mentioned trash, but that this didn’t seem to be present in this library. However, it seems that trash_dir is still in lib.rs, just that it is commented out. Assuming that this was once provided by this library, would it be possible to restore this feature?

Thanks.

soc commented 4 years ago

Hi Aramis,

the problem is that Windows' trash folder doesn't have a "real" path that we can return to the user, see: https://github.com/soc/directories-rs/issues/18

As there doesn't seem to be a consistent way to return this directory on all supported platforms (and there is usually not a per-user trash directory, but a per-disk one), the decision was made to not offer this API here.

lunacookies commented 4 years ago

Since this library returns Optionss of values, couldn’t you return None on those platforms that don’t support locating trash? Or is it that all supported platforms don’t support locating trash.

AFAIK and FWIW trash on macOS is always $HOME/.Trash, and on (some?) Linux distros it’s $XDG_DATA_DIR/Trash. This is just from a quick Google and you’ve probably done way more research than me on this though.

soc commented 4 years ago

My concern is that it would confuse the reasons why one might get a None.

Without trash, it's basically "this OS does not have this dir"; if we added trash, it would add "the OS might have this dir, but we can't give you a path to it" as a second reason to return None.

lunacookies commented 4 years ago

Ah, I see now. Thanks. Should I close this issue?

soc commented 4 years ago

I'd propose we keep this open for a week and figure out whether we can collect additional pros/cons; after that I'll make a decision based on hopefully more information. :-)

lunacookies commented 4 years ago

Sounds good 👍