Skip to content
Advertisement

Handling file paths cross platform

Do any C++ GNU standalone classes exist which handle paths cross platform? My applications build on Windows and LInux. Our configuration files refer to another file in a seperate directory. I’d like to be able to read the path for the other configuration file into a class which would work on both Linux or Windows.

Which class would offer the smallest footprint to translate paths to use on either system? Thanks

Advertisement

Answer

Unless you’re using absolute paths, there’s no need to translate at all – Windows automatically converts forward slashes into backslashes, so if you use relative paths with forward slash path separators, you’ll be golden. You should really avoid absolute paths if at all possible.

Advertisement