How to get inode with boost :: filesystem?

I want to determine if I have already seen the file and would like to identify it with something unique. Under Linux, there is an inode number along with a device identifier (see stat()or fstat()). I assume that under Windows I would find something similar.

To get started easily, boost::filesystemoffers convenient methods, for example. I can use boost::filesystem::recursive_directory_iteratorto navigate the directory tree. file_statusgives me if this is a regular file but not an inode number.

The closest I found is boost::filesystem::equivalent()with two paths. I guess this is also the most portable design.

The thing is, I would like to put the inode numbers in the database for a quick search. I can not do this with this function, I would have to call equivalent()with all the paths that already exist in the database.

Am I really out of luck and the promotion will not provide me such information due to portability concerns?

(edit) The goal is to detect duplicates using hard links during a single scan of the folder tree. equivalent()does just that, but I would have to do a quadratic algorithm.

+2
source share
1 answer

Windows CRT stat inode, . , Windows FindFirstfile , GetFileInformationByHandle, stat FindFirstfile, . inode, , . , .

NTFS, INODE, - MFT, . , , INODE, , .

GetFileInformationByHandle GetFileInformationByHandleEx . CreateFile, .

  • FILE_READ_ATTRIBUTES .
  • FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
  • OPEN_EXISTING .

, GetFileInformation, , .

BY_HANDLE_FILE_INFORMATION nFileIndexLow nFileIndexHigh, ReFS, 128- . , .

+4

Source: https://habr.com/ru/post/1609291/


All Articles