From 34572133dc4f3b86f9a3cb9708aa0806f1cfded2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 31 May 2015 07:57:03 +0000 Subject: fix for the temporary file types git-svn-id: http://svn.miranda-ng.org/main/trunk@13927 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber.cpp | 16 ++++++++++++---- protocols/JabberG/src/jabber_misc.cpp | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index a309320cb7..92b8c8872f 100644 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -235,11 +235,19 @@ extern "C" int __declspec(dllexport) Unload(void) DestroyHookableEvent(hDiscoInfoResult); if (g_nTempFileId != 0) { - TCHAR tszTempPath[MAX_PATH], tszTempFile[MAX_PATH]; + TCHAR tszTempPath[MAX_PATH], tszFilePath[MAX_PATH]; GetTempPath(_countof(tszTempPath), tszTempPath); - for (unsigned i = 1; i <= g_nTempFileId; i++) { - GetTempFileName(tszTempPath, _T("jab"), i, tszTempFile); - DeleteFile(tszTempFile); + mir_sntprintf(tszFilePath, _countof(tszFilePath), _T("%sjab*.tmp.*"), tszTempPath); + + WIN32_FIND_DATA findData; + HANDLE hFind = FindFirstFile(tszFilePath, &findData); + if (hFind != INVALID_HANDLE_VALUE) { + do { + mir_sntprintf(tszFilePath, _countof(tszFilePath), _T("%s%s"), tszTempPath, findData.cFileName); + DeleteFile(tszFilePath); + } while (FindNextFile(hFind, &findData)); + + FindClose(hFind); } } diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 21c686a724..06ddbe27ee 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -526,6 +526,8 @@ CMString CJabberProto::ExtractImage(HXML node) TCHAR tszTempPath[MAX_PATH], tszTempFile[MAX_PATH]; GetTempPath(_countof(tszTempPath), tszTempPath); GetTempFileName(tszTempPath, _T("jab"), InterlockedIncrement(&g_nTempFileId), tszTempFile); + _tcsncat_s(tszTempFile, _T("."), 1); + _tcsncat_s(tszTempFile, image, image.GetLength()); HANDLE h = CreateFile(tszTempFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, -- cgit v1.2.3