Handling file paths cross platform

Superpolock picture Superpolock · Sep 23, 2008 · Viewed 12.9k times · Source

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

Answer

Adam Rosenfield picture Adam Rosenfield · Sep 23, 2008

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.