I am writing a cross-platform application that needs to inspect and manipulate Windows-paths.
Specifically, for the particular problem I am having now, I need to know if a path is absolute or relative.
The current code uses boost::filesystem::path
which of course works like a charm on Windows:
boost::filesystem::path the_path(the_path_as_a_string);
if (!the_path.has_root_path()) { /* do stuff */ }
The problem with this approach is that boost::filesystem::path
only has two modes: native and portable. This means that the Windows path grammar is unavailable when I compile under Linux (it is #ifdef
ed out in the source). Hence, the path "C:\path" is considered absolute in Windows, but relative in Linux.
Can you guys recommend a cross-platform C++ library that can inspect and manipulate Windows-paths?
For now, the only Windows-path operation I will do is to check whether a path is absolute or not.
The criterion I will use for an absolute path is that it both contains a drive letter, and the path starts with \
. An example of an absolute path under this criterion is C:\path
. These are both examples of relative paths under this criterion: C:path
, \path
.