Know the number of files / directories before doing a FSCTL_ENUM_USN_DATA

405 views Asked by At

Before doing a USN journal / NTFS MFT files-enumeration with

while (DeviceIoControl(hDrive, FSCTL_ENUM_USN_DATA, &med, sizeof(med), pData, sizeof(pData), &cb, NULL))
{
    // do stuff here
    med.StartFileReferenceNumber = *((DWORDLONG*) pData);    // pData contains FRN for next FSCTL_ENUM_USN_DATA
}

I'd like to know the number of files/directories (to "reserve" a std::vector: v.reserve(...) and also other reasons).

I thought about using FSCTL_QUERY_USN_JOURNAL before, that gives a USN_JOURNAL_DATA_V0 containing informations about the volume.

Unfortnuately FirstUsn, NextUsn, MaxUsn don't give this information. Even if I have 100k files on the volume, NextUsn can be 10 millions for example, so it doesn't give the right order of magnitude.

How to get the number of files / directories before doing a FSCTL_ENUM_USN_DATA?

0

There are 0 answers