diff options
Diffstat (limited to 'plugins/DbChecker/src/worker.cpp')
-rw-r--r-- | plugins/DbChecker/src/worker.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp index a20dfaef6b..4c7137f9b6 100644 --- a/plugins/DbChecker/src/worker.cpp +++ b/plugins/DbChecker/src/worker.cpp @@ -26,7 +26,7 @@ static void Finalize(time_t& ts) opts.dbChecker->Destroy();
opts.dbChecker = NULL;
- if ( opts.hOutFile ) {
+ if (opts.hOutFile) {
CloseHandle(opts.hOutFile);
opts.hOutFile = NULL;
}
@@ -34,42 +34,42 @@ static void Finalize(time_t& ts) if (errorCount && !opts.bBackup && !opts.bCheckOnly) {
time_t dlg_ts = time(NULL);
if (IDYES == MessageBox(NULL,
- TranslateT("Errors were encountered, however you selected not to backup the original database. It is strongly recommended that you do so in case important data was omitted. Do you wish to keep a backup of the original database?"),
- TranslateT("Miranda Database Tool"), MB_YESNO))
+ TranslateT("Errors were encountered, however you selected not to backup the original database. It is strongly recommended that you do so in case important data was omitted. Do you wish to keep a backup of the original database?"),
+ TranslateT("Miranda Database Tool"), MB_YESNO))
opts.bBackup = 1;
ts += time(NULL) - dlg_ts;
}
if (opts.bBackup) {
- TCHAR dbPath[MAX_PATH],dbFile[MAX_PATH];
+ TCHAR dbPath[MAX_PATH], dbFile[MAX_PATH];
_tcscpy(dbPath, opts.filename);
TCHAR* str2 = _tcsrchr(dbPath, '\\');
if (str2 != NULL) {
- _tcscpy(dbFile, str2+1);
+ _tcscpy(dbFile, str2 + 1);
*str2 = 0;
}
else {
_tcscpy(dbFile, dbPath);
dbPath[0] = 0;
}
- for (int i = 1;;i++) {
+ for (int i = 1;; i++) {
if (i == 1)
mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup of %s"), dbPath, dbFile);
else
mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup (%d) of %s"), dbPath, i, dbFile);
- if (_taccess(opts.backupFilename,0) == -1) break;
+ if (_taccess(opts.backupFilename, 0) == -1) break;
}
- if ( !MoveFile(opts.filename,opts.backupFilename))
- AddToStatus(STATUS_WARNING,TranslateT("Unable to rename original file"));
+ if (!MoveFile(opts.filename, opts.backupFilename))
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to rename original file"));
}
else if (!opts.bCheckOnly)
if (!DeleteFile(opts.filename))
- AddToStatus(STATUS_WARNING,TranslateT("Unable to delete original file"));
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to delete original file"));
if (!opts.bCheckOnly)
if (!MoveFile(opts.outputFilename, opts.filename))
- AddToStatus(STATUS_WARNING,TranslateT("Unable to rename output file"));
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to rename output file"));
}
void __cdecl WorkerThread(void *unused)
@@ -79,19 +79,19 @@ void __cdecl WorkerThread(void *unused) AddToStatus(STATUS_MESSAGE, TranslateT("Database worker thread activated"));
- _tcscpy(opts.workingFilename,opts.filename);
+ _tcscpy(opts.workingFilename, opts.filename);
if (opts.bCheckOnly) {
_tcscpy(opts.outputFilename, TranslateT("<check only>"));
opts.hOutFile = INVALID_HANDLE_VALUE;
}
else {
- _tcscpy(opts.outputFilename,opts.filename);
- *_tcsrchr(opts.outputFilename,'.') = 0;
- _tcscat(opts.outputFilename,TranslateT(" (Output).dat"));
- opts.hOutFile = CreateFile(opts.outputFilename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
+ _tcscpy(opts.outputFilename, opts.filename);
+ *_tcsrchr(opts.outputFilename, '.') = 0;
+ _tcscat(opts.outputFilename, TranslateT(" (Output).dat"));
+ opts.hOutFile = CreateFile(opts.outputFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (opts.hOutFile == INVALID_HANDLE_VALUE) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create output file (%u)"),GetLastError());
+ AddToStatus(STATUS_FATAL, TranslateT("Can't create output file (%u)"), GetLastError());
ProcessingDone();
return;
}
@@ -114,9 +114,9 @@ void __cdecl WorkerThread(void *unused) callback.bConvertUtf = opts.bConvertUtf;
opts.dbChecker->Start(&callback);
- for(task = 0;;) {
- if (callback.spaceProcessed/(callback.spaceUsed/1000+1) > sp) {
- sp = callback.spaceProcessed/(callback.spaceUsed/1000+1);
+ for (task = 0;;) {
+ if (callback.spaceProcessed / (callback.spaceUsed / 1000 + 1) > sp) {
+ sp = callback.spaceProcessed / (callback.spaceUsed / 1000 + 1);
SetProgressBar(sp);
}
WaitForSingleObject(hEventRun, INFINITE);
@@ -124,15 +124,15 @@ void __cdecl WorkerThread(void *unused) AddToStatus(STATUS_FATAL, TranslateT("Processing aborted by user"));
break;
}
-
+
int ret = opts.dbChecker->CheckDb(task, firstTime);
firstTime = 0;
if (ret == ERROR_OUT_OF_PAPER) {
Finalize(ts);
- AddToStatus(STATUS_MESSAGE, TranslateT("Elapsed time: %d sec"), time(NULL)-ts);
- if (errorCount)
+ AddToStatus(STATUS_MESSAGE, TranslateT("Elapsed time: %d sec"), time(NULL) - ts);
+ if (errorCount)
AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed but with errors (%d)"), errorCount);
- else
+ else
AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed successfully"));
break;
}
|