Windows: Use wide-character system APIs
Make CMake compile with -DUNICODE. Make it possible for the 8 bit encoding to eventually be UTF-8 instead ANSI.
This commit is contained in:
parent
ce598cc838
commit
0b9906c2fb
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <cmsys/SystemTools.hxx>
|
#include <cmsys/SystemTools.hxx>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
#include <rpc.h> // for GUID generation
|
#include <rpc.h> // for GUID generation
|
||||||
|
|
||||||
|
@ -954,11 +955,12 @@ std::string cmCPackWIXGenerator::GenerateGUID()
|
||||||
UUID guid;
|
UUID guid;
|
||||||
UuidCreate(&guid);
|
UuidCreate(&guid);
|
||||||
|
|
||||||
unsigned char *tmp = 0;
|
unsigned short *tmp = 0;
|
||||||
UuidToString(&guid, &tmp);
|
UuidToStringW(&guid, &tmp);
|
||||||
|
|
||||||
std::string result(reinterpret_cast<char*>(tmp));
|
std::string result =
|
||||||
RpcStringFree(&tmp);
|
cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(tmp));
|
||||||
|
RpcStringFreeW(&tmp);
|
||||||
|
|
||||||
return cmSystemTools::UpperCase(result);
|
return cmSystemTools::UpperCase(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
#include "cmExportBuildFileGenerator.h"
|
#include "cmExportBuildFileGenerator.h"
|
||||||
|
|
||||||
|
@ -252,14 +253,14 @@ void cmExportCommand::ReportRegistryError(std::string const& msg,
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << msg << "\n"
|
e << msg << "\n"
|
||||||
<< " HKEY_CURRENT_USER\\" << key << "\n";
|
<< " HKEY_CURRENT_USER\\" << key << "\n";
|
||||||
char winmsg[1024];
|
wchar_t winmsg[1024];
|
||||||
if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
|
if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
|
FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
winmsg, 1024, 0) > 0)
|
winmsg, 1024, 0) > 0)
|
||||||
{
|
{
|
||||||
e << "Windows reported:\n"
|
e << "Windows reported:\n"
|
||||||
<< " " << winmsg;
|
<< " " << cmsys::Encoding::ToNarrow(winmsg);
|
||||||
}
|
}
|
||||||
this->Makefile->IssueMessage(cmake::WARNING, e.str());
|
this->Makefile->IssueMessage(cmake::WARNING, e.str());
|
||||||
}
|
}
|
||||||
|
@ -272,8 +273,9 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
|
||||||
std::string key = "Software\\Kitware\\CMake\\Packages\\";
|
std::string key = "Software\\Kitware\\CMake\\Packages\\";
|
||||||
key += package;
|
key += package;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
LONG err = RegCreateKeyEx(HKEY_CURRENT_USER,
|
LONG err = RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||||
key.c_str(), 0, 0, REG_OPTION_NON_VOLATILE,
|
cmsys::Encoding::ToWide(key).c_str(),
|
||||||
|
0, 0, REG_OPTION_NON_VOLATILE,
|
||||||
KEY_SET_VALUE, 0, &hKey, 0);
|
KEY_SET_VALUE, 0, &hKey, 0);
|
||||||
if(err != ERROR_SUCCESS)
|
if(err != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -281,8 +283,11 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
|
||||||
"Cannot create/open registry key", key, err);
|
"Cannot create/open registry key", key, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
err = RegSetValueEx(hKey, hash, 0, REG_SZ, (BYTE const*)content,
|
|
||||||
static_cast<DWORD>(strlen(content)+1));
|
std::wstring wcontent = cmsys::Encoding::ToWide(content);
|
||||||
|
err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(),
|
||||||
|
0, REG_SZ, (BYTE const*)wcontent.c_str(),
|
||||||
|
static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t));
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
if(err != ERROR_SUCCESS)
|
if(err != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
# include <cmsys/hash_map.hxx>
|
# include <cmsys/hash_map.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
// Use a platform-specific API to get file times efficiently.
|
// Use a platform-specific API to get file times efficiently.
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
# define cmFileTimeComparison_Type struct stat
|
# define cmFileTimeComparison_Type struct stat
|
||||||
|
@ -86,7 +88,8 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
|
||||||
// Windows version. Get the modification time from extended file
|
// Windows version. Get the modification time from extended file
|
||||||
// attributes.
|
// attributes.
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fdata;
|
WIN32_FILE_ATTRIBUTE_DATA fdata;
|
||||||
if(!GetFileAttributesEx(fname, GetFileExInfoStandard, &fdata))
|
if(!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(),
|
||||||
|
GetFileExInfoStandard, &fdata))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
#include "cmVariableWatch.h"
|
#include "cmVariableWatch.h"
|
||||||
|
@ -1245,23 +1246,23 @@ void cmFindPackageCommand::LoadPackageRegistryWinSystem()
|
||||||
void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
|
void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
|
||||||
unsigned int view)
|
unsigned int view)
|
||||||
{
|
{
|
||||||
std::string key = "Software\\Kitware\\CMake\\Packages\\";
|
std::wstring key = L"Software\\Kitware\\CMake\\Packages\\";
|
||||||
key += this->Name;
|
key += cmsys::Encoding::ToWide(this->Name);
|
||||||
std::set<cmStdString> bad;
|
std::set<std::wstring> bad;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if(RegOpenKeyEx(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(),
|
if(RegOpenKeyExW(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(),
|
||||||
0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS)
|
0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD valueType = REG_NONE;
|
DWORD valueType = REG_NONE;
|
||||||
char name[16384];
|
wchar_t name[16383]; // RegEnumValue docs limit name to 32767 _bytes_
|
||||||
std::vector<char> data(512);
|
std::vector<wchar_t> data(512);
|
||||||
bool done = false;
|
bool done = false;
|
||||||
DWORD index = 0;
|
DWORD index = 0;
|
||||||
while(!done)
|
while(!done)
|
||||||
{
|
{
|
||||||
DWORD nameSize = static_cast<DWORD>(sizeof(name));
|
DWORD nameSize = static_cast<DWORD>(sizeof(name));
|
||||||
DWORD dataSize = static_cast<DWORD>(data.size()-1);
|
DWORD dataSize = static_cast<DWORD>(data.size()*sizeof(data[0]));
|
||||||
switch(RegEnumValue(hKey, index, name, &nameSize,
|
switch(RegEnumValueW(hKey, index, name, &nameSize,
|
||||||
0, &valueType, (BYTE*)&data[0], &dataSize))
|
0, &valueType, (BYTE*)&data[0], &dataSize))
|
||||||
{
|
{
|
||||||
case ERROR_SUCCESS:
|
case ERROR_SUCCESS:
|
||||||
|
@ -1269,7 +1270,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
|
||||||
if(valueType == REG_SZ)
|
if(valueType == REG_SZ)
|
||||||
{
|
{
|
||||||
data[dataSize] = 0;
|
data[dataSize] = 0;
|
||||||
cmsys_ios::stringstream ss(&data[0]);
|
cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0]));
|
||||||
if(!this->CheckPackageRegistryEntry(ss))
|
if(!this->CheckPackageRegistryEntry(ss))
|
||||||
{
|
{
|
||||||
// The entry is invalid.
|
// The entry is invalid.
|
||||||
|
@ -1278,7 +1279,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ERROR_MORE_DATA:
|
case ERROR_MORE_DATA:
|
||||||
data.resize(dataSize+1);
|
data.resize((dataSize+sizeof(data[0])-1)/sizeof(data[0]));
|
||||||
break;
|
break;
|
||||||
case ERROR_NO_MORE_ITEMS: default: done = true; break;
|
case ERROR_NO_MORE_ITEMS: default: done = true; break;
|
||||||
}
|
}
|
||||||
|
@ -1288,13 +1289,13 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
|
||||||
|
|
||||||
// Remove bad values if possible.
|
// Remove bad values if possible.
|
||||||
if(user && !bad.empty() &&
|
if(user && !bad.empty() &&
|
||||||
RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(),
|
RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(),
|
||||||
0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS)
|
0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
for(std::set<cmStdString>::const_iterator vi = bad.begin();
|
for(std::set<std::wstring>::const_iterator vi = bad.begin();
|
||||||
vi != bad.end(); ++vi)
|
vi != bad.end(); ++vi)
|
||||||
{
|
{
|
||||||
RegDeleteValue(hKey, vi->c_str());
|
RegDeleteValueW(hKey, vi->c_str());
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "cmLocalVisualStudio7Generator.h"
|
#include "cmLocalVisualStudio7Generator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
|
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
|
||||||
const char* platformName)
|
const char* platformName)
|
||||||
|
@ -897,11 +898,11 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
|
||||||
}
|
}
|
||||||
std::string ret;
|
std::string ret;
|
||||||
UUID uid;
|
UUID uid;
|
||||||
unsigned char *uidstr;
|
unsigned short *uidstr;
|
||||||
UuidCreate(&uid);
|
UuidCreate(&uid);
|
||||||
UuidToString(&uid,&uidstr);
|
UuidToStringW(&uid,&uidstr);
|
||||||
ret = reinterpret_cast<char*>(uidstr);
|
ret = cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(uidstr));
|
||||||
RpcStringFree(&uidstr);
|
RpcStringFreeW(&uidstr);
|
||||||
ret = cmSystemTools::UpperCase(ret);
|
ret = cmSystemTools::UpperCase(ret);
|
||||||
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
|
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
|
||||||
ret.c_str(), "Stored GUID",
|
ret.c_str(), "Stored GUID",
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
|
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
|
||||||
|
@ -559,52 +560,53 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
|
||||||
|
|
||||||
keyname = regKeyBase + "\\OtherProjects7";
|
keyname = regKeyBase + "\\OtherProjects7";
|
||||||
hkey = NULL;
|
hkey = NULL;
|
||||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(),
|
result = RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||||
|
cmsys::Encoding::ToWide(keyname).c_str(),
|
||||||
0, KEY_READ, &hkey);
|
0, KEY_READ, &hkey);
|
||||||
if (ERROR_SUCCESS == result)
|
if (ERROR_SUCCESS == result)
|
||||||
{
|
{
|
||||||
// Iterate the subkeys and look for the values of interest in each subkey:
|
// Iterate the subkeys and look for the values of interest in each subkey:
|
||||||
CHAR subkeyname[256];
|
wchar_t subkeyname[256];
|
||||||
DWORD cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]);
|
DWORD cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]);
|
||||||
CHAR keyclass[256];
|
wchar_t keyclass[256];
|
||||||
DWORD cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]);
|
DWORD cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]);
|
||||||
FILETIME lastWriteTime;
|
FILETIME lastWriteTime;
|
||||||
lastWriteTime.dwHighDateTime = 0;
|
lastWriteTime.dwHighDateTime = 0;
|
||||||
lastWriteTime.dwLowDateTime = 0;
|
lastWriteTime.dwLowDateTime = 0;
|
||||||
|
|
||||||
while (ERROR_SUCCESS == RegEnumKeyEx(hkey, index, subkeyname,
|
while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname,
|
||||||
&cch_subkeyname,
|
&cch_subkeyname,
|
||||||
0, keyclass, &cch_keyclass, &lastWriteTime))
|
0, keyclass, &cch_keyclass, &lastWriteTime))
|
||||||
{
|
{
|
||||||
// Open the subkey and query the values of interest:
|
// Open the subkey and query the values of interest:
|
||||||
HKEY hsubkey = NULL;
|
HKEY hsubkey = NULL;
|
||||||
result = RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ, &hsubkey);
|
result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey);
|
||||||
if (ERROR_SUCCESS == result)
|
if (ERROR_SUCCESS == result)
|
||||||
{
|
{
|
||||||
DWORD valueType = REG_SZ;
|
DWORD valueType = REG_SZ;
|
||||||
CHAR data1[256];
|
wchar_t data1[256];
|
||||||
DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]);
|
DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]);
|
||||||
RegQueryValueEx(hsubkey, "Path", 0, &valueType,
|
RegQueryValueExW(hsubkey, L"Path", 0, &valueType,
|
||||||
(LPBYTE) &data1[0], &cch_data1);
|
(LPBYTE) &data1[0], &cch_data1);
|
||||||
|
|
||||||
DWORD data2 = 0;
|
DWORD data2 = 0;
|
||||||
DWORD cch_data2 = sizeof(data2);
|
DWORD cch_data2 = sizeof(data2);
|
||||||
RegQueryValueEx(hsubkey, "Security", 0, &valueType,
|
RegQueryValueExW(hsubkey, L"Security", 0, &valueType,
|
||||||
(LPBYTE) &data2, &cch_data2);
|
(LPBYTE) &data2, &cch_data2);
|
||||||
|
|
||||||
DWORD data3 = 0;
|
DWORD data3 = 0;
|
||||||
DWORD cch_data3 = sizeof(data3);
|
DWORD cch_data3 = sizeof(data3);
|
||||||
RegQueryValueEx(hsubkey, "StorageFormat", 0, &valueType,
|
RegQueryValueExW(hsubkey, L"StorageFormat", 0, &valueType,
|
||||||
(LPBYTE) &data3, &cch_data3);
|
(LPBYTE) &data3, &cch_data3);
|
||||||
|
|
||||||
s2 = cmSystemTools::LowerCase(data1);
|
s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1));
|
||||||
cmSystemTools::ConvertToUnixSlashes(s2);
|
cmSystemTools::ConvertToUnixSlashes(s2);
|
||||||
if (s2 == s1)
|
if (s2 == s1)
|
||||||
{
|
{
|
||||||
macrosRegistered = true;
|
macrosRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fullname(data1);
|
std::string fullname = cmsys::Encoding::ToNarrow(data1);
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string filepath;
|
std::string filepath;
|
||||||
std::string filepathname;
|
std::string filepathname;
|
||||||
|
@ -636,8 +638,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]);
|
cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]);
|
||||||
cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]);
|
cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]);
|
||||||
lastWriteTime.dwHighDateTime = 0;
|
lastWriteTime.dwHighDateTime = 0;
|
||||||
lastWriteTime.dwLowDateTime = 0;
|
lastWriteTime.dwLowDateTime = 0;
|
||||||
}
|
}
|
||||||
|
@ -662,27 +664,28 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
|
||||||
|
|
||||||
keyname = regKeyBase + "\\RecordingProject7";
|
keyname = regKeyBase + "\\RecordingProject7";
|
||||||
hkey = NULL;
|
hkey = NULL;
|
||||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(),
|
result = RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||||
|
cmsys::Encoding::ToWide(keyname).c_str(),
|
||||||
0, KEY_READ, &hkey);
|
0, KEY_READ, &hkey);
|
||||||
if (ERROR_SUCCESS == result)
|
if (ERROR_SUCCESS == result)
|
||||||
{
|
{
|
||||||
DWORD valueType = REG_SZ;
|
DWORD valueType = REG_SZ;
|
||||||
CHAR data1[256];
|
wchar_t data1[256];
|
||||||
DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]);
|
DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]);
|
||||||
RegQueryValueEx(hkey, "Path", 0, &valueType,
|
RegQueryValueExW(hkey, L"Path", 0, &valueType,
|
||||||
(LPBYTE) &data1[0], &cch_data1);
|
(LPBYTE) &data1[0], &cch_data1);
|
||||||
|
|
||||||
DWORD data2 = 0;
|
DWORD data2 = 0;
|
||||||
DWORD cch_data2 = sizeof(data2);
|
DWORD cch_data2 = sizeof(data2);
|
||||||
RegQueryValueEx(hkey, "Security", 0, &valueType,
|
RegQueryValueExW(hkey, L"Security", 0, &valueType,
|
||||||
(LPBYTE) &data2, &cch_data2);
|
(LPBYTE) &data2, &cch_data2);
|
||||||
|
|
||||||
DWORD data3 = 0;
|
DWORD data3 = 0;
|
||||||
DWORD cch_data3 = sizeof(data3);
|
DWORD cch_data3 = sizeof(data3);
|
||||||
RegQueryValueEx(hkey, "StorageFormat", 0, &valueType,
|
RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType,
|
||||||
(LPBYTE) &data3, &cch_data3);
|
(LPBYTE) &data3, &cch_data3);
|
||||||
|
|
||||||
s2 = cmSystemTools::LowerCase(data1);
|
s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1));
|
||||||
cmSystemTools::ConvertToUnixSlashes(s2);
|
cmSystemTools::ConvertToUnixSlashes(s2);
|
||||||
if (s2 == s1)
|
if (s2 == s1)
|
||||||
{
|
{
|
||||||
|
@ -714,14 +717,16 @@ void WriteVSMacrosFileRegistryEntry(
|
||||||
{
|
{
|
||||||
std::string keyname = regKeyBase + "\\OtherProjects7";
|
std::string keyname = regKeyBase + "\\OtherProjects7";
|
||||||
HKEY hkey = NULL;
|
HKEY hkey = NULL;
|
||||||
LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), 0,
|
LONG result = RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||||
|
cmsys::Encoding::ToWide(keyname).c_str(), 0,
|
||||||
KEY_READ|KEY_WRITE, &hkey);
|
KEY_READ|KEY_WRITE, &hkey);
|
||||||
if (ERROR_SUCCESS == result)
|
if (ERROR_SUCCESS == result)
|
||||||
{
|
{
|
||||||
// Create the subkey and set the values of interest:
|
// Create the subkey and set the values of interest:
|
||||||
HKEY hsubkey = NULL;
|
HKEY hsubkey = NULL;
|
||||||
char lpClass[] = "";
|
wchar_t lpClass[] = L"";
|
||||||
result = RegCreateKeyEx(hkey, nextAvailableSubKeyName.c_str(), 0,
|
result = RegCreateKeyExW(hkey,
|
||||||
|
cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0,
|
||||||
lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0);
|
lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0);
|
||||||
if (ERROR_SUCCESS == result)
|
if (ERROR_SUCCESS == result)
|
||||||
{
|
{
|
||||||
|
@ -729,9 +734,10 @@ void WriteVSMacrosFileRegistryEntry(
|
||||||
|
|
||||||
std::string s(macrosFile);
|
std::string s(macrosFile);
|
||||||
cmSystemTools::ReplaceString(s, "/", "\\");
|
cmSystemTools::ReplaceString(s, "/", "\\");
|
||||||
|
std::wstring ws = cmsys::Encoding::ToWide(s);
|
||||||
|
|
||||||
result = RegSetValueEx(hsubkey, "Path", 0, REG_SZ, (LPBYTE) s.c_str(),
|
result = RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(),
|
||||||
static_cast<DWORD>(strlen(s.c_str()) + 1));
|
static_cast<DWORD>(ws.size() + 1)*sizeof(wchar_t));
|
||||||
if (ERROR_SUCCESS != result)
|
if (ERROR_SUCCESS != result)
|
||||||
{
|
{
|
||||||
std::cout << "error result 1: " << result << std::endl;
|
std::cout << "error result 1: " << result << std::endl;
|
||||||
|
@ -741,7 +747,7 @@ void WriteVSMacrosFileRegistryEntry(
|
||||||
// Security value is always "1" for sample macros files (seems to be "2"
|
// Security value is always "1" for sample macros files (seems to be "2"
|
||||||
// if you put the file somewhere outside the standard VSMacros folder)
|
// if you put the file somewhere outside the standard VSMacros folder)
|
||||||
dw = 1;
|
dw = 1;
|
||||||
result = RegSetValueEx(hsubkey, "Security",
|
result = RegSetValueExW(hsubkey, L"Security",
|
||||||
0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
|
0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
|
||||||
if (ERROR_SUCCESS != result)
|
if (ERROR_SUCCESS != result)
|
||||||
{
|
{
|
||||||
|
@ -751,7 +757,7 @@ void WriteVSMacrosFileRegistryEntry(
|
||||||
|
|
||||||
// StorageFormat value is always "0" for sample macros files
|
// StorageFormat value is always "0" for sample macros files
|
||||||
dw = 0;
|
dw = 0;
|
||||||
result = RegSetValueEx(hsubkey, "StorageFormat",
|
result = RegSetValueExW(hsubkey, L"StorageFormat",
|
||||||
0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
|
0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
|
||||||
if (ERROR_SUCCESS != result)
|
if (ERROR_SUCCESS != result)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2224,7 +2224,7 @@ static bool cmLVS6G_IsFAT(const char* dir)
|
||||||
char volRoot[4] = "_:/";
|
char volRoot[4] = "_:/";
|
||||||
volRoot[0] = dir[0];
|
volRoot[0] = dir[0];
|
||||||
char fsName[16];
|
char fsName[16];
|
||||||
if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
|
if(GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
|
||||||
strstr(fsName, "FAT") != 0)
|
strstr(fsName, "FAT") != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include <cmsys/System.h>
|
#include <cmsys/System.h>
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
# include "cmArchiveWrite.h"
|
# include "cmArchiveWrite.h"
|
||||||
# include <cm_libarchive.h>
|
# include <cm_libarchive.h>
|
||||||
|
@ -880,19 +881,23 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
|
||||||
Try multiple times since we may be racing against another process
|
Try multiple times since we may be racing against another process
|
||||||
creating/opening the destination file just before our MoveFileEx. */
|
creating/opening the destination file just before our MoveFileEx. */
|
||||||
int tries = 5;
|
int tries = 5;
|
||||||
while(!MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) && --tries)
|
while(!MoveFileExW(cmsys::Encoding::ToWide(oldname).c_str(),
|
||||||
|
cmsys::Encoding::ToWide(newname).c_str(),
|
||||||
|
MOVEFILE_REPLACE_EXISTING) && --tries)
|
||||||
{
|
{
|
||||||
// Try again only if failure was due to access permissions.
|
// Try again only if failure was due to access permissions.
|
||||||
if(GetLastError() != ERROR_ACCESS_DENIED)
|
if(GetLastError() != ERROR_ACCESS_DENIED)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DWORD attrs = GetFileAttributes(newname);
|
DWORD attrs =
|
||||||
|
GetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str());
|
||||||
if((attrs != INVALID_FILE_ATTRIBUTES) &&
|
if((attrs != INVALID_FILE_ATTRIBUTES) &&
|
||||||
(attrs & FILE_ATTRIBUTE_READONLY))
|
(attrs & FILE_ATTRIBUTE_READONLY))
|
||||||
{
|
{
|
||||||
// Remove the read-only attribute from the destination file.
|
// Remove the read-only attribute from the destination file.
|
||||||
SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY);
|
SetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str(),
|
||||||
|
attrs & ~FILE_ATTRIBUTE_READONLY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1884,10 +1889,12 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
cmSystemToolsWindowsHandle hFrom =
|
cmSystemToolsWindowsHandle hFrom =
|
||||||
CreateFile(fromFile, GENERIC_READ, FILE_SHARE_READ, 0,
|
CreateFileW(cmsys::Encoding::ToWide(fromFile).c_str(),
|
||||||
|
GENERIC_READ, FILE_SHARE_READ, 0,
|
||||||
OPEN_EXISTING, 0, 0);
|
OPEN_EXISTING, 0, 0);
|
||||||
cmSystemToolsWindowsHandle hTo =
|
cmSystemToolsWindowsHandle hTo =
|
||||||
CreateFile(toFile, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
CreateFileW(cmsys::Encoding::ToWide(toFile).c_str(),
|
||||||
|
GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
||||||
if(!hFrom || !hTo)
|
if(!hFrom || !hTo)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1938,7 +1945,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
cmSystemToolsWindowsHandle h =
|
cmSystemToolsWindowsHandle h =
|
||||||
CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
CreateFileW(cmsys::Encoding::ToWide(fname).c_str(),
|
||||||
|
GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||||
if(!h)
|
if(!h)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1964,7 +1972,8 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
cmSystemToolsWindowsHandle h =
|
cmSystemToolsWindowsHandle h =
|
||||||
CreateFile(fname, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
CreateFileW(cmsys::Encoding::ToWide(fname).c_str(),
|
||||||
|
GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
||||||
if(!h)
|
if(!h)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -2059,9 +2068,10 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
|
||||||
std::string exe_dir;
|
std::string exe_dir;
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
(void)argv0; // ignore this on windows
|
(void)argv0; // ignore this on windows
|
||||||
char modulepath[_MAX_PATH];
|
wchar_t modulepath[_MAX_PATH];
|
||||||
::GetModuleFileName(NULL, modulepath, sizeof(modulepath));
|
::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath));
|
||||||
exe_dir = cmSystemTools::GetFilenamePath(modulepath);
|
exe_dir =
|
||||||
|
cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath));
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
(void)argv0; // ignore this on OS X
|
(void)argv0; // ignore this on OS X
|
||||||
# define CM_EXE_PATH_LOCAL_SIZE 16384
|
# define CM_EXE_PATH_LOCAL_SIZE 16384
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cmSystemTools.h>
|
#include <cmSystemTools.h>
|
||||||
|
#include <cmsys/Encoding.hxx>
|
||||||
|
|
||||||
// We don't want any wildcard expansion.
|
// We don't want any wildcard expansion.
|
||||||
// See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx
|
// See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx
|
||||||
|
@ -100,7 +101,7 @@ static std::string getArg(std::string& cmdline) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseCommandLine(LPTSTR wincmdline,
|
static void parseCommandLine(LPWSTR wincmdline,
|
||||||
std::string& lang,
|
std::string& lang,
|
||||||
std::string& srcfile,
|
std::string& srcfile,
|
||||||
std::string& dfile,
|
std::string& dfile,
|
||||||
|
@ -109,7 +110,7 @@ static void parseCommandLine(LPTSTR wincmdline,
|
||||||
std::string& clpath,
|
std::string& clpath,
|
||||||
std::string& binpath,
|
std::string& binpath,
|
||||||
std::string& rest) {
|
std::string& rest) {
|
||||||
std::string cmdline(wincmdline);
|
std::string cmdline = cmsys::Encoding::ToNarrow(wincmdline);
|
||||||
/* self */ getArg(cmdline);
|
/* self */ getArg(cmdline);
|
||||||
lang = getArg(cmdline);
|
lang = getArg(cmdline);
|
||||||
srcfile = getArg(cmdline);
|
srcfile = getArg(cmdline);
|
||||||
|
@ -247,7 +248,7 @@ int main() {
|
||||||
// the same command line verbatim.
|
// the same command line verbatim.
|
||||||
|
|
||||||
std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest;
|
std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest;
|
||||||
parseCommandLine(GetCommandLine(), lang, srcfile, dfile, objfile,
|
parseCommandLine(GetCommandLineW(), lang, srcfile, dfile, objfile,
|
||||||
prefix, cl, binpath, rest);
|
prefix, cl, binpath, rest);
|
||||||
|
|
||||||
// needed to suppress filename output of msvc tools
|
// needed to suppress filename output of msvc tools
|
||||||
|
|
Loading…
Reference in New Issue