Reputation: 33
I need to find the inode number of a directory in Windows. Using the _stat
and _stat64
function I am able to get the inode and other information for a file. But when I use the same for Windows directories it always gives the same number for any directory.
Is there any way to find the inode number of a Windows directory?
Upvotes: 2
Views: 3456
Reputation: 490663
Windows file systems don't have a direct analog to the inode number in most Unix file systems.
If you want something that uniquely and unambiguously identifies the directory in question, you may find the volume serial number/FileId combo sufficient. You can retrieve these with GetFileInformationByHandleEx
(which, despite the name, can retrieve information about directories) with the FileInformationClass
(second parameter) set to FileIdInfo
.
This is mostly useful for NTFS though. As you'll see in the docs, the limitations on FAT file systems are pretty significant (though it can still be better than nothing, depending on your needs).
Upvotes: 3
Reputation: 133
From Wikipedia:
an index-node (inode) is a data structure on a traditional Unix-style file system such as UFS. An inode stores all the information about a regular file, directory, or other file system object, except its data and name.
The usual file systems used by Windows aren't built around the inode concept, they're different, so there is no "inode number" to report, among other things.
Here's a link with clear explanation: Inode Explanation
Upvotes: 1
Reputation: 28575
From windows stat docs,
st_ino
Number of the information node (the inode) for the file (UNIX-specific). On UNIX file systems, the inode describes the file date and time stamps, permissions, and content. When files are hard-linked to one another, they share the same inode. The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or NTFS file systems.
So, don't rely on the inode number on Windows systems. Its a Unix-specific concept.
Refer this SO post for some ideas on how Windows manages files without inodes but using something similar.
Upvotes: 4