summaryrefslogtreecommitdiff
path: root/plugins/Db_autobackups/src/backup.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2014-12-12 09:14:43 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2014-12-12 09:14:43 +0000
commit91476fb1dd38562f3127ba5522578ff6fdee45f8 (patch)
tree8cea9344a3c866b475af40a22a8216ad57aa9db8 /plugins/Db_autobackups/src/backup.cpp
parent266e4e01e879d02f16fa1940aaeaa29b0990756d (diff)
db_autobackups:
-Fix for #847 git-svn-id: http://svn.miranda-ng.org/main/trunk@11341 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db_autobackups/src/backup.cpp')
-rw-r--r--plugins/Db_autobackups/src/backup.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index 2ef45183dd..792b02bdba 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -175,34 +175,32 @@ int RotateBackups(TCHAR *backupfolder, TCHAR *dbname)
{
size_t i = 0;
backupFile *bf = NULL, *bftmp;
- HANDLE hFind;
- WIN32_FIND_DATA FindFileData;
TCHAR backupfolderTmp[MAX_PATH];
-
- mir_sntprintf(backupfolderTmp, SIZEOF(backupfolderTmp), _T("%s\\%s*"), backupfolder, dbname);
- hFind = FindFirstFile(backupfolderTmp, &FindFileData);
- if (hFind == INVALID_HANDLE_VALUE)
- goto err_out;
- do {
- if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- continue;
- bftmp = (backupFile*)mir_realloc(bf, ((i + 1) * sizeof(backupFile)));
- if (bftmp == NULL)
- goto err_out;
- bf = bftmp;
- _tcsncpy_s(bf[i].Name, FindFileData.cFileName, _TRUNCATE);
- bf[i].CreationTime = FindFileData.ftCreationTime;
- i ++;
- } while (FindNextFile(hFind, &FindFileData));
-
- if (i > 0)
- qsort(bf, i, sizeof(backupFile), Comp); //Sort the list of found files by date in descending order
- for (i --; i >= (options.num_backups - 1); i --) {
- mir_sntprintf(backupfolderTmp, SIZEOF(backupfolderTmp), _T("%s\\%s"), backupfolder, bf[i].Name);
- DeleteFile(backupfolderTmp);
+ mir_sntprintf(backupfolderTmp, MAX_PATH, _T("%s\\%s*"), backupfolder, dbname);
+ WIN32_FIND_DATA FindFileData;
+ HANDLE hFind = FindFirstFile(backupfolderTmp, &FindFileData);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ continue;
+ bftmp = (backupFile*)mir_realloc(bf, ((i + 1) * sizeof(backupFile)));
+ if (bftmp == NULL) {
+ mir_free(bf);
+ return 0;
+ }
+ bf = bftmp;
+ _tcsncpy_s(bf[i].Name, FindFileData.cFileName, _TRUNCATE);
+ bf[i++].CreationTime = FindFileData.ftCreationTime;
+ } while (FindNextFile(hFind, &FindFileData));
+
+ if (i > 0)
+ qsort(bf, i, sizeof(backupFile), Comp); //Sort the list of found files by date in descending order
+ for (i --; i >= (options.num_backups - 1); i --) {
+ mir_sntprintf(backupfolderTmp, MAX_PATH, _T("%s\\%s"), backupfolder, bf[i].Name);
+ DeleteFile(backupfolderTmp);
+ }
+ FindClose(hFind);
}
-err_out:
- FindClose(hFind);
mir_free(bf);
return 0;
}