// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::LoadClientsL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpDownloadManagerServerEngine::LoadClientsL()
    {
    LOGGER_ENTERFN( "LoadClientsL" );

    CDir* dirs = 0;
    // hidden + system + dir + only these
    TUint mask = KEntryAttMatchMask | KEntryAttMatchExclusive; 

    User::LeaveIfError( iRfs.GetDir( KDmDefaultDir, 
                                     mask, 
                                     EAscending | EDirsFirst, 
                                     dirs) );
    if( dirs && dirs->Count() )
        {
        CleanupStack::PushL( dirs );

        for( TInt ii = 0; ii < dirs->Count(); ++ii )
            {
            TEntry entry = (*dirs)[ii];

            CLOG_WRITE_1( "Found: %S", &entry.iName );

            TUint32 clientUid = CheckClientDirName( entry.iName );
            if( clientUid )
                {
                CreateNewClientAppL( clientUid );
                }
            }

        CleanupStack::Pop( dirs );
        }

    delete dirs;
    }
Beispiel #2
0
LOCAL_C void TestInitialStructureL(CMsvServer& aServer)
	{
	TInt services=1;
	TInt localFolders=5;

	CMsvServerEntry* sEntry = CMsvServerEntry::NewL(aServer, KMsvRootIndexEntryId);
	CleanupStack::PushL(sEntry);
	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
	CleanupStack::PushL(selection);
	TMsvSelectionOrdering sort(KMsvNoGrouping, EMsvSortByNone, ETrue);
	sEntry->SetSort(sort);

	// root
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvRootIndexEntryId));
	test(sEntry->Entry().iDetails==KNullDesC);
	test(sEntry->Entry().iDescription==KNullDesC);
	REPORT_IF_ERROR(sEntry->GetChildren(*selection));
	test(selection->Count()==services);
	
	// local service
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvLocalServiceIndexEntryId));
	test(sEntry->Entry().iDetails==_L("Local"));
	REPORT_IF_ERROR(sEntry->GetChildren(*selection));
	test(selection->Count()==localFolders);

	// standard folders
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvGlobalInBoxIndexEntryId));
	test(sEntry->Entry().iDetails==_L("Inbox"));
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvGlobalOutBoxIndexEntryId));
	test(sEntry->Entry().iDetails==_L("Outbox"));
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvDraftEntryId));
	test(sEntry->Entry().iDetails==_L("Drafts"));
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvSentEntryId));
	test(sEntry->Entry().iDetails==_L("Sent"));
	REPORT_IF_ERROR(sEntry->SetEntry(KMsvDeletedEntryFolderEntryId));
	test(sEntry->Entry().iDetails==_L("Deleted"));

	// check that only the index file and the local services dir are present
	CDir* dir;
	const TUidType type(KMsvEntryFile, KMsvEntryFile, KNullUid);
	REPORT_IF_ERROR(theUtils->FileSession().GetDir(KTestFolder,type , ESortNone, dir));
	TInt count=dir->Count();
	test(count==0) ;
	delete dir;

	// check that the local services dir is empty
	TFileName filename;
	filename.Append(KTestLocalService);
	filename.Append(_L("\\"));
	REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename,type , ESortNone, dir));
	count=dir->Count();
	test(count==0) ;
	delete dir;

	CleanupStack::PopAndDestroy(2); // sEntry,selection
	}
Beispiel #3
0
void CCmdFind::DoRunL()
	{
	RFs& fs = FsL();
	iPath.SetIsDirectoryL();
	if (!iName)
		{
		LeaveIfErr(KErrArgument, _L("You must specify a name to match against"));
		}

	iSearchDirs.AppendL(iPath.AllocLC());
	CleanupStack::Pop();

	while (iSearchDirs.Count())
		{
		const TDesC& path = *iSearchDirs[0];

		TInt err;
		CDir* matchingFiles = NULL;
		iTempName.Copy(path);
		iTempName.AppendComponentL(*iName, TFileName2::EFile);
		// Look for files in this directory first
		err = fs.GetDir(iTempName, KEntryAttNormal|KEntryAttDir, ESortByName, matchingFiles);
		if (!err)
			{
			for (TInt i = 0; i < matchingFiles->Count(); i++)
				{
				const TEntry& entry = (*matchingFiles)[i];
				FoundFile(path, entry.iName, entry.IsDir());
				}
			}
		delete matchingFiles;

		// Then add all this dir's subdirectories to the list of ones to be scanned
		CDir* dirsToRecurse = NULL;
		err = fs.GetDir(path, KEntryAttDir|KEntryAttMatchExclusive, ESortNone, dirsToRecurse);
		if (!err)
			{
			CleanupStack::PushL(dirsToRecurse);
			for (TInt i = 0; i < dirsToRecurse->Count(); i++)
				{
				const TEntry& entry = (*dirsToRecurse)[i];
				iTempName.Copy(path);
				iTempName.AppendComponentL(entry);
				iSearchDirs.AppendL(iTempName.AllocLC());
				CleanupStack::Pop();
				}
			CleanupStack::PopAndDestroy(dirsToRecurse);
			}
		delete iSearchDirs[0];
		iSearchDirs.Remove(0);
		}
	}
Beispiel #4
0
void CCmdCifTest::DoRunL()
	{
	if (iCmd)
		{
		CCommandInfoFile* cif = CCommandInfoFile::NewL(FsL(), Env(), *iCmd);
		TestCifL(cif); // Takes ownership
		}
	else
		{
		_LIT(KCifDir, "y:\\resource\\cif\\fshell\\");
		TFindFile find(FsL());
		CDir* dir = NULL;
		TInt found = find.FindWildByDir(_L("*.cif"), KCifDir, dir);
		while (found == KErrNone)
			{
			for (TInt i = 0; i < dir->Count(); i++)
				{
				iFileName.Copy(TParsePtrC(find.File()).DriveAndPath()); // The docs for TFindFile state you shouldn't need the extra TParsePtrC::DriveAndPath(). Sigh.
				iFileName.Append((*dir)[i].iName);
				iCifFiles.AppendL(iFileName.AllocLC());
				CleanupStack::Pop();
				}
			delete dir;
			dir = NULL;
			found = find.FindWild(dir);
			}
		NextCif();
		}
	}
// ---------------------------------------------------------------------------
// Common file counting helper
// ---------------------------------------------------------------------------
//
TInt CXIMPTestFileTool::DoNumObjectsL( const TDesC& aTemplate )
    {
    CDir* dir = GetDirListL( aTemplate );
    TInt count = dir->Count();
    delete dir;
    return count;
    }
Beispiel #6
0
static void RecursiveRmDir(const TDesC& aDes)
//
// Delete directory contents recursively
//
{
    CDir* pD;
    TFileName n=aDes;
    n.Append(_L("*"));
    TInt r=TheFs.GetDir(n,KEntryAttMaskSupported,EDirsLast,pD);
    if (r==KErrNotFound || r==KErrPathNotFound)
        return;
    test_KErrNone(r);
    TInt count=pD->Count();
    TInt i=0;
    while (i<count)
    {
        const TEntry& e=(*pD)[i++];
        if (e.IsDir())
        {
            TFileName dirName;
            dirName.Format(_L("%S%S\\"),&aDes,&e.iName);
            RecursiveRmDir(dirName);
        }
        else
        {
            TFileName fileName;
            fileName.Format(_L("%S%S"),&aDes,&e.iName);
            r=TheFs.Delete(fileName);
            test_KErrNone(r);
        }
    }
    delete pD;
    r=TheFs.RmDir(aDes);
    test_KErrNone(r);
}
// -----------------------------------------------------------------------------
// CPlatformVerTest::DoPlatformVersionTest
// -----------------------------------------------------------------------------
//
TInt CPlatformVerTest::DoPlatformVersionTest(
        VersionInfo::TVersionBase& aVersion, RFs* aFs )
    {
    TInt fileErr( KErrNone );
    CDir* productIds = NULL;
    TFindFile find( iFs );
    TInt ret( find.FindWildByPath( KS60ProductIDFiles, NULL, productIds ) );
    if ( ret == KErrNone && productIds && productIds->Count() )
        {
        fileErr = KErrNone;
        }
    else
        {
        fileErr = KErrNotSupported;
        }
    if ( aFs )
        {
        ret = VersionInfo::GetVersion( aVersion, *aFs );
        }
    else
        {
        ret = VersionInfo::GetVersion( aVersion );
        }
    if ( fileErr == ret )
        {
        ret = KErrNone;
        }
    delete productIds;
    return ret;
    }
void CExampleCpiManager::FindCpiFilesL()
/**	Looks in the UAProf directory for any CPI files and adds them to the array of CPI files
	@since		8.0
*/
	{
	TUidType uidType(KUidUaProfCpi);
	CDir* dir;
	// Get a list of files that match the CPI UID
	TInt err = iFs.GetDir(KTxtCpiFilesLocation, uidType, ESortByUid, dir);
	CleanupStack::PushL(dir);	
	if (err == KErrPathNotFound)
		User::LeaveIfError(iFs.MkDirAll(KTxtCpiFilesLocation()));
	else
		User::LeaveIfError(err);
	
	const TInt fileCount = dir->Count();
	for (TInt i = 0; i < fileCount; ++i)
		{
		TEntry* entry = NULL;
		entry = new (ELeave) TEntry((*dir)[i]);
		entry->iName = KTxtCpiFilesLocation();
		(entry->iName.Des()).Append((*dir)[i].iName);
		User::LeaveIfError(iCpiFileList.Append(entry));
		}
	CleanupStack::PopAndDestroy(dir);
	}
void CPolicyImporter::BuildPolicyIdListL()
    {
    delete iPolicyIdList;
    iPolicyIdList = NULL;
    iPolicyIdList = new (ELeave) CArrayFixFlat<TExtVpnPolicyId>(2);

    TFindFile* fileFinder = new (ELeave) TFindFile(iFs);
    CleanupStack::PushL(fileFinder);

    CDir* fileList;

    TInt ret = fileFinder->FindWildByDir(KPinFilePat, iImportDir, fileList);

    if (ret == KErrNone)
        {
        CleanupStack::PushL(fileList);

        for (TInt i = 0; i < fileList->Count(); i++)
            {
            TParse* fileNameParser = new (ELeave) TParse();
            CleanupStack::PushL(fileNameParser);

            fileNameParser->Set((*fileList)[i].iName, NULL, NULL);

            TExtVpnPolicyId policyId;
            policyId.Copy(fileNameParser->Name());

            iPolicyIdList->AppendL(policyId);

            CleanupStack::PopAndDestroy(); // fileNameParser
            }
        CleanupStack::PopAndDestroy(); // fileList
        }
    CleanupStack::PopAndDestroy(); // fileFinder
    }
Beispiel #10
0
/*
 * Scan folders contents once
 */
inline bool CFolderScanner::ScanOnce()
{
    // Perform scan
    CDir* SMSInList = NULL;
    if (iFs.GetDir(*iFolder,KEntryAttNormal,ESortNone,SMSInList) == KErrNone)
    {
        for(TInt i = 0; i<SMSInList->Count(); i++)
        {
            // if we're given a wild card, we ignore chars before '.'
            // just extension chars?
            const TEntry& entry = (*SMSInList)[i];
            if (!entry.IsDir())
            {
                TPtrC ext(entry.iName.Mid(entry.iName.LocateReverse('.')));
                if (!ext.CompareF(iScanExt->Mid(iScanExt->LocateReverse('.'))))
                {
                    TFileName fileName;
                    fileName.Append(*iFolder);
                    fileName.Append(entry.iName);
                    iClient->FileFound(fileName);
                    delete SMSInList;
                    return true;
                }
            }
        }
        delete SMSInList;
    }
    return false;
}
Beispiel #11
0
void CProfileListDialog::PreLayoutDynInitL() {
    ButtonGroupContainer().SetDefaultCommand(ECmdProfileListConnect);

    iProfileArray = new (ELeave) CDesCArrayFlat(8);

    // Add default as the first profile
    iProfileArray->AppendL(KDefaultProfileName);

    // Find all profile files from the profile directory and add them to the
    // list    
    RFs &fs = CEikonEnv::Static()->FsSession();
    CDir *dir;
    User::LeaveIfError(fs.GetDir(iProfileDirectory, KEntryAttNormal,
                                 ESortByName, dir));
    CleanupStack::PushL(dir);
    for ( TInt i = 0; i < dir->Count(); i++ ) {
        iProfileArray->AppendL((*dir)[i].iName);
    }
    CleanupStack::PopAndDestroy(); //dir

    // Set profiles to the listbox
    CEikTextListBox *lbox = ((CEikTextListBox*)Control(EProfileListDlgProfileList));
    CTextListBoxModel *lbm = lbox->Model();
    lbm->SetItemTextArray(iProfileArray);
    lbm->SetOwnershipType(ELbmDoesNotOwnItemArray);

    // Enable scroll bars
    CEikScrollBarFrame *sbf = lbox->CreateScrollBarFrameL(ETrue);
    sbf->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,
                                 CEikScrollBarFrame::EAuto);

    ButtonGroupContainer().SetDefaultCommand(ECmdProfileListConnect);
}
//================================================================================
//convertPathL
//================================================================================
void convertPathL(TDesC& aPath, TDesC& aPathName, RFs& aFs, TDesC& aTargetFile)
	{
	aFs.MkDirAll(aPathName);

	CDir* entryList = NULL;
	TInt error = aFs.GetDir(aPath,KEntryAttMatchMask,ESortByName,entryList);
	User::LeaveIfError(error);

	TInt numberOfFiles = entryList->Count();
	for (TInt i=0; i<numberOfFiles; i++)
		{
		//get the source file
		HBufC* temp=HBufC::NewLC(((*entryList)[i].iName).Length());
		TPtr sourceFileName(temp->Des());
		sourceFileName.Copy((*entryList)[i].iName);

		HBufC* temp2=HBufC::NewLC(((*entryList)[i].iName).Length()+aPathName.Length());
		TPtr sourceFile(temp2->Des());
		sourceFile = aPathName;
		sourceFile.Append(sourceFileName);
		//do the conversion
		synchronousL(sourceFile, aTargetFile);
		//output result
		_LIT(KString,"%S");
		test.Printf(KString,&(sourceFileName));
		test.Printf(_L("\n"));
		CleanupStack::PopAndDestroy(2);//temp, temp2
		}

	delete entryList;
	test.Printf(_L("\n%d files converted\n"),numberOfFiles);
	}
Beispiel #13
0
LOCAL_C void ScanDirL(RFs& aFs, const TDesC& aDir)
	{
	User::After(1000000);

	TParse parse;
	parse.Set(_L("t_*.exe"), &aDir, NULL);
	TPtrC spec(parse.FullName());

	test.Start(parse.DriveAndPath());
	TFindFile find(aFs);
	CDir* dir;
	
	if (!find.FindWildByPath(parse.FullName(), NULL, dir))
		{
		CleanupStack::PushL(dir);

		for(int i = 0; i < dir->Count(); i++)
			{
			parse.Set((*dir)[i].iName, &spec, NULL);

			if (i == 0)
				test.Start(parse.FullName());
			else
				test.Next(parse.FullName());

			LaunchAndWaitL(parse.FullName());
			}

		CleanupStack::PopAndDestroy(); // dir
		}
	test.End();
	}
Beispiel #14
0
void CStateDownload::ScanDirectory(RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aFilesArray)
	{
	TParse parse;
	parse.Set(aWild, &aDir, NULL);
	TPtrC spec(parse.FullName());
	 
	TFindFile FindFile(aFs);
	CDir* dir;
	 
	if (FindFile.FindWildByPath(parse.FullName(), NULL, dir) == KErrNone)
		{
	    CleanupStack::PushL(dir);
	 
	    TInt count=dir->Count();
	    for(TInt i = 0; i < count; i++)
	    	{
	        parse.Set((*dir)[i].iName, &spec, NULL);
	        TEntry entry;
	        if(aFs.Entry(parse.FullName(),entry) == KErrNone)
	        	{
	        	if(!entry.IsDir())
	        		{
	        		//InsertIsqL raises a KErrAlreadyExists (-11) when inserting a duplicate
	        		TRAPD(err,aFilesArray->InsertIsqL(parse.FullName())); 
	        		}
	        	}
	        }
	    CleanupStack::PopAndDestroy(dir);
	    }
	}
Beispiel #15
0
void CMsvMove::CheckEntriesL()
//
//
//
	{
	iLockedIndex = iDescendents->Count();
	while (iLockedIndex)
		{
		TMsvId id = iDescendents->At(iLockedIndex-1);

		// lock the entry
		User::LeaveIfError(iServer.IndexAdapter().LockEntryAndStore(id));
		iLockedIndex--;

		// check noone is reading the store (reading the store now doesn't
		// keep the file open, therefore we can't rely on checking the file to stop
		// deleting while reading
		TBool reading=EFalse;
		User::LeaveIfError(iServer.IndexAdapter().IsStoreReadingLocked(id,reading));
		if(reading) User::Leave(KErrInUse);

		// get the entry
		TMsvEntry* entry;
		User::LeaveIfError(iServer.IndexAdapter().GetEntry(id, entry));
		// check the store
		TFileName filename;
		iServer.GetEntryName(id, filename, EFalse);
		TBool open;
		TInt error = iServer.FileSession().IsFileOpen(filename, open);
		if (error != KErrNotFound && error!=KErrPathNotFound)
			{
			if (error != KErrNone)
				User::Leave(error);
			if (open)
				User::Leave(KErrInUse);
			}

		// check any files
		CDir* dir;
		error = iServer.GetFileDirectoryListing(id, filename, dir);
		if (error == KErrNone)
			{
			CleanupStack::PushL(dir);
			User::LeaveIfError(iServer.FileSession().SetSessionPath(filename));
			TInt fCount=dir->Count();
			if (fCount--)
				{
				TBool open;
				User::LeaveIfError(iServer.FileSession().IsFileOpen((*dir)[fCount].iName, open));
				if (open)
					User::Leave(KErrInUse);
				}
			CleanupStack::PopAndDestroy(); // dir
			}
		else if (error != KErrPathNotFound)
			User::Leave(error);
		}
	}
// prepare each test step
void CFileOperator::TestStepPrepare(TUint aOp)
	{
	RDebug::Print(_L("Preparing for the next test step..."));
	switch (aOp)
		{
		case EOpReplace:
			{
			User::After(1500000); // Wait for 1.5 sec so that the new files have different modified time
			RFile file;
			TInt count = iFirstFile + iNumFiles;
			while (count < (iFirstFile + (iNumFiles * 2)))
				{
				TFileName nextFile;
				FileNameGen(nextFile, count);
				file.Create(iFs, nextFile, EFileRead);
				file.Close();
				count++;
				}
			break;
			}
		case EOpManyChanges:
			{
			RFile file;
			TFileName nextFile;
			FileNameGen(nextFile, 9999);
			file.Create(iFs, nextFile, EFileRead);
			file.Close();
			break;
			}
		case EOpManyFiles:
			{
			CDir* list;
			iFs.GetDir(gTestPath, KEntryAttMaskSupported, ESortNone, list);
			TInt count = list->Count();
			delete list;
			
			RFile file;
			
			for (TInt i = 0; i < iNumFiles - count; i++)
				{
				TFileName nextFile;
				FileNameGen(nextFile, count + i);
				file.Create(iFs, nextFile, EFileRead);
				file.Close();
				}
			
			break;
			}
		// No preparation for other operations
		default:
			break;
		}
	RDebug::Print(_L("Preparation done..."));
	}
void CAknFileSettingPage::ReadFilesL(const TDesC* aPos)
{
    TInt pos=-1;
    iFiles->Reset();
    FileControl()->Reset();
    TFileName buffer;
    if(iFileValue.Length())
    {
        buffer.Copy(KFolderIcon);
        buffer.Append(KFolderUp);
        iFiles->AppendL(buffer);
        TParse parse;
        parse.SetNoWild(iFileValue,NULL,NULL);
        CDir* list;
        User::LeaveIfError(iFs.GetDir(parse.DriveAndPath(),KEntryAttMaskSupported,ESortByName|EDirsFirst,list));
        CleanupStack::PushL(list);
        for(TInt i=0; i<list->Count(); i++)
        {
            const TDesC& name=(*list)[i].iName;
            if((*list)[i].IsDir())
            {
                buffer.Copy(KFolderIcon);
            }
            else
            {
                if(name.MatchF(KMelodyMask1)<0&&name.MatchF(KMelodyMask2)<0&&name.MatchF(KMelodyMask3)<0&&name.MatchF(KMelodyMask4)<0) continue;
                buffer.Copy(KMelodyIcon);
            }
            buffer.Append(name);
            if(aPos&&name.MatchF(*aPos)>=0) pos=iFiles->Count();
            iFiles->AppendL(buffer);
        }
        CleanupStack::PopAndDestroy(); //list
    }
    else
    {
        TDriveList drives;
        User::LeaveIfError(iFs.DriveList(drives));
        for(TInt drive=EDriveA; drive<=EDriveZ; drive++)
        {
            if(drives[drive])
            {
                buffer.Copy(KFolderIcon);
                buffer.Append(drive+'a');
                buffer.Append(':');
                iFiles->AppendL(buffer);
            }
        }
    }
    FileControl()->HandleItemAdditionL();
    if(pos!=-1) FileControl()->SetCurrentItemIndexAndDraw(pos);
    UpdateFileL();
}
// ---------------------------------------------------------
// 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 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 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);
		}
	}
/**
@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;	
	}
	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();
		}
// 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();
	}
// ---------------------------------------------------------------------------
// 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 );
    }
Beispiel #28
0
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--;
	}
Beispiel #29
0
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);
}
	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);
			}
		}