Linux.com

Two files, same name, same directory

Link to this post 21 Oct 13

Hi,

Really hoping someone can help.

For a Uni project I need to create a trash can for Linux, much like the Windows one. Files are not deleted, just put in a trash can for safety purposes in case they deleted by mistake.

Anyway, I know you cant have two files with the same name in the same directory. Which is causing me bother with the mv command I am using to put files in the trash can, as it just overwrites the file that is there.

Is there a way to do this, perhaps hidden text on the filename or something like that? I was messing about with adding the date to the name when it was moved, but I am not sure how to remove that date when the file is restored back to its original location.

Any help would be great.

Link to this post 24 Oct 13

You can append a has or deletion date to the filename, so that no duplicated will exist, to track the differences you can use a hidden text file that contains the original name, ,original directory, deletion date, hash, etc... That hidden index file can be used by the restore function to handle the naming issue and contents validation.

Link to this post 24 Aug

The trash in Windows isn't a real director in the disk.It's a virtual directory.
So when you delete some big file(for example,a move),you can find the space of the disk(for example D:)doesn't change.but it has changed when you clear the trash.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board