mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
SkinInstaller: Fix issues with paths containing Unicode characters
This commit is contained in:
parent
c7e172f906
commit
05c6ce1ce7
@ -293,37 +293,3 @@ OSPLATFORM GetOSPlatform()
|
||||
|
||||
return OSPLATFORM_UNKNOWN;
|
||||
}
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str && *str)
|
||||
{
|
||||
int strLen = (int)wcslen(str);
|
||||
int bufLen = WideCharToMultiByte(CP_ACP, 0, str, strLen, NULL, 0, NULL, NULL);
|
||||
if (bufLen > 0)
|
||||
{
|
||||
szAscii.resize(bufLen);
|
||||
WideCharToMultiByte(CP_ACP, 0, str, strLen, &szAscii[0], bufLen, NULL, NULL);
|
||||
}
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str && *str)
|
||||
{
|
||||
int strLen = (int)strlen(str);
|
||||
int bufLen = MultiByteToWideChar(CP_ACP, 0, str, strLen, NULL, 0);
|
||||
if (bufLen > 0)
|
||||
{
|
||||
szWide.resize(bufLen);
|
||||
MultiByteToWideChar(CP_ACP, 0, str, strLen, &szWide[0], bufLen);
|
||||
}
|
||||
}
|
||||
return szWide;
|
||||
}
|
@ -53,7 +53,5 @@ OSPLATFORM GetOSPlatform();
|
||||
|
||||
bool IsRunning(const WCHAR* name, HANDLE* hMutex);
|
||||
bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
||||
std::string ConvertToAscii(LPCTSTR str);
|
||||
std::wstring ConvertToWide(LPCSTR str);
|
||||
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "DialogInstall.h"
|
||||
#include "../Library/pcre-8.10/config.h"
|
||||
#include "../Library/pcre-8.10/pcre.h"
|
||||
#include "../Common/StringUtil.h"
|
||||
#include "resource.h"
|
||||
#include "../Version.h"
|
||||
|
||||
@ -388,7 +389,7 @@ bool CDialogInstall::ReadPackage()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_PackageUnzFile = unzOpen(ConvertToAscii(fileName).c_str());
|
||||
m_PackageUnzFile = unzOpen(StringUtil::NarrowUTF8(fileName).c_str());
|
||||
if (!m_PackageUnzFile)
|
||||
{
|
||||
return false;
|
||||
@ -409,7 +410,7 @@ bool CDialogInstall::ReadPackage()
|
||||
unz_file_info ufi;
|
||||
if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH);
|
||||
MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH);
|
||||
while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\';
|
||||
return true;
|
||||
}
|
||||
@ -717,7 +718,7 @@ bool CDialogInstall::InstallPackage()
|
||||
unz_file_info ufi;
|
||||
if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH);
|
||||
MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH);
|
||||
while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\';
|
||||
return true;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Application.h"
|
||||
#include "DialogPackage.h"
|
||||
#include "DialogInstall.h"
|
||||
#include "../Common/StringUtil.h"
|
||||
#include "resource.h"
|
||||
#include "../Version.h"
|
||||
|
||||
@ -264,7 +265,7 @@ bool CDialogPackage::CreatePackage()
|
||||
WritePrivateProfileString(L"rmskin", L"MinimumWindows", m_MinimumWindows.c_str(), tempFile);
|
||||
|
||||
// Create archive and add options file and header bitmap
|
||||
m_ZipFile = zipOpen(ConvertToAscii(m_TargetFile.c_str()).c_str(), APPEND_STATUS_CREATE);
|
||||
m_ZipFile = zipOpen(StringUtil::NarrowUTF8(m_TargetFile).c_str(), APPEND_STATUS_CREATE);
|
||||
|
||||
auto cleanup = [&]()->bool
|
||||
{
|
||||
@ -379,16 +380,16 @@ unsigned __stdcall CDialogPackage::PackagerThreadProc(void* pParam)
|
||||
|
||||
bool CDialogPackage::AddFileToPackage(const WCHAR* filePath, const WCHAR* zipPath)
|
||||
{
|
||||
std::string zipPathAscii = ConvertToAscii(zipPath);
|
||||
for (int i = 0, isize = zipPathAscii.length(); i < isize; ++i)
|
||||
std::string zipPathUTF8 = StringUtil::NarrowUTF8(zipPath);
|
||||
for (int i = 0, isize = zipPathUTF8.length(); i < isize; ++i)
|
||||
{
|
||||
if (zipPathAscii[i] == '\\')
|
||||
if (zipPathUTF8[i] == '\\')
|
||||
{
|
||||
zipPathAscii[i] = '/';
|
||||
zipPathUTF8[i] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
int open = zipOpenNewFileInZip(m_ZipFile, zipPathAscii.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
int open = zipOpenNewFileInZip(m_ZipFile, zipPathUTF8.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
if (open != ZIP_OK)
|
||||
{
|
||||
return false;
|
||||
@ -743,7 +744,7 @@ INT_PTR CALLBACK CDialogPackage::SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARA
|
||||
|
||||
bool x32 = LOWORD(wParam) == IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON;
|
||||
|
||||
LOADED_IMAGE* loadedImage = ImageLoad(ConvertToAscii(buffer).c_str(), NULL);
|
||||
LOADED_IMAGE* loadedImage = ImageLoad(StringUtil::NarrowUTF8(buffer).c_str(), NULL);
|
||||
if (loadedImage)
|
||||
{
|
||||
WORD machine = loadedImage->FileHeader->FileHeader.Machine;
|
||||
|
@ -134,6 +134,7 @@
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Common\StringUtil.cpp" />
|
||||
<ClCompile Include="..\Library\Dialog.cpp" />
|
||||
<ClCompile Include="Application.cpp" />
|
||||
<ClCompile Include="DialogInstall.cpp" />
|
||||
@ -170,6 +171,7 @@
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Common\StringUtil.h" />
|
||||
<ClInclude Include="..\Library\Dialog.h" />
|
||||
<ClInclude Include="Application.h" />
|
||||
<ClInclude Include="DialogInstall.h" />
|
||||
|
@ -22,6 +22,9 @@
|
||||
<Filter Include="pcre">
|
||||
<UniqueIdentifier>{73cc243e-5b60-4fbc-ae48-069c6decc4ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Common">
|
||||
<UniqueIdentifier>{65d4ccc5-15bd-4268-a539-ebf090e28d5d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Application.cpp">
|
||||
@ -87,6 +90,9 @@
|
||||
<ClCompile Include="DialogPackage.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\StringUtil.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
@ -155,6 +161,9 @@
|
||||
<ClInclude Include="DialogPackage.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Common\StringUtil.h">
|
||||
<Filter>Common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Res\SkinInstaller.ico">
|
||||
|
Loading…
Reference in New Issue
Block a user