void CCRUDProcessor::ProcessFiles(TFileList &fileList, const char *pSourceDir, const char *pDestDir, bool bRecursive, CCRUDResults &results) { OutputResult("Processing File List.."); TFileList::iterator curFile = fileList.begin(); TDateTime timeBegin; timeBegin = timeBegin.CurrentDateTime(); results.m_iFilesFound = 0; results.m_iFilesCopied = 0; int nTopLevel = fileList.size(); ResetEvent(m_hStopEvent); while ((WaitForSingleObject(m_hStopEvent, 0) == WAIT_TIMEOUT) && (curFile != fileList.end())) { // Count this file ++results.m_iFilesFound; // Get the source file name string curFileName(pSourceDir); curFileName += '\\'; curFileName += *curFile; CleanPath(curFileName.begin()); // Look for new files in this file bool bSearchInFile = bRecursive || nTopLevel; if (!bSearchInFile || SearchForNewFiles(fileList, curFileName.begin())) { // Get the destination file name string destFileName(pDestDir); destFileName += '\\'; destFileName += *curFile; CleanPath(destFileName.begin()); // Copy it if it needs to be updated if (MaybeCopyFile(curFileName.begin(), destFileName.begin())) ++results.m_iFilesCopied; } if (nTopLevel) --nTopLevel; // Go to the next file in the list ++curFile; // Breathe Application->ProcessMessages(); } results.m_ProcessingTime = timeBegin.CurrentDateTime() - timeBegin; }
void Loga(String msg) { FILE *fp; if ( ( fp = fopen(FILE_LOG, "at")) != NULL ) { TDateTime dt; dt = dt.CurrentDateTime(); String S = dt.FormatString("dd/mm/yy hh:nn:ss("); S = S + GetTickCount() % 1000; S = S + ") - " + msg; if ( FormMain->lbLog->Items->Count > 150 ) { FormMain->lbLog->Items->Delete(0); } FormMain->lbLog->Items->Add(S); fprintf( fp, S.c_str() ); fprintf( fp, "\n" ); fclose( fp ); } }