Frage

I am having an odd issue when using the file_size method from the boost library. If the path that I try to dereference using a directory iterator is not the current path where the executable is, then I get a value of 0 for any file sizes I try to return. So if my path variable is instantiated to "." for the current folder it will return byte sizes no problem but if I go one folder up or a path anywhere on the C drive the byte size of files is not returned. Is this an issue with scope or is there something I'm missing?

War es hilfreich?

Lösung

Turns out that if you are using a directory_iterator and are trying to find the file_size( dirIter->path() ) it will only work for the current folder the executable is in. However, if you concatenate the path of the directory you are searching using the variable name you assigned (for instance path p = "." ) it will return byte sizes for any file in any folder searched (an example of how to make it work would be file_size( p / dirIter->path() ) where the / is the overloaded concatenation operator in the boost library).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top