Re: Trash system



rik kde org wrote:
> 
> Let's imagine I'm deleting a file /mnt/somewhere/mydata
> 
> I have write access on the /mnt/somewhere filesystem. There are
> no directories on that filesystem, just a single file called mydata.

<snip...>

> 
> The only problem left is that when the user looks in their trash,
> we have to be able to find the directory /mnt/somewhere/.trash.
> 
> Without using find(1), we'd have to write a note somewhere to say
> that we have a .trash directory in /mnt/somewhere.

That's what the Trash support in Nautilus does -- once we create or find
Trash on a new partition that Nautilus never saw before, we save the
location of the Trash for that partition in a settings file in users
home.

The code that implements this is in gnome-vfs, the virtual file system
library Nautilus depends on.

The only detail that we do differently from your description is that we
use /mnt/somewhere/.Trash-(user name) to avoid trash conflicts for
different users.

> Off the top of my head, it might be a good plan to simply create
> symlinks in ~/Trash (or ~/.Trash or ~/Desktop/Trash, whatever)
> to .trash directories.

We don't use symlinks, just save the discovered Trash locations into the
settings file so that we can quickly access the Trash on the different
partitions. It's more or less the same approach though (the single file
with the cached paths happened to be more convenient in the
implementation). All of this is not exposed in the API used to access
the Trash, it's an implementation detail. Obviously it wouldn't be a
detail if we wanted to standardize the approach. I could see us going
with symlinks or using our cached file, either way. I guess the symlink
would be nicer for the case where folks wanted use it from the command
line if they wanted to maninpulate their trash that way. 

Btw., If you guys are interested and don't want to get a copy of
gnome-vfs, I can post snippets of the API for this and the code that
implements it.

Pavel




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]