summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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