From 46bd23bb19193e78e544d07a721e96548a7ab60a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 30 Sep 2012 14:50:03 +0000 Subject: fix for DLLs with the trailing W in names git-svn-id: http://svn.miranda-ng.org/main/trunk@1729 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/Common.h | 3 ++- plugins/PluginUpdater/src/Notifications.cpp | 6 +++--- plugins/PluginUpdater/src/Scanner.cpp | 23 ++++++++++++++--------- plugins/PluginUpdater/src/Utils.cpp | 9 +++++++++ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index e6eb4340b7..066e03c17b 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -67,7 +67,7 @@ struct FILEINFO { TCHAR tszOldName[MAX_PATH], tszNewName[MAX_PATH]; FILEURL File; - BOOL enabled; + BOOL enabled, bDeleteOnly; BYTE FileType; int FileNum; BYTE Force; @@ -145,6 +145,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); bool unzip(const TCHAR *ptszOldFileName, const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath); +void strdel(TCHAR *parBuffer, int len); #if MIRANDA_VER < 0x0A00 diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 4a07b446fb..aad66b965e 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -279,12 +279,12 @@ static void ApplyUpdates(void *param) continue; FILEINFO& p = todo[i]; - if (p.tszNewName[0] == 0) { // delete only - TCHAR *ptszRelPath = p.tszOldName + _tcslen(tszMirandaPath) + 1; + if (p.bDeleteOnly) { // delete only + TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1; TCHAR tszBackFile[MAX_PATH]; mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath); DeleteFile(tszBackFile); - MoveFile(p.tszOldName, tszBackFile); + MoveFile(p.tszNewName, tszBackFile); } else if ( unzip(p.tszOldName, p.File.tszDiskPath, tszMirandaPath, tszFileBack)) DeleteFile(p.File.tszDiskPath); diff --git a/plugins/PluginUpdater/src/Scanner.cpp b/plugins/PluginUpdater/src/Scanner.cpp index 6f0a266296..e0a4952b47 100644 --- a/plugins/PluginUpdater/src/Scanner.cpp +++ b/plugins/PluginUpdater/src/Scanner.cpp @@ -123,15 +123,16 @@ static void ScanFolder(const TCHAR *tszFolder, const TCHAR *tszBaseUrl, SERVLIST ServListEntry tmp = {NULL, key}; ServListEntry *item = hashes.find(&tmp); if (item == NULL) { - size_t cbKeyLen = _tcslen(key)-1; - if (key[cbKeyLen] != 'w') + TCHAR *p = _tcschr(key, '.'); + if (p[-1] != 'w') continue; - key[cbKeyLen] = 0; + int iPos = int(p - key)-1; + strdel(p-1, 1); if ((item = hashes.find(&tmp)) == NULL) continue; - ffd.cFileName[cbKeyLen] = 0; + strdel(tszNewName+iPos, 1); } size_t cbLenOrig = _tcslen(item->m_name); @@ -157,11 +158,15 @@ static void ScanFolder(const TCHAR *tszFolder, const TCHAR *tszBaseUrl, SERVLIST // Compare versions if ( strcmp(szMyHash, szSiteHash)) { // Yeah, we've got new version. FILEINFO *FileInfo = new FILEINFO; - _tcscpy(FileInfo->tszNewName, tszNewName); - if (tszNewName[0]) - _tcscpy(FileInfo->tszOldName, ffd.cFileName); - else - _tcscpy(FileInfo->tszOldName, tszMask); // + _tcscpy(FileInfo->tszOldName, ffd.cFileName); + if (tszNewName[0] == 0) { + FileInfo->bDeleteOnly = TRUE; + _tcscpy(FileInfo->tszNewName, tszMask); + } + else { + FileInfo->bDeleteOnly = FALSE; + _tcscpy(FileInfo->tszNewName, tszNewName); + } *pExt = 0; mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszNewName); diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 91716a45c6..ad1a5fe774 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -226,6 +226,15 @@ void InitTimer() } } +void strdel(TCHAR *parBuffer, int len ) +{ + TCHAR* p; + for (p = parBuffer+len; *p != 0; p++) + p[ -len ] = *p; + + p[ -len ] = '\0'; +} + #if MIRANDA_VER < 0x0A00 char* rtrim(char *str) { -- cgit v1.2.3