Welcome to the Linux Foundation Forum!

Two files, same name, same directory

Options

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.

Comments

  • mfillpot
    mfillpot Posts: 2,177
    Options
    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.
  • MrJelly
    MrJelly Posts: 2
    Options
    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.

Categories

Upcoming Training