void __cdecl SmileyDownloadThread(void*) { bool needext = false; HANDLE hHttpDwnl = NULL; WaitForSingleObject(g_hDlMutex, 3000); while (!Miranda_Terminated() && dlQueue.getCount()) { ReleaseMutex(g_hDlMutex); if (_taccess(dlQueue[0].fname.c_str(), 0) != 0) { InternetDownloadFile(T2A_SM(dlQueue[0].url.c_str()), T2A_SM(dlQueue[0].fname.c_str()), hHttpDwnl); WaitForSingleObject(g_hDlMutex, 3000); CMString fname(dlQueue[0].fname); if (dlQueue[0].needext) { fname += GetImageExt(fname); needext = true; } _trename(dlQueue[0].fname.c_str(), fname.c_str()); } else WaitForSingleObject(g_hDlMutex, 3000); dlQueue.remove(0); } dlQueue.destroy(); if (hHttpDwnl) Netlib_CloseHandle(hHttpDwnl); threadRunning = false; ReleaseMutex(g_hDlMutex); if (!Miranda_Terminated()) { if (needext) CallServiceSync(MS_SMILEYADD_RELOAD, 0, 0); else NotifyEventHooks(hEvent1, 0, 0); } }
void CLog::StartNewLogFile() { time_t tStarted = m_tStarted; Close(); TCHAR szDateLogStarted[40]; _tcsftime(szDateLogStarted, ARRSIZE(szDateLogStarted), _T("%Y.%m.%d %H.%M.%S"), localtime(&tStarted)); TCHAR szDrv[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; TCHAR szNam[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; _tsplitpath(m_strFilePath, szDrv, szDir, szNam, szExt); CString strLogBakNam; strLogBakNam = szNam; strLogBakNam += _T(" - "); strLogBakNam += szDateLogStarted; TCHAR szLogBakFilePath[MAX_PATH]; _tmakepath(szLogBakFilePath, szDrv, szDir, strLogBakNam, szExt); if (_trename(m_strFilePath, szLogBakFilePath) != 0) _tremove(m_strFilePath); Open(); }
WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname) { if ( wxUsingUnicowsDll() ) return rename(wxConvFile.cWX2MB(oldname), wxConvFile.cWX2MB(newname)); else return _trename(oldname, newname); }
void CServerList::AutoUpdate() { if (thePrefs.addresses_list.IsEmpty()){ // Comment UI //AfxMessageBox(GetResString(IDS_ERR_EMPTYADRESSESDAT), MB_ICONASTERISK); return; } bool bDownloaded = false; CString servermetdownload; CString servermetbackup; CString servermet; CString strURLToDownload; servermetdownload.Format(_T("%sserver_met.download"), thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); servermetbackup.Format(_T("%sserver_met.old"), thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); servermet.Format(_T("%s") SERVER_MET_FILENAME, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); (void)_tremove(servermetbackup); (void)_tremove(servermetdownload); (void)_trename(servermet, servermetbackup); POSITION Pos = thePrefs.addresses_list.GetHeadPosition(); while (!bDownloaded && Pos != NULL) { // TODO: Comment UI, 移动到emuledlg中去做.. CHttpDownloadDlg dlgDownload; dlgDownload.m_strTitle = GetResString(IDS_HTTP_CAPTION); strURLToDownload = thePrefs.addresses_list.GetNext(Pos); dlgDownload.m_sURLToDownload = strURLToDownload; dlgDownload.m_sFileToDownloadInto = servermetdownload; if (dlgDownload.DoModal() == IDOK) bDownloaded = true; else LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FAILEDDOWNLOADMET), strURLToDownload); } if (bDownloaded) { (void)_trename(servermet, servermetdownload); (void)_trename(servermetbackup, servermet); } else { (void)_tremove(servermet); (void)_trename(servermetbackup, servermet); } }
int CToxProto::OnAccountRenamed(WPARAM, LPARAM) { mir_cslock locker(profileLock); ptrT newPath(GetToxProfilePath()); TCHAR oldPath[MAX_PATH]; mir_sntprintf(oldPath, MAX_PATH, _T("%s\\%s.tox"), VARST(_T("%miranda_userdata%")), accountName); _trename(oldPath, newPath); mir_free(accountName); accountName = mir_tstrdup(m_tszUserName); return 0; }
void TFile::Rename(const KString& FileName) { DEBUG_VERIFY_ALLOCATION; DEBUG_VERIFY(!IsOpen()); DEBUG_VERIFY(m_FilePos.m_bPlainFile); if(_trename(m_FilePos.m_FileName, FileName)) INITIATE_FAILURE; m_FilePos.m_FileName = FileName; }
BOOL CIEMonitor::CheckForUpdate( CString realpath ) { CString oldpath = realpath + _T(".old"); CString newpath = realpath + _T(".new"); if(!PathFileExists(newpath)) return FALSE; if(PathFileExists(realpath)) { if(PathFileExists(oldpath)) { if(_tremove(oldpath) != 0) return FALSE; } if(_trename(realpath, oldpath) != 0) { return FALSE; } UnregisterLibrary(realpath); } _trename(newpath, realpath); return TRUE; }
int my_rename( const char *old_path, const char *new_path ) { DISABLE_ERRORS; int result = -1; auto told_path = tstr(old_path); auto tnew_path = tstr(new_path); LPCTSTR p_old = MRP(told_path.get()); LPCTSTR p_new = MRP2(tnew_path.get()); result = my_access(old_path,0); if(result < 0) { // my_errno already set } else { if(is_same_drive(p_old,p_new)) { result = _trename( p_old, p_new ); if(result != 0) { // by definition, rename may also return a positive value to indicate an error my_errno = errno; } else { my_errno = 0; } } else { if(is_dir(p_old)) { result = folder_copy( p_old, p_new ); // my_errno already set if(result >= 0) { if(myRemoveDirectory( p_old )) { my_errno = 0; result = 0; } else { // there is no proper error code for this failure. my_errno = EACCES; result = -1; } } } else { result = file_move( p_old, p_new ); // my_errno already set } } } D(bug(TEXT("rename(%s,%s,%s,%s) = %d\n"), told_path.get(), p_old, tnew_path.get(), p_new, result)); RESTORE_ERRORS; return result; }
FILE* AppenderFile::OpenFile(std::_tstring const &filename, std::_tstring const &mode, bool backup) { if (mode == _T("w") && backup) { std::wstring newName(filename); newName.push_back('.'); #ifdef _UNICODE std::wstring wstr; ConsoleToWStr(LogMessage::getTimeStr(time(NULL)),wstr); newName.append(wstr); #else newName.append(LogMessage::getTimeStr(time(NULL))); #endif _trename(filename.c_str(), newName.c_str()); // no error handling... if we couldn't make a backup, just ignore } return _tfopen((logDir + filename).c_str(), mode.c_str()); }
// 文件重命名 // const char *pszSrcFileName; // 源文件绝对路径 // const char* pszDesFileName; // 目标文件名 bool CLogMgr::FileReName(const TCHAR *pszSrcFileName, const TCHAR* pszDesFileName) { int nLen = 0; TCHAR szPath[_MAX_FILE_PATH]; TCHAR szDir[_MAX_FILE_PATH]; TCHAR szDrive[_MAX_FILE_PATH]; TCHAR szDesPath[_MAX_FILE_PATH]; memset(szPath, 0x00, _MAX_FILE_PATH); memset(szDir, 0x00, _MAX_FILE_PATH); memset(szDrive, 0x00, _MAX_FILE_PATH); memset(szDesPath, 0x00, _MAX_FILE_PATH); // 分离文件路径 _tsplitpath(pszSrcFileName, szDrive, szDir, NULL, NULL); // 获得目标文件路径 T_SNPRINTF(szPath, (_MAX_FILE_PATH - 1), _T("%s%s"),szDrive,szDir); //如果目录的最后一个字母不是'\',则在最后加上一个'\' nLen=T_STRLEN(szPath); if (szPath[nLen - 1] != _T('\\')) { T_STRCAT(szPath,_T("\\")); } // 获取当前系统时间 SYSTEMTIME oCurrTime; GetLocalTime(&oCurrTime); TCHAR szCurrTime[32]; memset(szCurrTime, 0x00, 32); T_SNPRINTF(szCurrTime, 31, _T("%02d-%02d-%02d-%02d-%02d-%02d"), oCurrTime.wYear, oCurrTime.wMonth, oCurrTime.wDay, oCurrTime.wHour, oCurrTime.wMinute, oCurrTime.wSecond); T_SNPRINTF(szDesPath, 1023, _T("%s%s.%s.log"), szPath, pszDesFileName, szCurrTime); // 重命名文件名 _trename(pszSrcFileName, szDesPath); return true; }
void LogRotate() { CAutoLock lock(&m_logFileLock); TCHAR fileName[MAX_PATH]; LogPath(fileName, _T("log")); try { // Get the last file write date WIN32_FILE_ATTRIBUTE_DATA fileInformation; if (GetFileAttributesEx(fileName, GetFileExInfoStandard, &fileInformation)) { // Convert the write time to local time. SYSTEMTIME stUTC, fileTime; if (FileTimeToSystemTime(&fileInformation.ftLastWriteTime, &stUTC)) { if (SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &fileTime)) { logFileDate = fileTime.wDay; SYSTEMTIME systemTime; GetLocalTime(&systemTime); if(fileTime.wDay == systemTime.wDay && fileInformation.nFileSizeLow <= 10485760) { //file date is today and the file size less then 10MB - no rotation needed return; } } } } } catch (...) {} TCHAR bakFileName[MAX_PATH]; LogPath(bakFileName, _T("bak")); _tremove(bakFileName); _trename(fileName, bakFileName); }
int our_rename(char *oldpath, char *newpath) { #ifdef _WINDOWS LPTSTR pold = NULL, pnew = NULL; int ret = -1; pold = utf8_to_lptstr((LPSTR) oldpath); pnew = utf8_to_lptstr((LPSTR) newpath); if(pold && pnew) ret = _trename(pold, pnew); if(pold) fs_give((void **) &pold); if(pnew) fs_give((void **) &pnew); return ret; #else /* UNIX */ char *p, *pold; size_t len; int ret = -1; p = fname_to_locale(oldpath); if(p){ len = strlen(p); pold = (char *) fs_get((len+1) * sizeof(char)); strncpy(pold, p, len+1); pold[len] = '\0'; ret = rename(pold, fname_to_locale(newpath)); fs_give((void **) &pold); } return ret; #endif /* UNIX */ }
void CPPgSecurity::OnLoadIPFFromURL() { CString url; GetDlgItemText(IDC_UPDATEURL,url); if (!url.IsEmpty()) { // add entered URL to LRU list even if it's not yet known whether we can download from this URL (it's just more convenient this way) if (m_pacIPFilterURL && m_pacIPFilterURL->IsBound()) m_pacIPFilterURL->AddItem(url, 0); TCHAR szTempFilePath[MAX_PATH]; _tmakepath(szTempFilePath, NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T("tmp")); CHttpDownloadDlg dlgDownload; dlgDownload.m_strTitle = _T("Downloading IP filter file"); dlgDownload.m_sURLToDownload = url; dlgDownload.m_sFileToDownloadInto = szTempFilePath; if (dlgDownload.DoModal() != IDOK) { _tremove(szTempFilePath); LogWarning(LOG_STATUSBAR, _T("IP Filter download failed")); return; } bool bIsZipFile = false; bool bUnzipped = false; CZIPFile zip; if (zip.Open(szTempFilePath)) { bIsZipFile = true; CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile) { TCHAR szTempUnzipFilePath[MAX_PATH]; _tmakepath(szTempUnzipFilePath, NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); if (zfile->Extract(szTempUnzipFilePath)) { zip.Close(); zfile = NULL; if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE("*** Error: Failed to remove default IP filter file \"%s\" - %s\n", theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_trename(szTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n", szTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_tremove(szTempFilePath) != 0) TRACE("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n", szTempFilePath, strerror(errno)); bUnzipped = true; } else LogError(LOG_STATUSBAR, _T("Failed to extract IP filter file from downloaded IP filter ZIP file \"%s\"."), szTempFilePath); } else LogError(LOG_STATUSBAR, _T("Downloaded IP filter file \"%s\" is a ZIP file with unexpected content."), szTempFilePath); zip.Close(); } if (!bIsZipFile && !bUnzipped) { _tremove(theApp.ipfilter->GetDefaultFilePath()); _trename(szTempFilePath, theApp.ipfilter->GetDefaultFilePath()); } } OnReloadIPFilter(); }
void CPPgSecurity::OnLoadIPFFromURL() { bool bHaveNewFilterFile = false; CString url; GetDlgItemText(IDC_UPDATEURL,url); if (!url.IsEmpty()) { // add entered URL to LRU list even if it's not yet known whether we can download from this URL (it's just more convenient this way) if (m_pacIPFilterURL && m_pacIPFilterURL->IsBound()) m_pacIPFilterURL->AddItem(url, 0); CString strTempFilePath; _tmakepathlimit(strTempFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T("tmp")); strTempFilePath.ReleaseBuffer(); CHttpDownloadDlg dlgDownload; dlgDownload.m_strTitle = GetResString(IDS_DWL_IPFILTERFILE); dlgDownload.m_sURLToDownload = url; dlgDownload.m_sFileToDownloadInto = strTempFilePath; if (dlgDownload.DoModal() != IDOK) { (void)_tremove(strTempFilePath); CString strError = GetResString(IDS_DWLIPFILTERFAILED); if (!dlgDownload.GetError().IsEmpty()) strError += _T("\r\n\r\n") + dlgDownload.GetError(); AfxMessageBox(strError, MB_ICONERROR); return; } CString strMimeType; GetMimeType(strTempFilePath, strMimeType); bool bIsArchiveFile = false; bool bUncompressed = false; CZIPFile zip; if (zip.Open(strTempFilePath)) { bIsArchiveFile = true; CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile == NULL) zfile = zip.GetFile(_T("ipfilter.dat")); if (zfile) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) { zip.Close(); zfile = NULL; if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERCONTENTERR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } zip.Close(); } else if (strMimeType.CompareNoCase(_T("application/x-rar-compressed")) == 0) { bIsArchiveFile = true; CRARFile rar; if (rar.Open(strTempFilePath)) { CString strFile; if (rar.GetNextFile(strFile) && (strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0)) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (rar.Extract(strTempUnzipFilePath)) { rar.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } rar.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), url); AfxMessageBox(strError, MB_ICONERROR); } } else { CGZIPFile gz; if (gz.Open(strTempFilePath)) { bIsArchiveFile = true; CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) { gz.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } gz.Close(); } if (!bIsArchiveFile && !bUncompressed) { // Check first lines of downloaded file for potential HTML content (e.g. 404 error pages) bool bValidIPFilterFile = true; FILE* fp = _tfsopen(strTempFilePath, _T("rb"), _SH_DENYWR); if (fp) { char szBuff[16384]; int iRead = fread(szBuff, 1, _countof(szBuff)-1, fp); if (iRead <= 0) bValidIPFilterFile = false; else { szBuff[iRead-1] = '\0'; const char* pc = szBuff; while (*pc == ' ' || *pc == '\t' || *pc == '\r' || *pc == '\n') pc++; if (strnicmp(pc, "<html", 5) == 0 || strnicmp(pc, "<xml", 4) == 0 || strnicmp(pc, "<!doc", 5) == 0) { bValidIPFilterFile = false; } } fclose(fp); } if (bValidIPFilterFile) { (void)_tremove(theApp.ipfilter->GetDefaultFilePath()); VERIFY( _trename(strTempFilePath, theApp.ipfilter->GetDefaultFilePath()) == 0 ); bHaveNewFilterFile = true; } else { AfxMessageBox(GetResString(IDS_DWLIPFILTERFAILED), MB_ICONERROR); } } } if (url.IsEmpty() || bHaveNewFilterFile) OnReloadIPFilter(); // In case we received an invalid IP-filter file (e.g. an 404 HTML page with HTTP status "OK"), // warn the user that there are no IP-filters available any longer. if (bHaveNewFilterFile && theApp.ipfilter->GetIPFilter().GetCount() == 0) { CString strLoaded; strLoaded.Format(GetResString(IDS_IPFILTERLOADED), theApp.ipfilter->GetIPFilter().GetCount()); CString strError; strError.Format(_T("%s\r\n\r\n%s"), GetResString(IDS_DWLIPFILTERFAILED), strLoaded); AfxMessageBox(strError, MB_ICONERROR); } }
CUploadQueue::CUploadQueue() : waitinglist(100) { EMULE_TRY m_hTimer = SetTimer(NULL, 141, 100, TimerProc); if (!m_hTimer) AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T(__FUNCTION__) _T(": Fatal Error, failed to create Timer")); m_dwDataRate = 0; m_dwBannedCount = 0; g_iCounter = 0; // Extended Upload stats m_iULSessionSuccessful = 0; m_iULSessionSuccessfulFullChunk = 0; for (int i=0; i<ETS_TERMINATOR; i++) { m_iULSessionSuccessfulPartChunk[i] = 0; m_iULSessionFailed[i] = 0; } m_iULSessionFailedNoDataForRemoteClient = 0; m_iTotalUploadTime = 0; m_dwSumUpDataOverheadInDeque = 0; m_nUpDataRateMSOverhead = 0; m_nUpDataRateOverhead = 0; m_nUpDataOverheadSourceExchange = 0; m_nUpDataOverheadFileRequest = 0; m_nUpDataOverheadOther = 0; m_nUpDataOverheadServer = 0; m_nUpDataOverheadSourceExchangePackets = 0; m_nUpDataOverheadFileRequestPackets = 0; m_nUpDataOverheadOtherPackets = 0; m_nUpDataOverheadServerPackets = 0; m_iLeftOverBandwidth = 0; m_guessedMaxLANBandwidth = 3000; m_lastGaveDataTick = ::GetTickCount(); m_dwLastScheduledBackupTick = ::GetTickCount(); m_pSaveThread = NULL; // Create event responsible for thread termination m_hQuitEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); if (m_hQuitEvent) { // Create lower priority thread that will do the "job" m_pSaveThread = AfxBeginThread(SaveSourcesThread, reinterpret_cast<LPVOID>(this), THREAD_PRIORITY_BELOW_NORMAL + g_App.m_pPrefs->GetMainProcessPriority(), CREATE_SUSPENDED); if (m_pSaveThread != NULL) { // Disable self termination, because we plan to wait for thread termination m_pSaveThread->m_bAutoDelete = FALSE; m_pSaveThread->ResumeThread(); } else AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T("Error creating SourcesSaveThread")); } else { AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T("Error creating SourcesSaveThread")); } m_strUploadLogFilePath.Format(_T("%supload.log"), g_App.m_pPrefs->GetAppDir()); #if 1 //code left for smooth migration, delete in v1.3 if (GetTextFileFormat(m_strUploadLogFilePath) == tffANSI) { CString strBackupFile(m_strUploadLogFilePath); strBackupFile += _T(".ansi"); _tremove(strBackupFile); _trename(m_strUploadLogFilePath, strBackupFile); } #endif ::InitializeCriticalSection(&m_csUploadQueueList); EMULE_CATCH2 }
void CDLP::Reload() { CString fullpath = thePrefs.GetMuleDirectory(EMULE_MODULEDIR); dlpavailable=false; bool waserror=false; CString newdll = fullpath + _T("antiLeech.dll.new"); CString olddll = fullpath + _T("antiLeech.dll.old"); CString currentdll = fullpath + _T("antiLeech.dll"); BOOL bUpdateOK = FALSE; if(PathFileExists(newdll) && thePrefs.m_bUpdateAntiLeecher) { AddLogLine(false,GetResString(IDS_DLP_NEWVERSION)); //new version exists, try to unload the old and load the new one if(dlpInstance!=NULL) { ::FreeLibrary(dlpInstance); dlpInstance=NULL; } if(PathFileExists(currentdll)) { if(PathFileExists(olddll)) { if(_tremove(olddll)!=0) waserror=true; } if(waserror==false) if(_trename(currentdll,olddll)!=0) waserror=true; } if(waserror==false) { if(_trename(newdll,currentdll)!=0) waserror=true; } if(waserror) AddLogLine(false,GetResString(IDS_DLP_LOADOLD)); else bUpdateOK = TRUE; } if(dlpInstance==NULL) { dlpInstance=::LoadLibrary(currentdll); if(dlpInstance!=NULL) { //testfunc = (TESTFUNC)GetProcAddress(dlpInstance,("TestFunc")); GetDLPVersion = (GETDLPVERSION)GetProcAddress(dlpInstance,("GetDLPVersion")); DLPCheckModstring_Hard = (DLPCHECKMODSTRING_HARD)GetProcAddress(dlpInstance,("DLPCheckModstring_Hard")); DLPCheck_NonStandard = (DLPCHECK_NONSTANDARD)GetProcAddress(dlpInstance,("DLPCheck_NonStandard")); DLPCheckModstring_Soft = (DLPCHECKMODSTRING_SOFT)GetProcAddress(dlpInstance,("DLPCheckModstring_Soft")); DLPCheckUsername_Hard = (DLPCHECKUSERNAME_HARD)GetProcAddress(dlpInstance,("DLPCheckUsername_Hard")); DLPCheckUsername_Soft = (DLPCHECKUSERNAME_SOFT)GetProcAddress(dlpInstance,("DLPCheckUsername_Soft")); DLPCheckNameAndHashAndMod = (DLPCHECKNAMEANDHASHANDMOD)GetProcAddress(dlpInstance,("DLPCheckNameAndHashAndMod")); DLPCheckMessageSpam = (DLPCHECKMESSAGESPAM)GetProcAddress(dlpInstance,("DLPCheckMessageSpam")); DLPCheckUserhash = (DLPCHECKUSERHASH)GetProcAddress(dlpInstance,("DLPCheckUserhash")); DLPCheckHelloTag = (DLPCHECKHELLOTAG)GetProcAddress(dlpInstance,("DLPCheckHelloTag")); DLPCheckInfoTag = (DLPCHECKINFOTAG)GetProcAddress(dlpInstance,("DLPCheckInfoTag")); if( GetDLPVersion && DLPCheckModstring_Hard && DLPCheckModstring_Soft && DLPCheckUsername_Hard && DLPCheckUsername_Soft && DLPCheckNameAndHashAndMod && DLPCheckHelloTag && DLPCheckInfoTag && DLPCheckMessageSpam && DLPCheckUserhash ) { dlpavailable=true; AddLogLine(false,GetResString(IDS_DLP_DLLLOADED), GetDLPVersion()); if (theApp.emuledlg && bUpdateOK) { CString tcs; tcs.Format(GetResString(IDS_DLP_DLLLOADED),GetDLPVersion()); theApp.emuledlg->ShowNotifier(tcs,TBN_NULL); } } else { LogError(GetResString(IDS_DLP_LOADFAILED)); ::FreeLibrary(dlpInstance); dlpInstance=NULL; } } else { LogError(GetResString(IDS_DLP_LOADFAILED2)); LogError(GetResString(IDS_DLP_ERRORCODE), GetLastError()); } } else { AddDebugLogLine(false,GetResString(IDS_DLP_NO_NEWVER)); dlpavailable=true; } }
/* void CIPFilter::UpdateIPFilterURL() */ void CIPFilter::UpdateIPFilterURL(uint32 uNewVersion) // <== Advanced Updates [MorphXT/Stulle] - Stulle { bool bHaveNewFilterFile = false; CString url = thePrefs.GetAutoUpdateIPFilter_URL(); SYSTEMTIME SysTime; if (!url.IsEmpty()) { CString strTempFilePath; _tmakepathlimit(strTempFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T("tmp")); strTempFilePath.ReleaseBuffer(); CHttpDownloadDlg dlgDownload; dlgDownload.m_strTitle = GetResString(IDS_DWL_IPFILTERFILE); dlgDownload.m_sURLToDownload = url; dlgDownload.m_sFileToDownloadInto = strTempFilePath; if (PathFileExists(GetDefaultFilePath())) memcpy(&SysTime, &thePrefs.m_IPfilterVersion, sizeof(SYSTEMTIME)); else memset(&SysTime, 0, sizeof(SYSTEMTIME)); // ==> Advanced Updates [MorphXT/Stulle] - Stulle if(thePrefs.IsIPFilterViaDynDNS()) dlgDownload.m_pLastModifiedTime = NULL; else // <== Advanced Updates [MorphXT/Stulle] - Stulle dlgDownload.m_pLastModifiedTime = &SysTime; //Xman remark: m_pLastModifiedTime is a pointer which points to the SysTime-struct if (dlgDownload.DoModal() != IDOK) { (void)_tremove(strTempFilePath); CString strError = GetResString(IDS_DWLIPFILTERFAILED); if (!dlgDownload.GetError().IsEmpty()) strError += _T("\r\n\r\n") + dlgDownload.GetError(); AfxMessageBox(strError, MB_ICONERROR); return; } // ==> Advanced Updates [MorphXT/Stulle] - Stulle /* if (dlgDownload.m_pLastModifiedTime == NULL) */ if (thePrefs.IsIPFilterViaDynDNS() == false && dlgDownload.m_pLastModifiedTime == NULL) // <== Advanced Updates [MorphXT/Stulle] - Stulle return; CString strMimeType; GetMimeType(strTempFilePath, strMimeType); bool bIsArchiveFile = false; bool bUncompressed = false; CZIPFile zip; if (zip.Open(strTempFilePath)) { bIsArchiveFile = true; CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile == NULL) zfile = zip.GetFile(_T("ipfilter.dat")); if (zfile) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) { zip.Close(); zfile = NULL; if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %hs\n"), theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %hs\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %hs\n"), strTempFilePath, strerror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERCONTENTERR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } zip.Close(); } else if (strMimeType.CompareNoCase(_T("application/x-rar-compressed")) == 0) { bIsArchiveFile = true; CRARFile rar; if (rar.Open(strTempFilePath)) { CString strFile; if (rar.GetNextFile(strFile) && (strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0)) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (rar.Extract(strTempUnzipFilePath)) { rar.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %hs\n"), theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %hs\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %hs\n"), strTempFilePath, strerror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } rar.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), url); AfxMessageBox(strError, MB_ICONERROR); } } else { CGZIPFile gz; if (gz.Open(strTempFilePath)) { bIsArchiveFile = true; CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) { gz.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %hs\n"), theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %hs\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), strerror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %hs\n"), strTempFilePath, strerror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } gz.Close(); } if (!bIsArchiveFile && !bUncompressed) { // Check first lines of downloaded file for potential HTML content (e.g. 404 error pages) bool bValidIPFilterFile = true; FILE* fp = _tfsopen(strTempFilePath, _T("rb"), _SH_DENYWR); if (fp) { char szBuff[16384]; int iRead = fread(szBuff, 1, _countof(szBuff)-1, fp); if (iRead <= 0) bValidIPFilterFile = false; else { szBuff[iRead-1] = '\0'; const char* pc = szBuff; while (*pc == ' ' || *pc == '\t' || *pc == '\r' || *pc == '\n') pc++; if (strnicmp(pc, "<html", 5) == 0 || strnicmp(pc, "<xml", 4) == 0 || strnicmp(pc, "<!doc", 5) == 0) { bValidIPFilterFile = false; } } fclose(fp); } if (bValidIPFilterFile) { (void)_tremove(theApp.ipfilter->GetDefaultFilePath()); VERIFY( _trename(strTempFilePath, theApp.ipfilter->GetDefaultFilePath()) == 0 ); bHaveNewFilterFile = true; } else { AfxMessageBox(GetResString(IDS_DWLIPFILTERFAILED), MB_ICONERROR); } } } else { AfxMessageBox(_T("Failed to auto-update IPFilter. No URL given"), MB_ICONERROR); return; } // ==> Advanced Updates [MorphXT/Stulle] - Stulle /* struct tm tmTemp; thePrefs.m_last_ipfilter_check = safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp)); */ // <== Advanced Updates [MorphXT/Stulle] - Stulle if (bHaveNewFilterFile) { LoadFromDefaultFile(); if (thePrefs.GetFilterServerByIP()) theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers(); } // In case we received an invalid IP-filter file (e.g. an 404 HTML page with HTTP status "OK"), // warn the user that there are no IP-filters available any longer. if (bHaveNewFilterFile && theApp.ipfilter->GetIPFilter().GetCount() == 0) { CString strLoaded; strLoaded.Format(GetResString(IDS_IPFILTERLOADED), theApp.ipfilter->GetIPFilter().GetCount()); CString strError; strError.Format(_T("%s\r\n\r\n%s"), GetResString(IDS_DWLIPFILTERFAILED), strLoaded); AfxMessageBox(strError, MB_ICONERROR); return; } //everything fine. update the stored version if (bHaveNewFilterFile) // ==> Advanced Updates [MorphXT/Stulle] - Stulle /* memcpy(&thePrefs.m_IPfilterVersion, &SysTime, sizeof SysTime); */ { thePrefs.m_uIPFilterVersionNum = uNewVersion; if(thePrefs.IsIPFilterViaDynDNS()) { memset(&SysTime, 0, sizeof(SYSTEMTIME)); if(theApp.emuledlg->preferenceswnd && theApp.emuledlg->preferenceswnd->m_wndScar && theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime) { CString strBuffer = NULL; strBuffer.Format(_T("v%u"), thePrefs.GetIPFilterVersionNum()); theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime.SetWindowText(strBuffer); } } else memcpy(&thePrefs.m_IPfilterVersion, &SysTime, sizeof SysTime); } else { thePrefs.m_uIPFilterVersionNum = 0; memset(&SysTime, 0, sizeof(SYSTEMTIME)); if(thePrefs.IsIPFilterViaDynDNS()) { if(theApp.emuledlg->preferenceswnd && theApp.emuledlg->preferenceswnd->m_wndScar && theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime) theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime.SetWindowText(GetResString(IDS_DL_NONE)); } } if(thePrefs.IsIPFilterViaDynDNS() == false && theApp.emuledlg->preferenceswnd && theApp.emuledlg->preferenceswnd->m_wndScar && theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime) { TCHAR sTime[30]; sTime[0] = _T('\0'); SysTimeToStr(thePrefs.GetIPfilterVersion(), sTime); theApp.emuledlg->preferenceswnd->m_wndScar.m_IpFilterTime.SetWindowText(sTime); } // <== Advanced Updates [MorphXT/Stulle] - Stulle }
int ZipFunc::replaceOrig(const DZStrW &d, const DZStrW& s) { struct stati64 t; // results of stat() int copy = 0; int d_exists; d_exists = _tstati64(d, &t) == 0; if (d_exists) { // respect existing soft and hard links! if (t.st_nlink > 1) copy = 1; else { if (_tunlink(d)) return DZ_ERM_ERROR_CREATE; // Can't erase zip file--give up Sleep(5); } } if (!copy) { // Just move s on top of d if (_trename(s, d))// !MoveFile(s, d)) { if (Verbose < 0) Notify(IERROR, _T(" replace failed %s (%s)"), s, errno); copy = 1; // failed ? if (errno != ENOTSAM) return DZ_ERM_ERROR_CREATE; } } if (copy) { HANDLE f, g; // source and destination files int r; // temporary variable diag(_T("in replace - open for read")); if ((f = CreateFile(s, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)) <= 0) { diag(_T("in replace - bad open for Read")); Notify(0, _T(" replace: can't open %s [%s]"), s, SysMsg()); return DZ_ERM_TEMP_FAILED; } diag(_T("in replace - fopen for write")); if ((g = CreateFile(d, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)) <= 0) { Close_Handle(&f); diag(_T("in replace - bad open for Write")); return DZ_ERM_ERROR_CREATE; } r = filecopy(f, g); Close_Handle(&f); if (!Close_Handle(&g) || r != DZ_ERR_GOOD) { DeleteFile(d); return r ? (DZ_ERR(r) == DZ_ERR_TEMP_FAILED ? DZ_ERR_ERROR_WRITE : r) : DZ_ERM_ERROR_WRITE; } DeleteFile(s); } return DZ_ERR_GOOD; }
//-------------------------- GLOBAL FUNCTION ---------------------------------* int TrcPrint(WORD wLevel, LPCTSTR pszFormat, ...) /*>>>> print trace line with current time I wLevel: trace level I pszFormat: format string for wsprintf() Result E_TRC_OK E_TRC_NOT_INITIALIZED E_TRC_BAD_LEVEL E_TRC_NO_RESOURCE <<<<*/ { if (!s_bInitialized) { return E_TRC_NOT_INITIALIZED; } if (s_traceMode == noTrace) { // trace mode is disabled return E_TRC_OK; } if ((wLevel & s_wLevel) == 0) { // this level is not activated return E_TRC_OK; } if (pszFormat == NULL) { return E_TRC_NO_RESOURCE; } // print time and level... SYSTEMTIME tm; GetLocalTime(&tm); TCHAR szBuffer[512]; EnterCriticalSection(&s_csTrcFile); if (s_bNewLine) { // insert date and time if start of new line: if (s_wCurrDay != tm.wDay) { printTrc(_T("--------------------------------------------------------------\n")); _stprintf(szBuffer, _T("Current date: %s %04d-%02d-%02d\n"), GetDayOfWeek(tm.wDayOfWeek), (int) tm.wYear, (int) tm.wMonth, (int) tm.wDay); printTrc(szBuffer); s_wCurrDay = tm.wDay; } _stprintf(szBuffer, _T("%02d:%02d:%02d.%03d(%03d)|"), (int) tm.wHour, (int) tm.wMinute, (int) tm.wSecond, (int) tm.wMilliseconds, ::GetCurrentThreadId()); printTrc(szBuffer); printTrc(GetTrcLevelString(wLevel)); printTrc(_T("|")); s_bNewLine = FALSE; } // ... and actual message: va_list args; va_start(args, pszFormat); int nBuf; nBuf = _vstprintf(szBuffer, pszFormat, args); assert(nBuf < _countof(szBuffer)); va_end(args); printTrc(szBuffer); int len = _tcslen(szBuffer); if (len > 0) { if ( (szBuffer[len - 1] == _T('\n')) || (szBuffer[len - 1] == _T('\r'))) { s_bNewLine = TRUE; } } // check if max file size was reached: if ((s_hfTrc != NULL) && s_bNewLine && (s_uFileSize > 0)) { if ((UINT)(ftell(s_hfTrc) / 1000) > s_uFileSize) { fclose(s_hfTrc); _tremove(s_pszOldTrcFile); _trename(s_pszTraceFile, s_pszOldTrcFile); s_hfTrc = NULL; s_wCurrDay = 0; // force date line as first line in new file } } LeaveCriticalSection(&s_csTrcFile); return E_TRC_OK; }
BOOL CRenameComplete::OnSetActive() { // TODO: Add your specialized code here and/or call the base class CWnd *parent = GetParent (); if (parent->IsKindOf ( RUNTIME_CLASS( CPropertySheet )) ) { ((CPropertySheet*)parent)->SetWizardButtons (PSWIZB_FINISH); } if (m_fromList && m_toList) { m_comTrol.SetExtendedStyle (LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_FLATSB); m_comTrol.InsertColumn(0, "Renamed?", LVCFMT_LEFT, 80, 1); m_comTrol.InsertColumn(1, "From Files", LVCFMT_LEFT, 260, 2); m_comTrol.InsertColumn(2, "To Files", LVCFMT_LEFT, 260, 3); int i = 0; POSITION fromPos = m_fromList->GetHeadPosition (); POSITION toPos = m_toList->GetHeadPosition (); while (fromPos && toPos) { m_comTrol.InsertItem (i, (LPCTSTR) m_fromList->GetAt (fromPos)); m_comTrol.SetItemText (i, 0, _T("")); m_comTrol.SetItemText (i, 1, (LPCTSTR) m_fromList->GetAt (fromPos)); m_comTrol.SetItemText(i, 2, (LPCTSTR) m_toList->GetAt (toPos)); m_fromList->GetNext (fromPos); m_toList->GetNext (toPos); i++; } i = 0; CWaitCursor waitc; fromPos = m_fromList->GetHeadPosition (); toPos = m_toList->GetHeadPosition (); while (fromPos && toPos) { int rstat = _trename ((LPCTSTR) m_fromList->GetAt (fromPos), (LPCTSTR) m_toList->GetAt (toPos)); switch (rstat) { case 0: m_comTrol.SetItemText (i, 0, _T("X")); break; case EACCES : m_comTrol.SetItemText (i, 0, _T("AD")); break; case ENOENT : m_comTrol.SetItemText (i, 0, _T("NF")); break; case EINVAL: m_comTrol.SetItemText (i, 0, _T("IV")); break; default: m_comTrol.SetItemText (i, 0, _T("?")); break; } m_comTrol.RedrawWindow (); m_fromList->GetNext (fromPos); m_toList->GetNext (toPos); i++; } } if (parent->IsKindOf ( RUNTIME_CLASS( CPropertySheet )) ) { ((CPropertySheet*)parent)->SetFinishText ("All Done."); } CancelToClose (); return CPropertyPage::OnSetActive(); }