From 0f53b90e908db3823329c411cc96931936dcdaab Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Thu, 27 Jul 2017 15:05:30 -0700 Subject: [PATCH] SkinInstaller: Fix installing and creating .rmskin files with Unicode characters path This also cherry-picks https://github.com/madler/zlib/commit/89e335abb49cd5c7d29d94e8f506d3f8ed71315a --- Library/DialogInstall.cpp | 6 +++++- Library/DialogPackage.cpp | 6 +++++- Library/zlib/minizip/iowin32.c | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/DialogInstall.cpp b/Library/DialogInstall.cpp index f1039adc8..ece0c08ef 100644 --- a/Library/DialogInstall.cpp +++ b/Library/DialogInstall.cpp @@ -13,6 +13,8 @@ #include "System.h" #include "../Version.h" +#include "iowin32.h" + #define WM_DELAYED_CLOSE WM_APP + 0 extern GlobalData g_Data; @@ -374,7 +376,9 @@ bool DialogInstall::ReadPackage() return false; } - m_PackageUnzFile = unzOpen(StringUtil::Narrow(fileName).c_str()); + zlib_filefunc64_def zlibFileFunc; + fill_win32_filefunc64W(&zlibFileFunc); + m_PackageUnzFile = unzOpen2_64(fileName, &zlibFileFunc); if (!m_PackageUnzFile) { return false; diff --git a/Library/DialogPackage.cpp b/Library/DialogPackage.cpp index 30d7f2c31..994df65bd 100644 --- a/Library/DialogPackage.cpp +++ b/Library/DialogPackage.cpp @@ -13,6 +13,8 @@ #include "resource.h" #include "../Version.h" +#include "iowin32.h" + #define WM_DELAYED_CLOSE WM_APP + 0 extern GlobalData g_Data; @@ -255,7 +257,9 @@ bool DialogPackage::CreatePackage() m_AllowNonAsciiFilenames = DialogInstall::CompareVersions(m_MinimumRainmeter, L"3.0.1") != -1; // Create archive and add options file and header bitmap - m_ZipFile = zipOpen(StringUtil::Narrow(m_TargetFile.c_str()).c_str(), APPEND_STATUS_CREATE); + zlib_filefunc64_def zlibFileFunc; + fill_win32_filefunc64W(&zlibFileFunc); + m_ZipFile = zipOpen2_64(m_TargetFile.c_str(), APPEND_STATUS_CREATE, nullptr, &zlibFileFunc); auto cleanup = [&]()->bool { diff --git a/Library/zlib/minizip/iowin32.c b/Library/zlib/minizip/iowin32.c index 711214758..52a44fc16 100644 --- a/Library/zlib/minizip/iowin32.c +++ b/Library/zlib/minizip/iowin32.c @@ -243,7 +243,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); #else LONG lHigh = pos.HighPart; - DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT); + DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); BOOL fOk = TRUE; if (dwNewPos == 0xFFFFFFFF) if (GetLastError() != NO_ERROR) @@ -370,7 +370,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off { LARGE_INTEGER pos; pos.QuadPart = offset; - if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT)) + if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) { DWORD dwErr = GetLastError(); ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;