SGPath can convert to std::wstring

This commit is contained in:
James Turner 2016-07-02 09:34:27 +01:00
parent 32735428bb
commit cf18d4eaaf
2 changed files with 21 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <fstream>
#include <cstdlib>
#ifdef _WIN32
# include <direct.h>
@ -980,3 +981,22 @@ std::string SGPath::join(const std::vector<SGPath>& paths, const std::string& jo
return r;
}
//------------------------------------------------------------------------------
std::wstring SGPath::wstr() const
{
#ifdef SG_WINDOWS
return std::wstring();
#else
wchar_t wideBuf[2048];
size_t count = mbstowcs(wideBuf, path.c_str(), 2048);
if (count == -1) {
return std::wstring();
} else if (count == 2048) {
SG_LOG( SG_GENERAL, SG_ALERT, "SGPath::wstr: overflowed conversion buffer for " << *this );
}
return std::wstring(wideBuf, count);
#endif
}

View File

@ -190,6 +190,7 @@ public:
std::string local8BitStr() const;
std::wstring wstr() const;
/**
* Get the path string