On Monday, 21 August 2023 at 07:52:28 UTC, harakim wrote:
I have been doing some backups and I wrote a utility that
determines if files are an exact match. As a shortcut, I check
the file size. So far so good on this with millions of files
until I found something odd: getSize() and DirEntry's .size are
producing different values.
...
It seems really odd that getSize(sourceFile.name) is returning
a different number than sourceFile.size. This is an external
HDD on windows formatted in ntfs that it is reading. I believe
I originally wrote the files to the file system in Windows, but
then today I cut and paste them (in the same drive) in Linux.
However, this is the first time this has happened after
millions of comparisons and it only happened for about 6 files.
It does happen consistently though.
I have verified that the file size is that reported by getSize
and not sourceFile.size and that the files open correctly.
...
Can you print some of the wrong sizes? D's DirEntry iteration
code just calls `FindFirstFileW`/`FindNextFileW`, so this
*shouldn't* be a D-specific issue, and it should be possible to
reproduce this in C.