SGPath can convert to std::wstring
This commit is contained in:
parent
32735428bb
commit
cf18d4eaaf
@ -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
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,7 @@ public:
|
||||
|
||||
std::string local8BitStr() const;
|
||||
|
||||
std::wstring wstr() const;
|
||||
|
||||
/**
|
||||
* Get the path string
|
||||
|
Loading…
Reference in New Issue
Block a user