summaryrefslogtreecommitdiff
path: root/plugins/Db_autobackups/src
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2016-03-23 19:48:36 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2016-03-23 19:48:36 +0000
commit930b7f8aa2175f1b114e76b5687c6a4b7d6fee37 (patch)
treeef0b2dc5e74917ee0a645b0735bb2f59c5355c2a /plugins/Db_autobackups/src
parentac208e21f1d573546aed4877532f343a675a6bd3 (diff)
db_autobacktps:
- Fixed handle leak git-svn-id: http://svn.miranda-ng.org/main/trunk@16532 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db_autobackups/src')
-rw-r--r--plugins/Db_autobackups/src/zip.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/plugins/Db_autobackups/src/zip.cpp b/plugins/Db_autobackups/src/zip.cpp
index 2b30fa7430..b1f296f62a 100644
--- a/plugins/Db_autobackups/src/zip.cpp
+++ b/plugins/Db_autobackups/src/zip.cpp
@@ -8,27 +8,36 @@ int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std:
zip_fileinfo fi = { 0 };
+ int ret = 0;
for (int i = 0; i < lstFiles.getCount(); i++)
{
ZipFile &zf = lstFiles[i];
HANDLE hSrcFile = CreateFileA(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, NULL, 0, NULL, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
-
- if (hSrcFile != INVALID_HANDLE_VALUE && iOpenRes == ZIP_OK)
+ if (hSrcFile != INVALID_HANDLE_VALUE)
{
- DWORD dwRead;
- BYTE buf[0x40000];
-
- while (ReadFile(hSrcFile, buf, sizeof(buf), &dwRead, nullptr) && dwRead && (zipWriteInFileInZip(hZip, buf, dwRead) == ZIP_OK));
- zipCloseFileInZip(hZip);
- CloseHandle(hSrcFile);
-
- if (!fnCallback(i))
- return 3;
+ int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, NULL, 0, NULL, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
+
+ if (iOpenRes == ZIP_OK)
+ {
+ DWORD dwRead;
+ BYTE buf[0x40000];
+
+ while (ReadFile(hSrcFile, buf, sizeof(buf), &dwRead, nullptr) && dwRead && (zipWriteInFileInZip(hZip, buf, dwRead) == ZIP_OK));
+ zipCloseFileInZip(hZip);
+ CloseHandle(hSrcFile);
+
+ if (!fnCallback(i))
+ {
+ ret = 3;
+ break;
+ }
+ }
+ else
+ CloseHandle(hSrcFile);
}
}
zipClose(hZip, CMStringA(FORMAT, Translate("Miranda NG [%s] Database Backup"), g_szMirVer));
- return 0;
+ return ret;
} \ No newline at end of file