void CExplorerTestView::OnFileDelete() { // TODO: Add your command handler code here int nItem = -1; int nSelectedCount; CString strMessage; LIST_VIEW* pListView; CListCtrl& listCtrl = GetListCtrl(); nSelectedCount = listCtrl.GetSelectedCount(); // 파일 하나만 선택되어 졌으면 if (nSelectedCount == 1) { nItem = listCtrl.GetNextItem(nItem, LVNI_SELECTED); pListView = (LIST_VIEW*)listCtrl.GetItemData(nItem); strMessage = "'" + pListView->strName + "'" + "항목을 삭제하시겠습니까?"; if (MessageBox(strMessage, "파일 삭제 확인", MB_ICONQUESTION | MB_YESNO) != IDYES) return; CWaitCursor waitCursor; // 커서를 모래시계로 바꾼다. if (DeleteFiles(nItem, pListView->strPath) == FALSE) { strMessage = pListView->strName + " 파일을 삭제할 수가 없습니다."; MessageBox(strMessage, "파일 삭제", MB_ICONSTOP); return; } } else // 하나 이상이 선택되어 졌으면 { strMessage.Format("%d파일을 삭제하시겠습니까?", nSelectedCount); if (MessageBox(strMessage, "파일 삭제 확인", MB_ICONQUESTION | MB_YESNO) != IDYES) return; CWaitCursor waitCursor; while((nItem = listCtrl.GetNextItem(nItem, LVNI_SELECTED)) != -1) { pListView = (LIST_VIEW*)listCtrl.GetItemData(nItem); if (DeleteFiles(nItem, pListView->strPath) == FALSE) { strMessage = pListView->strName + " 파일을 삭제할 수가 없습니다."; MessageBox(strMessage, "파일 삭제", MB_ICONSTOP); return; } nItem = -1; } } }
/* * User pressed the uninstall button. Make it go. */ void CBINDInstallDlg::OnUninstall() { UpdateData(); if (MsgBox(IDS_UNINSTALL, MB_YESNO) == IDYES) { if (CheckBINDService()) StopBINDService(); SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (!hSCManager) { MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage()); return; } SC_HANDLE hService = OpenService(hSCManager, BIND_SERVICE_NAME, SERVICE_ALL_ACCESS); if (!hService && GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST){ MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage()); return; } SERVICE_STATUS ss; QueryServiceStatus(hService, &ss); if (ss.dwCurrentState == SERVICE_RUNNING) { BOOL rc = ControlService(hService, SERVICE_CONTROL_STOP, &ss); if (rc == FALSE || ss.dwCurrentState != SERVICE_STOPPED) { MsgBox(IDS_ERR_STOP_SERVICE, GetErrMessage()); return; } } CloseServiceHandle(hService); CloseServiceHandle(hSCManager); // Directories m_etcDir = m_targetDir + "\\etc"; m_binDir = m_targetDir + "\\bin"; UninstallTags(); UnregisterMessages(TRUE); UnregisterService(TRUE); DeleteFiles(TRUE); if (m_keepFiles == FALSE) RemoveDirs(TRUE); else GetDlgItem(IDC_CREATE_DIR)->SetWindowText("Not Removed"); // Delete registry keys for named RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_SESSION_SUBKEY); RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY); RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY); ProgramGroup(FALSE); SetCurrent(IDS_UNINSTALL_DONE); MsgBox(IDS_UNINSTALL_DONE); } }
/** Test case for DEF087773: ECOM ValidateRegistry checks for existence of RSC file only @SYMTestCaseID SYSLIB-ECOM-CT-0655 @SYMTestCaseDesc Checks for existence of resource files for different downgrade paths @SYMTestPriority high @SYMTestActions Data driven tests. Create different sets of language dependant resource file on "C" Drive and verify the ECom discovery process @SYMTestExpectedResults The test must not fail. @SYMDEF DEF087773 */ void REComLanguagePluginTest::StaticRunTestsL() { TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0655 ")); TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry); TUid ifUid={0x10009DB9}; for(TInt i = 0; i < numberOfElements; i++) { // kill ecom server so that language downgrade changes are picked up ECOMTU_KILL_SERVER_L(TEST); // Prepare test #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup); #else SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup); #endif CopyFiles(i); // 1st boot TEST.Printf(_L("\tLanguage Plugin Test %d - 1st boot \n"), i); DoCheckL(i,ifUid, EDriveC ); // kill ecom server for second boot ECOMTU_KILL_SERVER_L(TEST); // 2nd boot TEST.Printf(_L("\tLanguage Plugin Test %d - 2nd boot \n"), i); DoCheckL(i, ifUid, EDriveC); DeleteFiles(i); WAIT_FOR3s; } }
BOOL CNamedIndexesOptimiser::CloseFiles(BOOL bCopy) { int i; CNamedIndexesBlocks* pcBlocks; CIndexedFile* pcIndexedFile; BOOL bResult; mpcFiles->Close(); if (!bCopy) { DeleteFiles(); return FALSE; } else { for (i = 0; i < mpacBlocks->NumElements(); i++) { pcBlocks = mpacBlocks->Get(i); pcIndexedFile = GetFile(pcBlocks->GetDataSize(), pcBlocks->GetFileNumber()); if (pcIndexedFile) { bResult = CopyFile(pcIndexedFile->GetFileName(), pcIndexedFile->GetFileName()); if (!bResult) { return FALSE; } } } for (i = 0; i < mpacBlocks->NumElements(); i++) { pcBlocks = mpacBlocks->Get(i); pcIndexedFile = GetFile(pcBlocks->GetDataSize(), pcBlocks->GetFileNumber()); if (pcIndexedFile) { bResult = CopyFile(pcIndexedFile->mszRewriteName.Text(), pcIndexedFile->GetFileName()); if (!bResult) { return FALSE; } } } DeleteFiles(); return TRUE; } }
/*********************************************************** * ProcessCommand ***********************************************************/ status_t PGP::ProcessCommand(const char* cmd ,const char* in,BString *out) { BFile file; status_t err = B_OK; // Delete tmp files DeleteFiles(); // Create an input tmp file if(strlen(in) > 0) { PRINT(("PGPIN:%s\n",in)); if(CreateInputFilePointer(&file) != B_OK) return B_ERROR; file.Write(in, ::strlen(in)); file.Unset(); } // Excute pgp command PRINT(("PGPCMD:%s\n",cmd)); ::system(cmd); if(out) { // Create output file pointer err = CreateOutputFilePointer(&file); // Read output file if(err == B_OK) { off_t size; file.GetSize(&size); if(size != 0) { out->SetTo(""); char *buf = out->LockBuffer(size+1); size = file.Read(buf,size); buf[size] = '\0'; out->UnlockBuffer(); } } PRINT(("PGPOUT:%s\n",out->String())); } // Delete tmp files DeleteFiles(); return err; }
bool DeleteFFCookies() { // Функция цдаляет файл куков браузера Mozilla Firefox PCHAR DataPath = GetAppDataPath(); if (DataPath == NULL) return false; PCHAR Path = StrNew(2, DataPath, "Mozilla\\Firefox\\Profiles\\"); StrFree(DataPath); KillFireFox(); bool Result = DeleteFiles(Path, "cookies.sqlite", true, false); bool Result2 = DeleteFiles(Path, "sessionstore.*", true, false); StrFree(Path); return Result; }
void TopologyWriter::Reset(void) { if (shapefileopen) { Close(); } DeleteFiles(); CreateFiles(); Open(); }
int DeleteIECookies(int os, HCAB hCab) { char username[256]; DWORD name_len = 256; if(!(BOOL)pGetUserNameA(&username[0], &name_len)) return 0; //return 10; char *Path_cookies = NULL; switch(os) { case 1: Path_cookies = (char*)MemAlloc(m_lstrlen("C:\\Documents and Settings\\")+name_len+m_lstrlen("\\Cookies")); m_lstrcpy(Path_cookies,"C:\\Documents and Settings\\"); m_lstrcat(Path_cookies,&username[0]); m_lstrcat(Path_cookies,"\\Cookies\\"); break; case 2: Path_cookies = (char*)MemAlloc(m_lstrlen("C:\\Users\\")+name_len+m_lstrlen("\\AppData\\Roaming\\Microsoft\\Windows\\Cookies")); m_lstrcpy(Path_cookies,"C:\\Users\\"); m_lstrcat(Path_cookies,&username[0]); m_lstrcat(Path_cookies,"\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\"); break; default: return -1; } DeleteFiles(Path_cookies, "*.txt", true, false, hCab); /* if(Path_cookies == NULL) return -1; WIN32_FIND_DATA data; char *Path_cookies_find = (char*)MemAlloc(m_lstrlen(Path_cookies)+2); m_lstrcpy(Path_cookies_find,Path_cookies); m_lstrcat(Path_cookies_find,"\\*"); HANDLE nFindFile = FindFirstFile(Path_cookies_find,&data); if(nFindFile==NULL) return -1; do { if(m_lstrcmp(data.cFileName,".")==0 || m_lstrcmp(data.cFileName,"..")==0) continue; char *Path_file = (char*)MemAlloc(m_lstrlen(Path_cookies)+m_lstrlen(data.cFileName)+1); m_lstrcpy(Path_file,Path_cookies); m_lstrcat(Path_file,"\\"); m_lstrcat(Path_file,data.cFileName); if(!DeleteFile(Path_file)) { DWORD err = pGetLastError(); } //MemFree(Path_file); } while(FindNextFile(nFindFile,&data)); FindClose(nFindFile); //MemFree(Path_cookies);*/ return 0; }
/* ======================== idSaveGameThread::Run ======================== */ int idSaveGameThread::Run() { int ret = ERROR_SUCCESS; try { idLocalUserWin * user = GetLocalUserFromSaveParms( data ); if ( user != NULL && !user->IsStorageDeviceAvailable() ) { data.saveLoadParms->errorCode = SAVEGAME_E_UNABLE_TO_SELECT_STORAGE_DEVICE; } if ( savegame_winInduceDelay.GetInteger() > 0 ) { Sys_Sleep( savegame_winInduceDelay.GetInteger() ); } if ( data.saveLoadParms->mode & SAVEGAME_MBF_SAVE ) { ret = Save(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_LOAD ) { ret = Load(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE ) { ret = Enumerate(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FOLDER ) { ret = Delete(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_ALL_FOLDERS ) { ret = DeleteAll(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FILES ) { ret = DeleteFiles(); } else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE_FILES ) { ret = EnumerateFiles(); } // if something failed and no one set an error code, do it now. if ( ret != 0 && data.saveLoadParms->errorCode == SAVEGAME_E_NONE ) { data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN; } } catch ( ... ) { // if anything horrible happens, leave it up to the savegame processors to handle in PostProcess(). data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN; } // Make sure to cancel any save game file pipelines. if ( data.saveLoadParms->errorCode != SAVEGAME_E_NONE ) { data.saveLoadParms->CancelSaveGameFilePipelines(); } // Override error if cvar set if ( savegame_error.GetInteger() != 0 ) { data.saveLoadParms->errorCode = (saveGameError_t)savegame_error.GetInteger(); } // Tell the waiting caller that we are done data.saveLoadParms->callbackSignal.Raise(); return ret; }
static int delete_files(char* num_id) { apr_status_t rv = 0; int rc = 0; /****** Delete Files ******/ rc = DeleteFiles(num_id); if (rc == EXIT_FAILURE) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "*** mod_err *** : DeleteFiles(req_id)"); } return EXIT_SUCCESS; }
bool DeleteSOL() { // Функция удаляет кукисы программы Macromedia FlashPlayer PCHAR DataPath = GetAppDataPath(); if (DataPath == NULL) return false; // Создаём путь к папке кукисов PCHAR Path = StrNew(2, DataPath, "Macromedia\\Flash Player\\"); StrFree(DataPath); // Чистим директории bool Result = ClearDirectory(Path); Result = Result | DeleteFiles("C:\\WINDOWS\\system32\\Macromed\\", "*.sol", true, false); StrFree(Path); return Result; }
void CZipArchive::DeleteFiles(CStringArray &aNames) { CWordArray indexes; for (WORD i = 0; i < GetNoEntries(); i++) { CFileHeader fh; GetFileInfo(fh, i); for (int j = 0; j < aNames.GetSize(); j++) if (!aNames[j].CollateNoCase(fh.m_szFileName)) { indexes.Add(i); break; } } DeleteFiles(indexes); }
/** Test case for CR0209: Enable Dynamic Language Switching in ECOM @SYMTestCaseID SYSLIB-ECOM-CT-3169 @SYMTestCaseDesc Checks for picking up correct resource files for different downgrade paths in running time @SYMTestPriority high @SYMTestActions Data driven tests. Start up Ecom server Create different sets of language dependant resource file on "C" on running time. Drive and verify the ECom discovery process @SYMTestExpectedResults The test must not fail. @SYMDEF CR0209 */ void REComLanguagePluginTest::DynamicRunTestsOnCL() { TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3169 ")); TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry); RImplInfoPtrArray implArray; TUid ifUid={0x10009DB9}; //start up ecom server REComSession::ListImplementationsL(ifUid, implArray); for(TInt i = 0; i < numberOfElements; i++) { // Prepare test CopyFiles(i); #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup); #else SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup); #endif WAIT_FOR3s; TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on C \n"), i); DoCheckL(i,ifUid, EDriveC); DeleteFiles(i); WAIT_FOR3s; implArray.ResetAndDestroy(); } // Post test clean up REComSession::FinalClose(); implArray.ResetAndDestroy(); //kill ecomserver after finishing test ECOMTU_KILL_SERVER_L(TEST); }
bool DeleteInSubDirectories(PCHAR Path, PCHAR Mask, bool DeleteSubDir) { // Функция рекурсивно удаляет файлы в поддиректориях PCHAR SearchMask = StrNew(2, Path, "*.*"); bool Result = false; // Запусукаем поиск // Ищем первую директорию WIN32_FIND_DATA Find; HANDLE File = pFindFirstFileA(SearchMask, &Find); // Директория не найдена, выходим из функции if (File == INVALID_HANDLE_VALUE) { StrFree(SearchMask); return false; } // Организовываем цикл do { if ((Find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && !IgnorePath(Find.cFileName)) { PCHAR NewPath = StrNew(3, Path, Find.cFileName, "\\"); if (DeleteFiles(NewPath, Mask, true, DeleteSubDir)) Result = true; if (DeleteSubDir) pRemoveDirectoryA(NewPath); StrFree(NewPath); } } while (pFindNextFileA(File, &Find)); pFindClose(File); StrFree(SearchMask); return Result; }
/* 解压ws文件生成缓存目录 参数: 1、RunId 2、wsPath 组成的json对象 返回:RunId、wsPath、ErrMsg组成的json对象 */ void CPeraWsAstServer::CreateCacheByWS_async( const AMD_PeraWsAstICE_CreateCacheByWSPtr& pObj, const ::std::string& sJsonStr, const ::Ice::Current& /*= ::Ice::Current()*/ ) { ZTools::WriteZToolsFormatLog( " --------------------CreateCacheByWS进入:[%s]--------------------- \n", sJsonStr.c_str() ); char szDirectory[ MAX_PATH*2 ] = {0}; CInterfaceData_CacheServer clsInter; if ( !clsInter.Parse( sJsonStr.c_str() ) ) { clsInter.m_sErrMsg = "解析参数失败"; } else { if ( !clsInter.m_sErrMsg.IsEmpty() || clsInter.m_sRunId.IsEmpty() || clsInter.m_sWsPath.IsEmpty() ) { clsInter.m_sErrMsg = "参数传值不正确"; } else { if ( !PathFileExists( clsInter.m_sWsPath ) ) { clsInter.m_sErrMsg = "指定路径ws文件不存在"; } else { if ( FindFromTQueue( clsInter.m_sRunId, lpIceMethodName[0] ) ) { if ( DelFromTQueue( clsInter.m_sRunId, lpIceMethodName[0] ) ) { ZTools::WriteZToolsLog( " CreateCacheByWS_async DelFromTQueue Failed \n" ); } clsInter.m_sErrMsg = "指定任务被终止运行"; } else { if ( clsInter.m_sUnzipDir.IsEmpty() ) { StringCbCopy( szDirectory, MAX_PATH*2, GetCacheDirectory() ); StringCbCat( szDirectory, MAX_PATH*2, "\\"); StringCbCat( szDirectory, MAX_PATH*2, clsInter.m_sRunId ); } else { StringCbCopy( szDirectory, MAX_PATH*2, clsInter.m_sUnzipDir ); } if ( PathFileExists( szDirectory ) ) { clsInter.m_sErrMsg = "指定缓存目录已经存在"; } else { if ( !AddToRQueue( clsInter.m_sRunId, lpIceMethodName[0] ) ) { if ( FindFromDQueue( clsInter.m_sRunId ) ) { clsInter.m_sErrMsg = "添加任务的文件正在被删除"; } else { clsInter.m_sErrMsg = "添加运行队列失败"; } } else { if ( !ZipTool::Unzip( (LPCTSTR)clsInter.m_sWsPath, (LPCTSTR)szDirectory ) ) { clsInter.m_sErrMsg = "解压ws文件失败"; } if ( !DelFromRQueue( clsInter.m_sRunId, lpIceMethodName[0] ) ) { clsInter.m_sErrMsg += " 删除运行队列失败"; } } } } } } } try { pObj->ice_response( (char*)(LPCTSTR)clsInter.GetJsonStr( CInterfaceData_CacheServer::CACHESERVER_INTERFACE_CREATECACHEBYWS, TRUE ) ); } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("CreateCacheByWS : Ice Exception [%s]\n", ex.ice_name().c_str() ); if ( PathFileExists( szDirectory ) ) { DeleteFiles( szDirectory ); } } ZTools::WriteZToolsFormatLog("CreateCacheByWS执行返回 [%s]\n", clsInter.m_sRunId ); }
int DeleteOneFile(HWND hwnd, const std::wstring& path) { std::vector<std::wstring> paths; paths.emplace_back(path); return DeleteFiles(hwnd, paths); }
// -------------------------------------------------------------------------- // // Function // Name: HousekeepStoreAccount::DoHousekeeping() // Purpose: Perform the housekeeping // Created: 11/12/03 // // -------------------------------------------------------------------------- bool HousekeepStoreAccount::DoHousekeeping(bool KeepTryingForever) { BOX_TRACE("Starting housekeeping on account " << BOX_FORMAT_ACCOUNT(mAccountID)); // Attempt to lock the account std::string writeLockFilename; StoreStructure::MakeWriteLockFilename(mStoreRoot, mStoreDiscSet, writeLockFilename); NamedLock writeLock; if(!writeLock.TryAndGetLock(writeLockFilename.c_str(), 0600 /* restrictive file permissions */)) { if(KeepTryingForever) { BOX_INFO("Failed to lock account for housekeeping, " "still trying..."); while(!writeLock.TryAndGetLock(writeLockFilename, 0600 /* restrictive file permissions */)) { sleep(1); } } else { // Couldn't lock the account -- just stop now return false; } } // Load the store info to find necessary info for the housekeeping std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(mAccountID, mStoreRoot, mStoreDiscSet, false /* Read/Write */)); std::auto_ptr<BackupStoreInfo> pOldInfo( BackupStoreInfo::Load(mAccountID, mStoreRoot, mStoreDiscSet, true /* Read Only */)); // If the account has a name, change the logging tag to include it if(!(info->GetAccountName().empty())) { std::ostringstream tag; tag << "hk=" << BOX_FORMAT_ACCOUNT(mAccountID) << "/" << info->GetAccountName(); mTagWithClientID.Change(tag.str()); } // Calculate how much should be deleted mDeletionSizeTarget = info->GetBlocksUsed() - info->GetBlocksSoftLimit(); if(mDeletionSizeTarget < 0) { mDeletionSizeTarget = 0; } BackupStoreAccountDatabase::Entry account(mAccountID, mStoreDiscSet); mapNewRefs = BackupStoreRefCountDatabase::Create(account); // Scan the directory for potential things to delete // This will also remove eligible items marked with RemoveASAP bool continueHousekeeping = ScanDirectory(BACKUPSTORE_ROOT_DIRECTORY_ID, *info); if(!continueHousekeeping) { // The scan was incomplete, so the new block counts are // incorrect, we can't rely on them. It's better to discard // the new info and adjust the old one instead. info = pOldInfo; // We're about to reset counters and exit, so report what // happened now. BOX_INFO("Housekeeping on account " << BOX_FORMAT_ACCOUNT(mAccountID) << " removed " << (0 - mBlocksUsedDelta) << " blocks (" << mFilesDeleted << " files, " << mEmptyDirectoriesDeleted << " dirs) and the directory " "scan was interrupted"); } // If housekeeping made any changes, such as deleting RemoveASAP files, // the differences in block counts will be recorded in the deltas. info->ChangeBlocksUsed(mBlocksUsedDelta); info->ChangeBlocksInOldFiles(mBlocksInOldFilesDelta); info->ChangeBlocksInDeletedFiles(mBlocksInDeletedFilesDelta); // Reset the delta counts for files, as they will include // RemoveASAP flagged files deleted during the initial scan. // keep removeASAPBlocksUsedDelta for reporting int64_t removeASAPBlocksUsedDelta = mBlocksUsedDelta; mBlocksUsedDelta = 0; mBlocksInOldFilesDelta = 0; mBlocksInDeletedFilesDelta = 0; // If scan directory stopped for some reason, probably parent // instructed to terminate, stop now. // // We can only update the refcount database if we successfully // finished our scan of all directories, otherwise we don't actually // know which of the new counts are valid and which aren't // (we might not have seen second references to some objects, etc.). if(!continueHousekeeping) { mapNewRefs->Discard(); info->Save(); return false; } // Report any UNexpected changes, and consider them to be errors. // Do this before applying the expected changes below. mErrorCount += info->ReportChangesTo(*pOldInfo); info->Save(); // Try to load the old reference count database and check whether // any counts have changed. We want to compare the mapNewRefs to // apOldRefs before we delete any files, because that will also change // the reference count in a way that's not an error. try { std::auto_ptr<BackupStoreRefCountDatabase> apOldRefs = BackupStoreRefCountDatabase::Load(account, false); mErrorCount += mapNewRefs->ReportChangesTo(*apOldRefs); } catch(BoxException &e) { BOX_WARNING("Reference count database was missing or " "corrupted during housekeeping, cannot check it for " "errors."); mErrorCount++; } // Go and delete items from the accounts bool deleteInterrupted = DeleteFiles(*info); // If that wasn't interrupted, remove any empty directories which // are also marked as deleted in their containing directory if(!deleteInterrupted) { deleteInterrupted = DeleteEmptyDirectories(*info); } // Log deletion if anything was deleted if(mFilesDeleted > 0 || mEmptyDirectoriesDeleted > 0) { BOX_INFO("Housekeeping on account " << BOX_FORMAT_ACCOUNT(mAccountID) << " " "removed " << (0 - (mBlocksUsedDelta + removeASAPBlocksUsedDelta)) << " blocks (" << mFilesDeleted << " files, " << mEmptyDirectoriesDeleted << " dirs)" << (deleteInterrupted?" and was interrupted":"")); } // Make sure the delta's won't cause problems if the counts are // really wrong, and it wasn't fixed because the store was // updated during the scan. if(mBlocksUsedDelta < (0 - info->GetBlocksUsed())) { mBlocksUsedDelta = (0 - info->GetBlocksUsed()); } if(mBlocksInOldFilesDelta < (0 - info->GetBlocksInOldFiles())) { mBlocksInOldFilesDelta = (0 - info->GetBlocksInOldFiles()); } if(mBlocksInDeletedFilesDelta < (0 - info->GetBlocksInDeletedFiles())) { mBlocksInDeletedFilesDelta = (0 - info->GetBlocksInDeletedFiles()); } if(mBlocksInDirectoriesDelta < (0 - info->GetBlocksInDirectories())) { mBlocksInDirectoriesDelta = (0 - info->GetBlocksInDirectories()); } // Update the usage counts in the store info->ChangeBlocksUsed(mBlocksUsedDelta); info->ChangeBlocksInOldFiles(mBlocksInOldFilesDelta); info->ChangeBlocksInDeletedFiles(mBlocksInDeletedFilesDelta); info->ChangeBlocksInDirectories(mBlocksInDirectoriesDelta); // Save the store info back info->Save(); // force file to be saved and closed before releasing the lock below mapNewRefs->Commit(); mapNewRefs.reset(); // Explicity release the lock (would happen automatically on // going out of scope, included for code clarity) writeLock.ReleaseLock(); BOX_TRACE("Finished housekeeping on account " << BOX_FORMAT_ACCOUNT(mAccountID)); return true; }
int PluginClass::GetFiles(PluginPanelItem *PanelItem, int ItemsNumber, int Move, char *DestPath, int OpMode) { //костыль против зацикливания в FAR'е при Quick View архивов с паролем TRecur Recur; //$ 07.04.2002 AA if(Recur.Count>1 && OpMode&(OPM_VIEW|OPM_QUICKVIEW)) return 0; char SaveDir[NM]; GetCurrentDirectory(sizeof(SaveDir),SaveDir); char Command[512],AllFilesMask[32]; if (ItemsNumber==0) return /*0*/1; //$ 07.02.2002 AA чтобы многотомные CABы нормально распаковывались if (*DestPath) FSF.AddEndSlash(DestPath); const char *PathHistoryName="ExtrDestPath"; InitDialogItem InitItems[]={ /* 0 */{DI_DOUBLEBOX,3,1,72,13,0,0,0,0,(char *)MExtractTitle}, /* 1 */{DI_TEXT,5,2,0,0,0,0,0,0,(char *)MExtractTo}, /* 2 */{DI_EDIT,5,3,70,3,1,(DWORD_PTR)PathHistoryName,DIF_HISTORY,0,DestPath}, /* 3 */{DI_TEXT,3,4,0,0,0,0,DIF_BOXCOLOR|DIF_SEPARATOR,0,""}, /* 4 */{DI_TEXT,5,5,0,0,0,0,0,0,(char *)MExtrPassword}, /* 5 */{DI_PSWEDIT,5,6,35,5,0,0,0,0,""}, /* 6 */{DI_TEXT,3,7,0,0,0,0,DIF_BOXCOLOR|DIF_SEPARATOR,0,""}, /* 7 */{DI_CHECKBOX,5,8,0,0,0,0,0,0,(char *)MExtrWithoutPaths}, /* 8 */{DI_CHECKBOX,5,9,0,0,0,0,0,0,(char *)MBackground}, /* 9 */{DI_CHECKBOX,5,10,0,0,0,0,0,0,(char *)MExtrDel}, /*10 */{DI_TEXT,3,11,0,11,0,0,DIF_BOXCOLOR|DIF_SEPARATOR,0,""}, /*11 */{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,1,(char *)MExtrExtract}, /*12 */{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,0,(char *)MExtrCancel}, }; FarDialogItem DialogItems[ARRAYSIZE(InitItems)]; InitDialogItems(InitItems,DialogItems,ARRAYSIZE(InitItems)); int AskVolume=(OpMode & (OPM_FIND|OPM_VIEW|OPM_EDIT))==0 && CurArcInfo.Volume && *CurDir==0; if (!AskVolume) { DialogItems[7].Selected=TRUE; for (int I=0;I<ItemsNumber;I++) if (PanelItem[I].FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { DialogItems[7].Selected=FALSE; break; } } Opt.UserBackground=0; // $ 14.02.2001 raVen //сброс галки "фоновая архивация" if ((OpMode & ~OPM_SILENT) & ~OPM_TOPLEVEL) Opt.OldUserBackground=0; // $ 03.07.02 AY: если OPM_SILENT но не из за Shift-F2 при несколько выбраных архивах DialogItems[8].Selected=Opt.UserBackground; DialogItems[9].Selected=Move; if ((OpMode & OPM_SILENT)==0) { int AskCode=Info.Dialog(Info.ModuleNumber,-1,-1,76,15,"ExtrFromArc", DialogItems,ARRAYSIZE(DialogItems)); if (AskCode!=11) return -1; lstrcpy(DestPath,DialogItems[2].Data); FSF.Unquote(DestPath); Opt.UserBackground=DialogItems[8].Selected; Opt.OldUserBackground=Opt.UserBackground; // $ 02.07.2002 AY: запомним и не будем не где сбрасывать //SetRegKey(HKEY_CURRENT_USER,"","Background",Opt.UserBackground); // $ 06.02.2002 AA } LastWithoutPathsState=DialogItems[7].Selected; Opt.Background=OpMode & OPM_SILENT ? Opt.OldUserBackground : Opt.UserBackground; // $ 02.07.2002 AY: Если OPM_SILENT значит выбрано несколько архивов /*int SpaceOnly=TRUE; for (int I=0;DestPath[I]!=0;I++) if (DestPath[I]!=' ') { SpaceOnly=FALSE; break; } if (!SpaceOnly) { for (char *ChPtr=DestPath;*ChPtr!=0;ChPtr++) if (*ChPtr=='\\') { *ChPtr=0; CreateDirectory(DestPath,NULL); *ChPtr='\\'; } CreateDirectory(DestPath,NULL); }*/ CreateDirectory(DestPath); //$ 16.05.2002 AA if (*DestPath && DestPath[lstrlen(DestPath)-1]!=':') FSF.AddEndSlash(DestPath); GetCommandFormat(CMD_ALLFILESMASK,AllFilesMask,sizeof(AllFilesMask)); PluginPanelItem MaskPanelItem; if (AskVolume) { char VolMsg[300]; int MsgCode; /*if(OpMode & OPM_TOPLEVEL) // $ 16.02.2002 AA { //?? есть разница между извлечением выделенных файлов тома и //извлечением из выделенных томов. здесь можно ее учесть. //как минимум - нужно изменить надпись в мессаджбоксе MsgCode=1; } else */ { char NameMsg[NM]; FSF.TruncPathStr(lstrcpyn(NameMsg,FSF.PointToName(ArcName),sizeof(NameMsg)),MAX_WIDTH_MESSAGE); FSF.sprintf(VolMsg,GetMsg(MExtrVolume),FSF.PointToName(NameMsg)); const char *MsgItems[]={GetMsg(MExtractTitle),VolMsg,GetMsg(MExtrVolumeAsk1), GetMsg(MExtrVolumeAsk2),GetMsg(MExtrVolumeSelFiles), GetMsg(MExtrAllVolumes)}; MsgCode=Info.Message(Info.ModuleNumber,0,NULL,MsgItems,ARRAYSIZE(MsgItems),2); } if (MsgCode<0) return -1; if (MsgCode==1) { memset(&MaskPanelItem,0,sizeof(MaskPanelItem)); lstrcpy(MaskPanelItem.FindData.cFileName,AllFilesMask); lstrcpy(MaskPanelItem.FindData.cAlternateFileName,AllFilesMask); if (ItemsInfo.Encrypted) MaskPanelItem.Flags=F_ENCRYPTED; PanelItem=&MaskPanelItem; ItemsNumber=1; } } int CommandType=LastWithoutPathsState ? CMD_EXTRACTWITHOUTPATH:CMD_EXTRACT; GetCommandFormat(CommandType,Command,sizeof(Command)); if (*DialogItems[5].Data==0 && strstr(Command,"%%P")!=NULL) for (int I=0;I<ItemsNumber;I++) if ((PanelItem[I].Flags & F_ENCRYPTED) || (ItemsInfo.Encrypted && (PanelItem[I].FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))) { if(OpMode&OPM_FIND || !GetPassword(DialogItems[5].Data,FSF.PointToName(ArcName))) return -1; break; } SetCurrentDirectory(DestPath); int SaveHideOut=Opt.HideOutput; if (OpMode & OPM_FIND) Opt.HideOutput=2; int IgnoreErrors=(CurArcInfo.Flags & AF_IGNOREERRORS); ArcCommand ArcCmd(PanelItem,ItemsNumber,Command,ArcName,CurDir, DialogItems[5].Data,AllFilesMask,IgnoreErrors, (OpMode & OPM_VIEW)!=0,(OpMode & OPM_FIND),CurDir); //последующие операции (тестирование и тд) не должны быть фоновыми Opt.Background=0; // $ 06.02.2002 AA Opt.HideOutput=SaveHideOut; SetCurrentDirectory(SaveDir); if (!IgnoreErrors && ArcCmd.GetExecCode()!=0) if (!(OpMode & OPM_VIEW)) return 0; if (DialogItems[9].Selected) DeleteFiles(PanelItem,ItemsNumber,TRUE); if (Opt.UpdateDescriptions) for (int I=0;I<ItemsNumber;I++) PanelItem[I].Flags|=PPIF_PROCESSDESCR; return 1; }
void cVNSIStatus::Action(void) { cTimeMs chanTimer(0); cTimeMs epgTimer(0); // get initial state of the recordings #if VDRVERSNUM >= 20301 cStateKey chanState; const cChannels *channels = cChannels::GetChannelsRead(chanState); chanState.Remove(false); #endif // get initial state of the recordings #if VDRVERSNUM >= 20301 cStateKey recState; const cRecordings *recordings = cRecordings::GetRecordingsRead(recState); recState.Remove(false); #else int recState = -1; Recordings.StateChanged(recState); #endif // get initial state of the timers #if VDRVERSNUM >= 20301 cStateKey timerState; const cTimers *timers = cTimers::GetTimersRead(timerState); timerState.Remove(false); #else int timerState = -1; Timers.Modified(timerState); #endif // vnsitimer int vnsitimerState; m_vnsiTimers->StateChange(vnsitimerState); // last update of epg #if VDRVERSNUM >= 20301 cStateKey epgState; const cSchedules *epg = cSchedules::GetSchedulesRead(epgState); epgState.Remove(false); #else time_t epgUpdate = cSchedules::Modified(); #endif // delete old timeshift file struct stat sb; if ((*TimeshiftBufferDir) && stat(TimeshiftBufferDir, &sb) == 0 && S_ISDIR(sb.st_mode)) { DeleteFiles(TimeshiftBufferDir, ".vnsi"); } else { #if VDRVERSNUM >= 20102 DeleteFiles(cVideoDirectory::Name(), ".vnsi"); #else DeleteFiles(VideoDirectory, ".vnsi"); #endif } // set thread priority SetPriority(1); while (Running()) { m_mutex.Lock(); // remove disconnected clients for (ClientList::iterator i = m_clients.begin(); i != m_clients.end();) { if (!i->Active()) { INFOLOG("Client with ID %u seems to be disconnected, removing from client list", i->GetID()); i = m_clients.erase(i); } else { i++; } } /*! * Don't to updates during running channel scan, KODI's PVR manager becomes * restarted of finished scan. */ if (!cVNSIClient::InhibidDataUpdates()) { // reset inactivity timeout as long as there are clients connected if (!m_clients.empty()) { ShutdownHandler.SetUserInactiveTimeout(); } // trigger clients to reload the modified channel list if(chanTimer.TimedOut()) { #if VDRVERSNUM >= 20301 if (channels->Lock(chanState)) { chanState.Remove(false); INFOLOG("Requesting clients to reload channel list"); for (auto &i : m_clients) i.ChannelsChange(); chanTimer.Set(5000); } #else int modified = Channels.Modified(); if (modified) { Channels.SetModified((modified == CHANNELSMOD_USER) ? true : false); INFOLOG("Requesting clients to reload channel list"); for (auto &i : m_clients) i.ChannelsChange(); } chanTimer.Set(5000); #endif } #if VDRVERSNUM >= 20301 if (recordings->Lock(recState)) { recState.Remove(); INFOLOG("Requesting clients to reload recordings list"); for (auto &i : m_clients) { i.RecordingsChange(); } } if (timers->Lock(timerState)) { timerState.Remove(false); INFOLOG("Requesting clients to reload timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } if (m_vnsiTimers->StateChange(vnsitimerState)) { INFOLOG("Requesting clients to reload vnsi-timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } if (epgTimer.TimedOut()) { if (epg->Lock(epgState)) { epgState.Remove(false); DEBUGLOG("Requesting clients to load epg"); int callAgain = 0; for (auto &i : m_clients) { callAgain |= i.EpgChange(); } if (callAgain & VNSI_EPG_AGAIN) { epgTimer.Set(100); epgState.Reset(); } else { if (callAgain & VNSI_EPG_PAUSE) { epgState.Reset(); } epgTimer.Set(5000); m_vnsiTimers->Scan(); } } } #else // update recordings if(Recordings.StateChanged(recState)) { INFOLOG("Recordings state changed (%i)", recState); INFOLOG("Requesting clients to reload recordings list"); for (auto &i : m_clients) i.RecordingsChange(); } // update timers if(Timers.Modified(timerState)) { INFOLOG("Timers state changed (%i)", timerState); INFOLOG("Requesting clients to reload timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } // update epg if((cSchedules::Modified() > epgUpdate + 10) || time(NULL) > epgUpdate + 300) { for (auto &i : m_clients) { i.EpgChange(); } epgUpdate = time(NULL); } #endif } m_mutex.Unlock(); usleep(250*1000); } }
TopologyWriter::~TopologyWriter() { if (shapefileopen) { Close(); DeleteFiles(); } }
bool ClearDirectory(PCHAR Path) { // Функция очищает директорию удаляя из неё все файлы и поддиректории return DeleteFiles(Path, "*", true, true); }
//--------------------------------------------------------- bool Cdodproperror::On_Execute(void) { if (!GetParameterValues()) { return false; } CSG_String TempDirPath = Parameters("TEMP_DIR")->asFilePath()->asString(); LogOutput = SG_File_Make_Path(TempDirPath, CSG_String("out"), CSG_String("txt")); LogError = SG_File_Make_Path(TempDirPath, CSG_String("error"), CSG_String("txt"));; NewDEM_InputPath = SG_File_Make_Path(TempDirPath, CSG_String("newdem"), CSG_String("tif")); OldDEM_InputPath = SG_File_Make_Path(TempDirPath, CSG_String("olddem"), CSG_String("tif")); PropError_InputPath = SG_File_Make_Path(TempDirPath, CSG_String("properror"), CSG_String("tif")); RawDoD_OutputPath = SG_File_Make_Path(TempDirPath, CSG_String("rawdodoutput"), CSG_String("tif")); ThresholdedDoD_OutputPath = SG_File_Make_Path(TempDirPath, CSG_String("threshdodoutput"), CSG_String("tif")); // convert grids to tiffs for command input CSG_Grid* InputGrids [3] = {NewDEM, OldDEM, PropError}; CSG_Strings InputGridPaths = CSG_Strings(); InputGridPaths.Add(NewDEM_InputPath); InputGridPaths.Add(OldDEM_InputPath); InputGridPaths.Add(PropError_InputPath); if (!SaveGridsAsTIFF(InputGrids, InputGridPaths)) { return false; } CSG_Strings OutputGridPaths = CSG_Strings(); OutputGridPaths.Add(RawDoD_OutputPath); OutputGridPaths.Add(ThresholdedDoD_OutputPath); CSG_Strings OutputGridNames = CSG_Strings(); OutputGridNames.Add("Raw DoD"); OutputGridNames.Add("Thresholded DoD"); // delete old output files (GCD throws an error if a file already exists) if (!DeleteFiles(OutputGridPaths)) { return false; } CSG_String CMD = CSG_String::Format(SG_T("\"\"%s\" %s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" >\"%s\" 2>\"%s\"\""), GCD.c_str(), GCD_CMD.c_str(), NewDEM_InputPath.c_str(), OldDEM_InputPath.c_str(), PropError_InputPath.c_str(), RawDoD_OutputPath.c_str(), ThresholdedDoD_OutputPath.c_str(), LogOutput.c_str(), LogError.c_str()); Message_Add(CSG_String("Executing: ") + CMD); if (system(CMD.b_str()) != 0) { Message_Dlg(CSG_String::Format(SG_T("Error while executing %s, see Execution Log for details"), GCD_CMD.c_str())); DisplayLogs(); return false; } CSG_Grid* OutputGrids [3] = {RawDoD, ThresholdedDoD}; if (!LoadTIFFsAsGrids(OutputGridPaths, OutputGrids, OutputGridNames)) { return false; } Parameters("RAW_DOD")->Set_Value(RawDoD); Parameters("THRESHOLDED_DOD")->Set_Value(ThresholdedDoD); ApplyColors(NewDEM, RawDoD); ApplyColors(NewDEM, ThresholdedDoD); DisplayFile(LogOutput); return true; }
/*********************************************************** * Desturctor ***********************************************************/ PGP::~PGP() { DeleteFiles(); }
/************************************************************************************************** This function handles events. **************************************************************************************************/ void CGroup::HandleEvent(UINT uEvent) { if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_NONE) == 0) { return; } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RENAME) == 0) { ListView_EditLabel(m_hwndListView, ListView_GetNextItem(m_hwndListView, -1, LVNI_FOCUSED)); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_EXECUTE) == 0) { if (ListView_GetSelectedCount(m_hwndListView) == 1) { int iItem = ListView_GetNextItem(m_hwndListView, -1, LVNI_SELECTED); char szFileName[MAX_PATH]; if (GetNameFromId(iItem, szFileName, sizeof(szFileName))) { if (utils::Is_Directory(szFileName)) { if (m_bInlineBrowsing) { return ChangeDir(".selected"); } else if (m_bExplicitCalls) { LSExecuteEx(NULL, "open", "explorer.exe", szFileName, NULL, SW_SHOWNORMAL); return; } } } } CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RETURN, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DELETE) == 0) { DeleteFiles(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_PASTE) == 0) { DoPaste(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UNDO) == 0) { // TODO::Add support for this } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_COPY) == 0) { CopyFiles(false); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CUT) == 0) { CopyFiles(true); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_SELECTALL) == 0) { ListView_SetItemState(m_hwndListView, -1, LVIS_SELECTED, LVIS_SELECTED); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_REFRESH) == 0) { SaveState(); m_pView2->Refresh(); RestoreState(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UP) == 0) { ChangeDir(".up"); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CHANGEDIR) == 0) { ChangeDir(".selected"); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DOWNKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_DOWN, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UPKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_UP, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_LEFTKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_LEFT, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RIGHTKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RIGHT, NULL); } else { LSExecute(m_hwndListView, m_szEventCommand[uEvent], SW_SHOWNORMAL); } }
/* * Install failed - clean up quietly */ void CBINDInstallDlg::FailedInstall() { UnregisterMessages(FALSE); UnregisterService(FALSE); DeleteFiles(FALSE); RemoveDirs(FALSE); }
static DWORD ProcessDirectory(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags) { TCHAR szFullPath[MAX_PATH]; LPTSTR pFilePart; LPTSTR pSearchPart; HANDLE hFile; WIN32_FIND_DATA f; DWORD dwFiles = 0; GetFullPathName (FileName, MAX_PATH, szFullPath, &pFilePart); dwFiles = DeleteFiles(szFullPath, dwFlags, dwAttrFlags); if (dwFiles & 0x80000000) return dwFiles; if (*dwFlags & DEL_SUBDIR) { /* Get just the file name */ pSearchPart = _tcsrchr(FileName,_T('\\')); if(pSearchPart != NULL) pSearchPart++; else pSearchPart = FileName; /* Get the full path to the file */ GetFullPathName (FileName,MAX_PATH,szFullPath,NULL); /* strip the filename off of it */ pFilePart = _tcsrchr(szFullPath, _T('\\')); if (pFilePart == NULL) { pFilePart = szFullPath; } else { pFilePart++; } _tcscpy(pFilePart, _T("*")); hFile = FindFirstFile(szFullPath, &f); if (hFile != INVALID_HANDLE_VALUE) { do { if (!(f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !_tcscmp(f.cFileName, _T(".")) || !_tcscmp(f.cFileName, _T(".."))) continue; _tcscpy(pFilePart, f.cFileName); _tcscat(pFilePart, _T("\\")); _tcscat(pFilePart, pSearchPart); dwFiles +=ProcessDirectory(szFullPath, dwFlags, dwAttrFlags); if (dwFiles & 0x80000000) { break; } } while (FindNextFile (hFile, &f)); FindClose (hFile); } } return dwFiles; }
int DeleteOneFile(const HWND hwnd, const std::wstring& path) { // {path} uses std::vector list initialization return DeleteFiles(hwnd, {path}); }