void CPolicyStore::ConstructPolicyListL() { // Using two policy lists (one for all and one for the visible // ones) makes it easy to support the concept of hidden and // visible policies. There's a slight memory penalty but this // is not serious as the number of policies is typically small). // Hidden policies differ from visible ones in only one aspect - // they are not included in the policy listing returned to // the caller. // A list of all policies (both visible and hidden) iPolicyListAll = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(2); // A list of visible policies only iPolicyListVisible = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(2); TFindFile fileFinder(iFs); CDir* fileList; TPath privateDir; User::LeaveIfError(iFs.PrivatePath(privateDir)); TInt ret = fileFinder.FindWildByDir(KPolFilePat, privateDir, fileList); if (ret == KErrNone) { CleanupStack::PushL(fileList); for (TInt i = 0; i < fileList->Count(); i++) { TParse fileNameParser; fileNameParser.Set((*fileList)[i].iName, &fileFinder.File(), NULL); TVpnPolicyId policyId; // Only add the policy to the list its ID length is // acceptable (this is the case with all policies // that have been properly imported to the store) if (fileNameParser.Name().Length() <= policyId.MaxLength()) { policyId.Copy(fileNameParser.Name()); HBufC* pinFile = iFileUtil.GetPinFileNameLC(policyId); if (iFileUtil.FileExists(*pinFile)) { AddPolicyL(policyId); } CleanupStack::PopAndDestroy(pinFile); } } CleanupStack::PopAndDestroy(); // fileList } }
TInt CFileEngine::DeleteFile(const TDesC& aPath) { TInt returnErr=0; CDir* dir; TInt err=iFs.GetDir(aPath,KEntryAttNormal|KEntryAttDir|KEntryAttHidden,ESortByDate,dir); if(err==KErrNone) { TInt tempInt = dir->Count(); for(TInt i = 0;i < tempInt;i++) { TEntry iEntry = (*dir)[i]; if(iEntry.IsDir()) { TInt iLength=iEntry.iName.Length(); if(iLength>0) { TFileName filePath; filePath.Append(aPath); filePath.Append(iEntry.iName); filePath.Append(_L("\\")); DeleteFile(filePath); } } else { TFileName filePath; filePath.Append(aPath); filePath.Append(iEntry.iName); returnErr=BaflUtils::DeleteFile(iFs,filePath); } } } else { returnErr=err; } if(dir) { delete dir; dir=NULL; } returnErr=iFs.RmDir(aPath); return returnErr; }
int DeviceManagementNode::getChildrenMaxCount() { int count = 0; RFs fileSession; RFile file; int cleanupStackSize = 0; StringBuffer fileSpecSb(currentDir); concatDirs(fileSpecSb, "*.*"); // TODO use utility function for string conversion TBuf8<DIM_MANAGEMENT_PATH> buf8((const unsigned char*)fileSpecSb.c_str()); HBufC* fileSpec = CnvUtfConverter::ConvertToUnicodeFromUtf8L(buf8); CleanupStack::PushL(fileSpec); ++cleanupStackSize; // // Connect to the file server // fileSession.Connect(); CleanupClosePushL(fileSession); ++cleanupStackSize; StringBuffer buf; // // Get the directories list, sorted by name // (Leave if an error occurs) // CDir* dirList; TRAPD(err, fileSession.GetDir(*fileSpec, KEntryAttDir|KEntryAttMatchExclusive, ESortByName, dirList)); if (err != KErrNone || dirList == NULL) { goto finally; } CleanupStack::PushL(dirList); ++cleanupStackSize; count = dirList->Count(); finally: // // Close the connection with the file server // and destroy dirList // fileSession.Close(); CleanupStack::PopAndDestroy(cleanupStackSize); return count; }
RArray<TFileName> ListImages::searchJPGL(TFileName tot, RFs fs, TFileName current) { RArray<TFileName> result; TInt i; TBuf<50> totalPath; TBuf<30> fileName; CDir* dirList; totalPath = tot; CleanupStack::PushL(dirList); if ((current.Length()) > 0) totalPath.Append(current); //CleanupClosePushL(result); TRAPD(err,fs.GetDir(totalPath, KEntryAttMaskSupported, ESortByDate, dirList)); CleanupStack::Pop(1); if (!dirList) return result; for (i = 0; i < dirList->Count(); i++) { if ((*dirList)[i].IsDir()) { TFileName tmp; tmp.Append((*dirList)[i].iName); tmp.Append(_L("\\")); RArray<TFileName> res = searchJPGL(totalPath, fs, tmp); for (int j = 0; j < res.Count(); j++) result.Append(res[j]); res.Reset(); } else { fileName = (*dirList)[i].iName; if (fileName.Find(_L(".jpg")) != KErrNotFound) { TBuf<50> tmp; tmp = totalPath; tmp.Append(fileName); result.Append(tmp); tmp.Delete(0, tmp.Length() - 1); } } } delete dirList; return result; }
void CDirectoryCache::AddFile(const std::string& strFile) { CSingleLock lock (m_cs); std::string strPath = URIUtils::GetDirectory(strFile); URIUtils::RemoveSlashAtEnd(strPath); ciCache i = m_cache.find(strPath); if (i != m_cache.end()) { CDir *dir = i->second; CFileItemPtr item(new CFileItem(strFile, false)); dir->m_Items->Add(item); dir->SetLastAccess(m_accessCounter); } }
void CDirectoryCache::AddFile(const std::string& strFile) { CSingleLock lock (m_cs); // Get rid of any URL options, else the compare may be wrong std::string strPath = URIUtils::GetDirectory(CURL(strFile).GetWithoutOptions()); URIUtils::RemoveSlashAtEnd(strPath); ciCache i = m_cache.find(strPath); if (i != m_cache.end()) { CDir *dir = i->second; CFileItemPtr item(new CFileItem(strFile, false)); dir->m_Items->Add(item); dir->SetLastAccess(m_accessCounter); } }
void CDirectoryCache::PrintStats() const { CSingleLock lock (m_cs); CLog::Log(LOGDEBUG, "%s - total of %u cache hits, and %u cache misses", __FUNCTION__, m_cacheHits, m_cacheMisses); // run through and find the oldest and the number of items cached unsigned int oldest = UINT_MAX; unsigned int numItems = 0; unsigned int numDirs = 0; for (ciCache i = m_cache.begin(); i != m_cache.end(); i++) { CDir *dir = i->second; oldest = min(oldest, dir->GetLastAccess()); numItems += dir->m_Items->Size(); numDirs++; } CLog::Log(LOGDEBUG, "%s - %u folders cached, with %u items total. Oldest is %u, current is %u", __FUNCTION__, numDirs, numItems, oldest, m_accessCounter); }
void PrintDiskUsage(RFs& aFs, const TDesC& aPath, TInt aOffset = 0) { _LIT(KSpace, " "); TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath); TFindFile findFile(aFs); CDir* fileNameCol = NULL; TBuf<8> fileNameMask; fileNameMask.Copy(_L("*.*")); TInt err = findFile.FindWildByDir(fileNameMask, aPath, fileNameCol); if(err == KErrNone) { do { const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case. (void)TheParse.Set(file, NULL, NULL); TPtrC driveName = TheParse.Drive(); if(aPath.FindF(driveName) >= 0) { TInt cnt = fileNameCol->Count(); for(TInt i=0;i<cnt;++i) { const ::TEntry& entry = (*fileNameCol)[i]; if(!entry.IsDir()) { TheTest.Printf(_L("%*.*S %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize); } else { TBuf<100> path; path.Copy(aPath); path.Append(entry.iName); path.Append(_L("\\")); PrintDiskUsage(aFs, path, aOffset + 4); } } } // if(aPath.FindF(driveName) >= 0) delete fileNameCol; fileNameCol = NULL; } while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files } else { TheTest.Printf(_L(" FindWildByDir() failed with err=%d\r\n"), err); } }
TInt CStorageManager::TotalIncFiles(CSBSIDTransferType* aTransferType) /** Returns number of Files in the directory for SID TransferType @param aTransferType - CSBSIDTransferType* pointer */ { __ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer)); CDir* dir = NULL; TFileName filename; GetSIDFileNameL(aTransferType, filename); TInt err = iTestStep->Fs().GetDir(filename, KEntryAttMaskSupported, ESortByName, dir); if (err != KErrNone) { return 0; } return dir->Count(); }
/** @SYMTestCaseID SYSLIB-FEATREG-CT-3471 @SYMTestCaseDesc List Config Files Names Under Featreg Data cage @SYMTestPriority High @SYMTestActions This test returns in a list format the names of all the featreg config files in its data cage. In order to validate EC114 Changes for FeatReg @SYMTestExpectedResults Names of featreg config files is returned. @SYMDEF DEF104374 */ static void OutputFileNameL() { TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3471 ")); _LIT(KFeatRegDir,"z:\\private\\102744CA\\*"); CDir* dirList; User::LeaveIfError(TheFs.GetDir(KFeatRegDir, KEntryAttMaskSupported,ESortByName,dirList)); RDebug::Print(_L("These are the files under z:\\private\\102744CA\\ ")); for (TInt i=0;i<dirList->Count();i++) { RDebug::Print(_L(" %S "), &(*dirList)[i].iName); } delete dirList; }
TBool XQAccessPointManagerPrivate::s60PlatformVersion(TUint& aMajor, TUint& aMinor) const { if (iPlatformVersionMajor != 0) { aMajor = iPlatformVersionMajor; aMinor = iPlatformVersionMinor; return ETrue; } RFs fs; if (fs.Connect() != KErrNone) { return EFalse; } CleanupClosePushL(fs); // Obtain the version number TFindFile fileFinder = fs; CDir* pResult; _LIT(KS60ProductIDFile, "Series60v*.sis"); _LIT(KROMInstallDir, "z:\\system\\install\\"); if (fileFinder.FindWildByDir(KS60ProductIDFile, KROMInstallDir, pResult) != KErrNone) { CleanupStack::PopAndDestroy(&fs); return EFalse; } CleanupStack::PushL(pResult); // Sort the file names so that the newest platforms are first if (pResult->Sort(ESortByName | EDescending) != KErrNone) { CleanupStack::PopAndDestroy(pResult); CleanupStack::PopAndDestroy(&fs); return EFalse; } // Parse the version numbers from the file name (e.g. Series60v3_1.sis) aMajor = (*pResult)[0].iName[9] - '0'; aMinor = (*pResult)[0].iName[11] - '0'; CleanupStack::PopAndDestroy(pResult); CleanupStack::PopAndDestroy(&fs); iPlatformVersionMajor = aMajor; iPlatformVersionMinor = aMinor; return ETrue; }
void CMemberAI::MemberAutoSynPos(bool bExtraMove) { CDummyAI* pDummyAI = GetGroupLeaderDummyAI(); if (!pDummyAI) return; CCharacterDictator* pDummyCharacter = pDummyAI->GetCharacter(); if (!pDummyCharacter) return; CFighterDictator* pDummyFighter = pDummyCharacter->GetFighter(); if(!pDummyFighter) return; CFPos destPos = GetSelfCorrectPos(); CFPos ownPos; GetCharacter()->GetPixelPos(ownPos); bool bWalkState = pDummyAI->m_bDefaultWalkState; float fSpeed = bWalkState ?pDummyFighter->m_WalkSpeed.Get(pDummyFighter) : pDummyFighter->m_RunSpeed.Get(pDummyFighter); if (ownPos.Dist(destPos)<eGridSpanForObj/2) { if (bExtraMove) pDummyAI->CheckMemberSynState(); else MoveToPixelInLinePath(destPos,fSpeed,bWalkState); return; } CVector2f vecf; vecf.x = destPos.x - ownPos.x; vecf.y = destPos.y - ownPos.y; CDir dir; dir.Set(vecf); dir.Get(vecf); if(bExtraMove) { float fLineDst = fSpeed*0.5f*eGridSpanForObj; destPos.x = destPos.x + fLineDst*vecf.x; destPos.y = destPos.y + fLineDst*vecf.y; } fSpeed += 0.3f; MoveToPixelInLinePath(destPos,fSpeed,bWalkState); }
// perform a full dir scan void CNotifyWatcher::FullDirectoryScanL(RArray<TEntry>& aArray) { aArray.Reset(); CDir* list; iFs.GetDir(gTestPath, KEntryAttMaskSupported, ESortByName, list); if (!list) return; CleanupStack::PushL(list); for (TInt i = 0; i < list->Count(); i++) { TEntry en ((*list)[i]); aArray.AppendL(en); } CleanupStack::PopAndDestroy(); }
void CMyServer::GetOsVersion(OsVersion& aVersion) { TFindFile fileFinder = iFs; CDir* result; _LIT(KS60ProductIDFile, "Series60v*.sis"); _LIT(KROMInstallDir, "z:\\system\\install\\"); User::LeaveIfError(fileFinder.FindWildByDir(KS60ProductIDFile, KROMInstallDir, result)); CleanupStack::PushL(result); // Sort the file names so that the newest platforms are first User::LeaveIfError(result->Sort(ESortByName | EDescending)); // Parse the version numbers from the file name (e.g. Series60v3_1.sis) aVersion.iMajor = (*result)[0].iName[9] - '0'; aVersion.iMinor = (*result)[0].iName[11] - '0'; CleanupStack::PopAndDestroy(result); }
// --------------------------------------------------------------------------- // Scan directory for files. // --------------------------------------------------------------------------- // void CAknsSrvActiveBackupDataClient::ScanDirectoryForSkinFilesL( const TDesC& aRootDir ) { AKNS_TRACE_DEBUG("CAknsSrvActiveBackupDataClient::ScanDirectoryForSkinFilesL" ); CDirScan *dirScan = CDirScan::NewLC( iFsSession ); dirScan->SetScanDataL( aRootDir, KEntryAttNormal | KEntryAttHidden | KEntryAttSystem | KEntryAttDir, ESortNone ); // Fetch all directories and files from root. CDir* entryList = NULL; TParse parse; for(;;) { TRAPD( err, dirScan->NextL( entryList ) ); // Stop in error case, or if no more data. if (!entryList || ( err != KErrNone) ) { break; } for (TInt i=0; i < entryList->Count(); i++) { TEntry entry = (*entryList)[i]; const TDesC& dir = dirScan->FullPath(); parse.Set( entry.iName, &dir, NULL ); if ( !entry.IsDir() ) { iFileArray.Append( parse ); } } delete entryList; } AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::ScanDirectoryForSkinFilesL noFiles=%d", iFileArray.Count() ); // Destroy the list. CleanupStack::PopAndDestroy( dirScan ); }
bool CTargetDirectionFX::RenderCallback( IEffectUnit* pUnit, CMatrix& matWorld, uint32 uCurTime, RenderObjStyle* pRORS ) { IEffectUnitProp* pProp = pUnit->GetProp(); if(/* !bAlphaBlend ||*/ !pUnit->IsInRenderTime() ) { return false; } CEntityClient* pEntity = CEntityClientManager::GetInst()->GetEntityByID( CEntityClientManager::GetInst()->GetDirectorID()); CFPos Pos = pEntity->GetPixelPos(); CVector2f vec2f(m_Pos.x-Pos.x,m_Pos.y-Pos.y); CDir dir; dir.Set(vec2f); float fRotate = dir.uDir* CMath::pi *2/256; CVector3f vec3f =matWorld.GetAxis(3); matWorld.SetRotateY(fRotate); matWorld._41 = vec3f.x; matWorld._42 = vec3f.y; matWorld._43 = vec3f.z; return true; }
void CMemDir::LoadDirL(const TDesC& aPath) // // Load a directory. // { TheLevel++; iPath=aPath.AllocL(); TFileName name=Name(_L("*.*")); test.Printf(_L("%*p%S\n"),TheLevel<<1,&name); CDir* pD; test(TheFs.GetDir(Name(_L("*.*")),KEntryAttMatchMask,EDirsFirst|ESortByName,pD)==KErrNone); TInt count=pD->Count(); TInt i=0; while (i<count) { const TEntry& e=(*pD)[i++]; TParse parse; parse.Set(e.iName,NULL,NULL); if (!parse.Ext().CompareF(_L(".NCB"))) continue; // Ignore .ncb files - cannot open/read them. CMemEntry* pE=CMemEntry::New(e); iEntryQ.AddLast(*pE); } delete pD; TDblQueIter<CMemEntry> q(iEntryQ); CMemEntry* pE; while ((pE=q++)!=NULL) { if (pE->IsDir()) { CMemDir* pM=CMemDir::NewL(); pE->SetDir(*pM); pM->LoadDirL(Name(pE->Name())); } else pE->SetDir(*this); } TheLevel--; }
// --------------------------------------------------------- // CFileBrowserEngine::GetResourceFilesL ( TFileName &aBasePath ) // The method get all files including files into subfolders. // --------------------------------------------------------- // void CFileBrowserEngine::GetResourceFilesL ( TFileName &aBasePath ) { CDir* dirs = 0; CDir* files = 0; if(! BaflUtils::PathExists(iFsSession, aBasePath)) { return; } // Get dir. KEntryAttNormal means that no hidden files or directories are included User::LeaveIfError(iFsSession.GetDir(aBasePath, KEntryAttNormal, ESortByName, files, dirs)); CleanupStack::PushL(dirs); CleanupStack::PushL(files); //get files in base path for( TInt i = 0; i < files->Count(); i++ ) { iFileList.Append( (*files)[i] ); iDirList.Append( aBasePath ); } //get subfolders for( TInt i = 0; i < dirs->Count(); i++ ) { // Exclude directories beginning with '_' as they can // contain system-generated thumbnails etc. if( (*dirs)[i].iName[0] != '_') { TFileName nextDir = aBasePath; nextDir.Append( (*dirs)[i].iName ); nextDir.Append( KSlash ); GetResourceFilesL( nextDir ); } } // Number 2 cannot be considered a "magic number" in this case, // and PopAndDestroy does get a parameter. Thus, the CSIs. CleanupStack::PopAndDestroy( 2, dirs ); // CSI: 47,12 # }
void CStorageManager::ReadDataOwnersFromDiskL(RDataOwnerArray& aArray) /** Reads Data Owners from a storage @param aArray - RDataOwnerArray will contain dataowners found in storage */ { aArray.ResetAndDestroy(); CDir* dir = NULL; TFileName filename = iBackupDirName; filename.Append(KDataOwnerDir); User::LeaveIfError(iTestStep->Fs().GetDir(filename, KEntryAttMaskSupported, ESortByName, dir)); TInt totalFiles = dir->Count(); for (TInt index = 0; index < totalFiles; index++) { TFileName file = filename; TEntry entry = (*dir)[index]; file.Append(entry.iName); HBufC8* data = HBufC8::NewLC(entry.iSize); TPtr8 pData = data->Des(); TBool ignore; TRAPD(err, ReadFromDiskL(file, pData, ignore)); if (err != KErrNone) { _LIT(KLog1, "Error opening file: "); iTestStep->LogWithText(LOG_LEVEL2, KLog1, file); CleanupStack::PopAndDestroy(data); continue; } CDataOwnerInfo* dataOwner = CDataOwnerInfo::NewL(pData); CleanupStack::PushL(dataOwner); aArray.AppendL(dataOwner); CleanupStack::Pop(dataOwner); CleanupStack::PopAndDestroy(data); } }
void CMapFileFinderBase::InternalFindFilesL() { if (!iFileList) { iFileList = new (ELeave) CDesCArrayFlat(5); } if (iDirList && iDirList->Count() > 0) { TPtrC path = iDirList->MdcaPoint(0); CDir* dir; TInt err = iFinder->FindWildByDir(*iNameAndExt, path, dir); if (path != KNullDesC && err == KErrNone) { while (err == KErrNone) { // We have found at least one match in path. class TParse parser; for(TInt i=0; i<dir->Count(); i++) { // Iterate through dir and check all matching files. parser.Set(dir->operator[](i).iName, &iFinder->File(), NULL); TPtrC path = parser.FullName(); if(CheckFile(path)) { // The file is a real map file, add it to // our list. iFileList->AppendL(path); } } DeleteAndNull(dir); err = iFinder->FindWild(dir); } } if (iFirstFile) { iFirstFile = EFalse; } iDIState = EMoveFiles; } else { // No more directories to search in, we are // finished. iDIState = EFindAndMoveFilesRequestCompleted; } CompleteRequest(KErrNone); }
LOCAL_C void ListDirs() // // List the directories and files on the disk, without DC (so we // find all of them), saving them in gDirList[] apart from // members of the System and Private ones. // { CDirScan* scanner = NULL; TInt r; TRAP(r, scanner = CDirScan::NewL(TheFs)); test_Value(r, r == KErrNone && scanner); TParse dirName; TheFs.Parse(_L("\\"),dirName); TRAP(r, scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName|EAscending)); test_KErrNone(r); CDir *entryList; test.Printf(_L("------ ALL DIRECTORIES ------\n")); for (;;) { scanner->NextL(entryList); if (entryList==NULL) break; TInt count=entryList->Count(); while (count--) { TEntry data=(*entryList)[count]; TBuf<KMaxFileName> path=scanner->AbbreviatedPath(); gDirList[gDirNum] = path; gDirList[gDirNum].Append(data.iName); test.Printf(_L(" %S\n"),&gDirList[gDirNum]); gDirNum++; } delete entryList; entryList=NULL; } delete scanner; }
void CTestUTCParse::ReadEmailL() { TInt counter=0; TInt numberOfFiles=0; TFileName name; TParse parsedFileName; parsedFileName.Set(KPath,NULL,NULL); CDir* rfcFileList; // Loads the any test files into an EntryList TInt error=iTestUtils->FileSession().GetDir(parsedFileName.FullName(), KEntryAttNormal, ESortByName, rfcFileList); if(!error) { numberOfFiles = rfcFileList->Count(); INFO_PRINTF2(_L("Number Of Files=%d 1\n"), numberOfFiles); if(numberOfFiles) { do { TFileName filename = (*rfcFileList)[counter].iName; TestReadL(parsedFileName.FullName(), filename); counter++; } while(counter<numberOfFiles); } else WARN_PRINTF1(_L("WARNING - There are no RFC files in test file source directory\n")); } else ERR_PRINTF2(TRefByValue<const TDesC>_L("\r\nFile error %d"), error); if(rfcFileList) { delete rfcFileList; } }
void CInArchive::CreateRefs(CDir &d) { if (!d.IsDir()) return; for (int i = 0; i < d._subItems.Size(); i++) { CRef ref; CDir &subItem = d._subItems[i]; subItem.Parent = &d; ref.Dir = &d; ref.Index = i; Refs.Add(ref); CreateRefs(subItem); } }
void CBlueWhaleSisReader::FindFileInSubDirsL(const TFileName& aDir) { CDir* dir = NULL; TFindFile findFile(iFs); CDirScan* dirScan = CDirScan::NewLC(iFs); dirScan->SetScanDataL(aDir, KEntryAttDir | KEntryAttNormal | KEntryAttMatchExclusive, ESortNone); TRAPD(err, dirScan->NextL(dir)); if (err == KErrNone) { while (dir) { CDir* subDir = NULL; if (findFile.FindWildByPath(KSisPattern, &dirScan->FullPath(), subDir) == KErrNone && subDir->Count()) { if (iDir == NULL) { iDir = subDir; } else { for (TInt i = 0; i < subDir->Count(); i++) { reinterpret_cast<CDirPlus*>(iDir)->AddL((*subDir)[i]); } delete subDir; } } delete dir; dir = NULL; dirScan->NextL(dir); } delete dir; dir = NULL; } CleanupStack::PopAndDestroy(dirScan); }
bool CLogMod::OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { CFile LogFile(m_sLogPath); CDir LogDir (LogFile.GetDir()); for(std::vector<CFile*>::iterator it = LogDir.begin(); it != LogDir.end(); ++it) { CTemplate& Row = Tmpl.AddRow("LogsLoop"); Row["File"] = (**it).GetShortName(); } if (WebSock.HasParam("file", false)) { CString path = CDir::CheckPathPrefix(GetSavePath(), LogFile.GetDir() + WebSock.GetParam("file", false)); if (path.empty()) { WebSock.PrintErrorPage("Invalid Path"); return true; } CFile DisplayFile(path); CString content; DisplayFile.Open(); int PageSize = 1024 * 1024; int Page = 0; if (WebSock.HasParam("page", false)) { Page = WebSock.GetParam("page", false).ToInt(); DisplayFile.Seek(Page * PageSize); } Tmpl["Prev"] = CString(Page - 1); Tmpl["Next"] = CString(Page + 1); Tmpl["Curr"] = WebSock.GetParam("file", false); DisplayFile.ReadFile(content, PageSize); DisplayFile.Close(); Tmpl["Log"] = content; } return true; }
void sUpdateCase(CDir& test_cases_dir, const string& test_name) { string input = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extInput); string output = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extOutput); string errors = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extErrors); if (!CFile(input).Exists()) { BOOST_FAIL("input file " << input << " does not exist."); } cerr << "Creating new test case from " << input << " ..." << endl; CErrorLogger logger(errors); CGvfReader reader(0); CNcbiIfstream ifstr(input.c_str()); typedef CGff2Reader::TAnnotList ANNOTS; ANNOTS annots; try { reader.ReadSeqAnnots(annots, ifstr, &logger); } catch (...) { ifstr.close(); BOOST_FAIL("Error: " << input << " failed during conversion."); } ifstr.close(); cerr << " Produced new error listing " << output << "." << endl; CNcbiOfstream ofstr(output.c_str()); for (ANNOTS::iterator cit = annots.begin(); cit != annots.end(); ++cit){ ofstr << MSerial_AsnText << **cit; ofstr.flush(); } ofstr.close(); cerr << " Produced new ASN1 file " << output << "." << endl; cerr << " ... Done." << endl; }
void sUpdateCase(CDir& test_cases_dir, const string& test_name) { string input = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extInput); string output = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extOutput); string errors = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extErrors); if (!CFile(input).Exists()) { BOOST_FAIL("input file " << input << " does not exist."); } string test_base, test_type; NStr::SplitInTwo(test_name, ".", test_base, test_type); cerr << "Creating new test case from " << input << " ..." << endl; CErrorLogger logger(errors); //get a scope CRef<CObjectManager> pObjMngr = CObjectManager::GetInstance(); CGBDataLoader::RegisterInObjectManager(*pObjMngr); CRef<CScope> pScope(new CScope(*pObjMngr)); pScope->AddDefaults(); //get a writer object CNcbiIfstream ifstr(input.c_str(), ios::binary); CObjectIStream* pI = CObjectIStream::Open(eSerial_AsnText, ifstr, eTakeOwnership); CNcbiOfstream ofstr(output.c_str()); CBedGraphWriter* pWriter = sGetWriter(*pScope, ofstr); if (test_type == "annot") { CRef<CSeq_annot> pAnnot(new CSeq_annot); *pI >> *pAnnot; pWriter->WriteHeader(); pWriter->WriteAnnot(*pAnnot); pWriter->WriteFooter(); delete pWriter; ofstr.flush(); }
bool CDirectoryCache::GetDirectory(const CStdString& strPath, CFileItemList &items, bool retrieveAll) { CSingleLock lock (m_cs); CStdString storedPath = URIUtils::SubstitutePath(strPath); URIUtils::RemoveSlashAtEnd(storedPath); ciCache i = m_cache.find(storedPath); if (i != m_cache.end()) { CDir* dir = i->second; if (dir->m_cacheType == XFILE::DIR_CACHE_ALWAYS || (dir->m_cacheType == XFILE::DIR_CACHE_ONCE && retrieveAll)) { items.Copy(*dir->m_Items); dir->SetLastAccess(m_accessCounter); #ifdef _DEBUG m_cacheHits+=items.Size(); #endif return true; } } return false; }
virtual void OnGetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) { if (bGlobal) { return; } CDir Dir; CModules::ModDirList dirs = CModules::GetModDirs(); while (!dirs.empty()) { set<CString> already; Dir.FillByWildcard(dirs.front().first, "*.py"); for (unsigned int a = 0; a < Dir.size(); a++) { CFile& File = *Dir[a]; CString sName = File.GetShortName(); CString sPath = File.GetLongName(); sPath.TrimSuffix(sName); sName.RightChomp(3); TryAddModInfo(sPath, sName, ssMods, already); } Dir.FillByWildcard(dirs.front().first, "*.pyc"); for (unsigned int a = 0; a < Dir.size(); a++) { CFile& File = *Dir[a]; CString sName = File.GetShortName(); CString sPath = File.GetLongName(); sPath.TrimSuffix(sName); sName.RightChomp(4); TryAddModInfo(sPath, sName, ssMods, already); } Dir.FillByWildcard(dirs.front().first, "*.so"); for (unsigned int a = 0; a < Dir.size(); a++) { CFile& File = *Dir[a]; CString sName = File.GetShortName(); CString sPath = File.GetLongName(); sPath.TrimSuffix(sName); sName.RightChomp(3); TryAddModInfo(sPath, sName, ssMods, already); } dirs.pop(); } }
bool CTAbleValApp::ProcessOneDirectory(const CDir& directory, const CMask& mask, bool recurse) { CDir::TEntries* e = directory.GetEntriesPtr("*", CDir::fCreateObjects | CDir::fIgnoreRecursive); auto_ptr<CDir::TEntries> entries(e); for (CDir::TEntries::const_iterator it = e->begin(); it != e->end(); it++) { // first process files and then recursivelly access other folders if (!(*it)->IsDir()) { if (mask.Match((*it)->GetPath())) { ProcessOneFile((*it)->GetPath()); } } else if (recurse) { ProcessOneDirectory(**it, mask, recurse); } } return true; }