8000 Send to recycling/trash folder · Issue #10 · nemec/pathlib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Send to recycling/trash folder #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks
nemec opened this issue Nov 9, 2017 · 2 comments
Open
4 tasks

Send to recycling/trash folder #10

nemec opened this issue Nov 9, 2017 · 2 comments

Comments

@nemec
Copy link
Owner
nemec commented Nov 9, 2017

In addition to deleting a file, it would be nice to be able to send it to the user's trash folder. The challenge in this one is that various OSes do things differently. Windows has the recycle bin, Linux has the trash folder (which can be in any number of places)

  • OSX holds it in ~/.Trash folder for main drive, other places for different mount points. Perhaps port the Trash application to C#.
  • Linus (and others using XDG spec) generally place it in .local/share/Trash, or mount-local directory.
  • Windows will probably use a PInvoke to native Win32 method since the Recycling Bin is a special GUID folder.
  • In case none of these work on the user's machine, need a good way to indicate failure. Perhaps by return value.
@jeffward01
Copy link
Contributor

How would you determine what OS the user is on? Would it be something like

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
  // Do something
}

Would you want this feature added on all 'PathTypes'? IPurePath, Posix, etc

btw - this is cs_legend_93 from reddit. Thanks for recommending your library! it is by far the best

@nemec
Copy link
Owner Author
nemec commented May 1, 2022

For Mac/Linux it would probably be enough to just check for the existence of the expected folders and use it if it exists - it's unlikely you'll find a ~/.local/share/Trash directory on Mac, for example, so small risk of false positives. Your suggestion is another option - I do something similar in some of the test cases.

I would put it as a method on the IPath interface, since it interacts with the filesystem. It would then be added as an abstract method on ConcretePath (since the implementation varies by OS) and finally the implementation for each platform falls in the PosixPath and WindowsPath classes. No changes to anything "Pure".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0