I am using the Visual Studio 2013 TR2 filesystem library. I am seeing a bug when converting a UNC path to a string:
#include "StdAfx.h"
#include <filesystem>
#include <iostream>
//------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
namespace fs = std::tr2::sys;
fs::path fsPath = "//server/dir";
std::string sPath = fsPath;
std::cout << sPath.c_str() << "\n";
}
This will output "\server\dir", not "\\server\dir".
Is there a fix or a workaround for this? Am I doing something wrong?
Well I found a workaround that works for me. If I use
I can now pass that string to the std::ifstream constructor. The path string will be "//server/dir" rather than "\\server\dir".