Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 471
Superpolock Avatar asked Sep 23 '08 17:09

Superpolock


People also ask

What are the two types of file paths?

File paths are of two types: Absolute File Paths. Relative File Paths.

What is cross platform in node JS?

Cross-platform if you want Node. js is cross-platform meaning it works on Windows, OSX and Linux. A large number of the Node. js community write Node. js on OSX and then deploy to Linux servers.

What is a file path example?

A path is either relative or absolute. An absolute path always contains the root element and the complete directory list required to locate the file. For example, /home/sally/statusReport is an absolute path. All of the information needed to locate the file is contained in the path string.

What is a file system path?

Alternatively known as the pathname, the current path or path is the complete location or name of where a computer, file, device, or web page is located.


2 Answers

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.

like image 116
Adam Rosenfield Avatar answered Sep 20 '22 18:09

Adam Rosenfield


try boost::filesystem

like image 24
gbjbaanb Avatar answered Sep 16 '22 18:09

gbjbaanb