I want to detect if I saw a file already and would like to identify it with something unique. Under Linux there is the inode number together with the device id (see stat()
or fstat()
). I assume under Windows I would find something similar.
To start easy, the boost::filesystem
offers convenient methods, e.g. I can use boost::filesystem::recursive_directory_iterator
to traverse the directory tree. The file_status
gives me if it is a regular file, but not the inode number.
The closest thing I found was boost::filesystem::equivalent()
taking two paths. I guess this is also the most portable design.
The thing is that I would like to put the inode numbers into a database to have a quick lookup. I cannot do this with this function, I would have to call equivalent()
with all paths already existing in the database.
Am I out of luck and boost will not provide me such information due to portability reasons?
(edit) The intention is to detect duplicates via hardlinks during one scan of a folder tree. equivalent()
does exactly that, but I would have to do a quadratic algorithm.