How to remove quotes from std :: filesystem :: path
If I use functions like absolute()
, I always get a path containing quotes.
Is there a way in filesystem functions to remove those quotes that allow it to use, for example std :: ifstream?
fs::path p2 { "./test/hallo.txt" };
std::cout << "absolte to file : " << fs::absolute(p2) << std::endl;
returns:
"/home/bla/blub/./test/hallo.txt"
I need
/home/bla/blub/./test/hallo.txt
instead.
No need to do it manually, but I want to ask if there is a method inside the file library.
source to share
std::operator << (std::filesystem::path const &)
is indicated as follows:
Performs input or output to the stream at path p.
std::quoted
is used so that spaces are not truncated [sic] when later read by a stream input statement.
So this is the expected streaming behavior. You need path::string()
:
Returns an internal path in native path format converted to a specific string type.
std::cout << "absolte to file : " << absolute(p2).string() << std::endl;
// ^^^^^^^^^
I also uninstalled fs::
, as absolute
can be found via ADL.
source to share