Question

How can I write filesystem-dependent code in C++? I am writing a user level library that should handle files in different ways depending on certain features in the underlying filesystem, how can I figure that out?

For example, are there any defined preprocessor directives that expose the filesystem?

Was it helpful?

Solution

On Windows, you can use the GetVolumeInformation function. On Linux and OSX (and BSD!), you can use the statfs function.

OTHER TIPS

I'm not aware of any information that the preprocessor would give you on this.

Something to keep in mind is that you might be in a situation where the OS supports multiple types of filesystems. It's not inconceivable that an application might be accessing multiple filesystems at the same time on the same box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top