bump simplecpp 2917a13fbda2df9742d5f45d33f40f58217b6708

This commit is contained in:
Daniel Marjamäki 2016-09-11 20:27:57 +02:00
parent a396e2f839
commit 3bdbce0bde
1 changed files with 22 additions and 8 deletions

View File

@ -1565,19 +1565,33 @@ private:
namespace simplecpp { namespace simplecpp {
#ifdef SIMPLECPP_WINDOWS #ifdef SIMPLECPP_WINDOWS
std::string realFilename(const std::string &f) {
static bool realFileName(const std::vector<TCHAR> &buf, std::ostream &ostr) {
WIN32_FIND_DATA FindFileData; WIN32_FIND_DATA FindFileData;
TCHAR buf[4096] = {0}; HANDLE hFind = FindFirstFile(&buf[0], &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return false;
for (const TCHAR *c = FindFileData.cFileName; *c; c++)
ostr << (char)*c;
FindClose(hFind);
return true;
}
std::string realFilename(const std::string &f) {
std::vector<TCHAR> buf(f.size()+1U, 0);
for (unsigned int i = 0; i < f.size(); ++i) for (unsigned int i = 0; i < f.size(); ++i)
buf[i] = f[i]; buf[i] = f[i];
HANDLE hFind = FindFirstFile(buf, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return f;
std::ostringstream ostr; std::ostringstream ostr;
for (const TCHAR *c = FindFileData.cFileName; *c; c++) { std::string::size_type sep = 0;
ostr << (char)*c; while ((sep = f.find_first_of("\\/", sep + 1U)) != std::string::npos) {
buf[sep] = 0;
if (!realFileName(buf,ostr))
return f;
ostr << '/';
buf[sep] = '/';
} }
FindClose(hFind); if (!realFileName(buf, ostr))
return f;
return ostr.str(); return ostr.str();
} }
#else #else