I am scanning folder size like this:
qint64 dirSize = 0;
int fileCount = 0;
for(QDirIterator itDir(someDir, QDir::NoDotAndDotDot|QDir::Files|QDir::Hidden|QDir::System,
QDirIterator::Subdirectories);
itDir.hasNext(); )
{
itDir.next();
dirSize += itDir.fileInfo().size();
++fileCount;
}
This appears to work fine.
However, I noticed that a folder containing Windows shortcuts (.lnk
) is returning a much larger size than expected. The reason is that the sizes of the shortcut targets are being returned, rather than the sizes of the shortcut files themselves.
But according to QFileInfo documentation:
On Windows, symlinks (shortcuts) are .lnk files. The reported size() is that of the symlink (not the link's target) [...]
So my question is: what am I doing wrong here? How do I get the size of the shortcut file?
.lnk
) files.itDir
should refer to a link, what is returned byitDir.filePath()
(oritDir.fileInfo().filePath()
) -- is it the path of the link itself or the path of the target?