I have a single line of code for which I include the boost-filesystem 1.64 library which I'd love to remove, so I can remove the dependency on Boost altogether from my program.
The line itself:
std::string currentPath = boost::filesystem::current_path().string();
I'm searching for a replacement that gives me a std::string currentPath
that works on Windows and Linux with the compilers Visual C++ and LLVM. If possible also for GCC.
It's probably true that I haven't looked hard enough, but I am still learning C++ and don't actually know a lot about the standard library. Therefore I'm asking this question.
The current solution is to rely on:
std::experimental::filesystem::current_path();
I suggest you take the source code from Boost, adapt/decrustify it and move on. It is not much more than a wrapper around
getcwd()
(POSIX) andGetCurrentDirectoryW
(Windows). You can throw it out later whenstd::filesystem::current_path()
becomes broadly available.If you wonder how
BOOST_POSIX_API
is set (referenced in the method), have a look at this snippet: