How to detect file system size limitations of indi

2019-02-17 17:01发布

问题:

is there a way to detect the file system size limitations of individual files (e.g. 4gb on fat 32)?

It must work on Windows OS, but better would be a portable solution. Detecting the file system type could be a work around, but I don't know how you can do that either.

Can anybody help me out here?

Thank you in advance Tobias

回答1:

You can detect the filesystem type on Windows with GetVolumeInformation



回答2:

You can obtain the total capacity limitations through boost::space(), or directly use POSIX fstatvs().

As for limitations on the size of individual files... the only portable answer that springs to mind is ugly brute force try-to-create-larger-and-larger-files-until-failure, expensive as it is (and impossible if capacity is already limited).