void CPolicyImporter::BuildUserPrivKeyAndUserCertListL()
    {
    LOG_("-> CPolicyImporter::BuildUserPrivKeyAndUserCertListL()");
    delete iCurrUserPrivKeyList;
    iCurrUserPrivKeyList = NULL;
    iCurrUserPrivKeyList = new (ELeave) CArrayFixFlat<TFileName>(2);

    delete iCurrUserCertList;
    iCurrUserCertList = NULL;
    iCurrUserCertList = new (ELeave) CArrayFixFlat<TFileName>(2);

    TFileName *fileName = new (ELeave) TFileName;
    CleanupStack::PushL(fileName);


    for (TInt i = 0; i < iCurrIkeDataArray->Count(); i++)
        {
        CIkeData* ikeData = iCurrIkeDataArray->At(i);
        fileName->Zero();

        if (ikeData->iOwnCert.iData.Length() > 0 &&
            ikeData->iOwnCert.iFormat == BIN_CERT)
            {
            //First check that defined user cert is found and if so
            //add the file name to the list

            *fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iOwnCert.iData);
            if (!iFileUtil.FileExists(*fileName))
                {
                User::Leave(KVpnErrInvalidUserCertFile);
                }
            AppendIfNotFoundL( iCurrUserCertList, fileName );

            //After the user cert is found check that the assosiated private key
            //is found.
            if (ikeData->iPrivKey.iData.Length() > 0 &&
                ikeData->iPrivKey.iFormat == BIN_CERT)
                {
                fileName->Zero();
                *fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iPrivKey.iData);
                if (!iFileUtil.FileExists(*fileName))
                    {
                    User::Leave(KVpnErrInvalidUserPrivKeyFile);
                    }
                AppendIfNotFoundL( iCurrUserPrivKeyList, fileName );
                }
            else
                {
                User::Leave(KVpnErrInvalidPolicyFile);
                }
            }
        }

    CleanupStack::PopAndDestroy(); //fileName
    LOG_("<- CPolicyImporter::BuildUserPrivKeyAndUserCertListL()");
    }
void CPolicyImporter::BuildPeerCertListL()
    {
    LOG(Log::Printf(_L8("-> CPolicyImporter::BuildPeerCertListL()\n")));
    delete iCurrPeerCertList;
    iCurrPeerCertList = NULL;
    iCurrPeerCertList = new (ELeave) CArrayFixFlat<TFileName>(2);

    TFileName *fileName = new (ELeave) TFileName;
    CleanupStack::PushL(fileName);

    for (TInt i = 0; i < iCurrIkeDataArray->Count(); i++)
        {
        CIkeData* ikeData = iCurrIkeDataArray->At(i);
        fileName->Zero();

        if (ikeData->iPeerCert.iData.Length() > 0 &&
            ikeData->iPeerCert.iFormat == BIN_CERT)
            {
            *fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iPeerCert.iData);
            if (!iFileUtil.FileExists(*fileName))
                {
                User::Leave(KVpnErrPeerCertFileMissing);
                }
            AppendIfNotFoundL( iCurrPeerCertList, fileName );
            }
        }

    CleanupStack::PopAndDestroy(); //fileName
    LOG_("<- CPolicyImporter::BuildPeerCertListL()");
    }
void CFriendLink::EnterModel(TInt atype)
{
//	atype += 1;

	TBuf<30>temptitle;
	temptitle.Zero();
	switch(atype)
	{
	case 0:
		{
			temptitle.Append(iMainEngine.GetDesById(ECoCoTextRes_MainView_Three));
			temptitle.Append(_L("->"));
			CNormalListBoxItem& item = (CNormalListBoxItem&)ilistbox->CurItem();

			temptitle.Append(item.GetText());
			CNewDownload* newdowload = CNewDownload::NewL(this,iMainEngine);
			newdowload->titlebuf.Zero();
			newdowload->titlebuf.Copy(temptitle);
			newdowload->iFirstID = EContentHotDownload;
			TInt tempsecondid = ilistbox->CurItemIndex();			
			newdowload->iSecondID = iMainEngine.GetSynchronContent().GetItemID(EContentHotDownload,tempsecondid,-1);
			newdowload->iThirdID = 0;
			newdowload->ConstructLater();
			newdowload->SetViewType(EContentHotDownload);
			this->SetChildWindow(newdowload);
		}
		break;
	case 1:
		{
			if(iFLinkType==0)
			{
				iPIndex=ilistbox->CurItemIndex();
				this->ChangeFriendLinkList(iPIndex);
			}
			else
			{
				TFileName downLoadUrl;
				downLoadUrl.Zero();
				downLoadUrl.Append(_L("http://59.36.96.182/interface/f?n="));
				downLoadUrl.Append(iMainEngine.GetIMEI());
				downLoadUrl.Append(_L("&id="));
				TInt firstid = EContentFriendLink;
				TInt secondid = iPIndex;
				TInt thirdid =this->ilistbox->CurItemIndex();
				TInt Urlid = iMainEngine.GetSynchronContent().GetItemID(firstid,secondid,thirdid);

				downLoadUrl.AppendNum(Urlid);
				downLoadUrl.Append(_L("&t="));
				downLoadUrl.AppendNum(1);
				this->iMainEngine.LaunchWapBrowswerL(downLoadUrl);
			}
		}
	    break;
	default:
	    break;
	}
}
void CSearchLocalResultView::OpenFile()
{
	TFileName fileName;
	fileName.Zero();
	fileName.Append(iLocalSearch->GetOneItemPath(this->iSearchList->GetSelectedIndex()));
	fileName.Append(iLocalSearch->GetOneItemName(this->iSearchList->GetSelectedIndex()));

	iMainEngine.FileExecuter((CWindow*)this).OpenFileByDefault(fileName);
}
void CSearchLocalResultView::InitCopyToDialog(const TDesC& aText)
{
	TFileName path;
	
	CCopyToDialog* copyToDialog=iMainEngine.ControlFactory().CreateCopyToDialog(*this,aText,this);
	for(TInt i=0;i<7;i++)
	{
		path.Zero();
		this->GetCopyToPath(i,path);
		copyToDialog->AppendItem(iMainEngine.GetDesById(ETurkeyTextRes_NewSearch_Type1+i),path);
	}
	this->iSearchList->SetEdwinVisible(EFalse);
}
示例#6
0
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
void CEcomHandler::ReFreshHandlersL()
{		
	iHandlers.ResetAndDestroy();

	RImplInfoPtrArray infoArray;
	REComSession::ListImplementationsL(KUidYTaskHandUID, infoArray);

	TFileName CurrName;

	for ( TInt i = 0; i < infoArray.Count(); i++ )
	{
		CurrName.Zero();		
		CurrName.Copy(infoArray[i]->DisplayName());
		CurrName.TrimAll();
		
		TInt YStart = infoArray[i]->OpaqueData().Find(KtxStrtYTools);
		TInt YEnd 	= infoArray[i]->OpaqueData().Find(KtxEnddYTools);
		if(YStart != KErrNotFound
		&& YEnd != KErrNotFound)
		{	
			YStart = YStart + KtxStrtYTools().Length();
			YEnd = (YEnd - YStart);
			if(YEnd > 0 )
			{
				if(CurrName.Length() && CheckVersionL(infoArray[i]->OpaqueData().Mid(YStart,YEnd)))
				{
					CHandlerItem* newItem = new(ELeave)CHandlerItem();
					CleanupStack::PushL(newItem);
				
					newItem->iUid = infoArray[i]->ImplementationUid();	
					newItem->iName = CurrName.AllocL();
				
					newItem->iServerName = ParseInfoL(infoArray[i]->OpaqueData().Mid(YStart,YEnd),KtxStrtSERVER,KtxEnddSERVER);
					newItem->iIconfile = ParseInfoL(infoArray[i]->OpaqueData().Mid(YStart,YEnd),KtxStrtICONFILE,KtxEnddICONFILE);
				
					CleanupStack::Pop(newItem);
					
					iHandlers.Append(newItem);
				}
			}
		}
	}
	
	infoArray.ResetAndDestroy();
}
示例#7
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
CYTasksContainer* CEcomHandler::GetHandlerL(CHandlerItem& aHandler,CEikButtonGroupContainer* aCba)
{
	CYTasksContainer* Ret(NULL);

	TAny *impl;  // pointer to interface implementation
	RImplInfoPtrArray infoArray;		
			
	REComSession::ListImplementationsL(KUidYTaskHandUID, infoArray);
	
	TFileName CurrName;				
	for ( TInt i = 0; i < infoArray.Count(); i++ )
	{
		CurrName.Zero();		
		CurrName.Copy(infoArray[i]->DisplayName());
		CurrName.TrimAll();
		
		if(aHandler.iUid == infoArray[i]->ImplementationUid() 
		&& CurrName.Length()
		&& aHandler.iName)
		{
			if(CurrName == aHandler.iName->Des())	
			{
				impl = REComSession::CreateImplementationL(infoArray[i]->ImplementationUid(), _FOFF(CYTasksContainer,iDestructorIDKey));
				if ( impl )
				{
					Ret = ((CYTasksContainer*)impl);
					Ret->iTasksHandlerExit = iTasksHandlerExit;				
					CleanupStack::PushL(Ret);
					Ret->ConstructL(aCba);
					CleanupStack::Pop();//Ret
					break;
				}
				
				impl = NULL;
			}
		}
	}

	infoArray.ResetAndDestroy();

	return Ret;
}
void CPolicyImporter::BuildCaCertListL()
    {
    LOG_("-> CPolicyImporter::BuildCaCertListL()");
    delete iCurrCaCertList;
    iCurrCaCertList = NULL;
    iCurrCaCertList = new (ELeave) CArrayFixFlat<TFileName>(2);

    TFileName *fileName = new (ELeave) TFileName;
    CleanupStack::PushL(fileName);

    LOG_("Pre-for");
    for (TInt i = 0; i < iCurrIkeDataArray->Count(); i++)
        {
        LOG_("For start");
        CIkeData* ikeData = iCurrIkeDataArray->At(i);
        fileName->Zero();

        if (ikeData->iCAList)
            {
            LOG_("CAlist found");
            for (TInt j = 0; j < ikeData->iCAList->Count(); j++)
                {
                LOG_("CA iter start");
                if (ikeData->iCAList->At(j)->iFormat == BIN_CERT)
                    {
                    LOG_("Bin cert found");
                    *fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iCAList->At(j)->iData);
                    if (!iFileUtil.FileExists(*fileName))
                        {
                        LOG_("<- CPolicyImporter::BuildCaCertListL() LEAVE (KVpnErrCaCertFileMissing)");
                        User::Leave(KVpnErrInvalidCaCertFile);
                        }
                    //Makes sure every file name is appended only once.
                    AppendIfNotFoundL( iCurrCaCertList, fileName );
                    }
                }
            }
        }

    CleanupStack::PopAndDestroy(); //fileName
    LOG_("<- CPolicyImporter::BuildCaCertListL()");
    }
//--------------------------------------------------------------------------
// CLbtContainerAttrFilter::FilesIdentical
//--------------------------------------------------------------------------
//
TBool CLbtContainerAttrFilter::FilesIdentical( TFileName& aTriggerFileName, TFileName& aSystemFileName )
	{
	FUNC_ENTER("CLbtContainerAttrFilter::FilesIdentical");
	
	if( DoesFileContainePathInfo(aTriggerFileName) )
		{
		LOG("aTriggerFileName containes path info");		
		return ( aSystemFileName.CompareC(aTriggerFileName) != KErrNotFound );
		}
	
	TFileName triggerFileName;
	triggerFileName.Zero();
	triggerFileName.Copy(aTriggerFileName);
	triggerFileName.Insert(0,_L("\\"));
	
	LOGSTRING( "triggerFileName : \"%S\" ", &triggerFileName );
	LOGSTRING( "aSystemFileName: \"%S\" ", &aSystemFileName );
	
	return ( aSystemFileName.FindC( aTriggerFileName ) != KErrNotFound );	
	}
// -----------------------------------------------------------------------------
// CSisxUIStartupFile::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSisxUIStartupFile::ConstructL( const TUid& aUid )
    {
    User::LeaveIfError( iFileSession.Connect() );

    TUidName uidStr = aUid.Name();
    TFileName tmp;
    
    iFileSession.PrivatePath( tmp );    
    tmp.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() );
    tmp.Append( KImportDir );      
    tmp.AppendFormat( KNewFileFormat, &uidStr ); 
    iNewFile = tmp.AllocL();
    tmp.Zero();
        
    iFileSession.PrivatePath( tmp );
    tmp.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() );
    tmp.Append( KPrivateFileDir );    
    iFileSession.MkDir( tmp );    
    tmp.AppendFormat( KPrivateFileFormat, &uidStr );
    iPrivateFile = tmp.AllocL();
    }
void TThreadData::InitialiseL(TInt aIteration, TInt aThreadNum)
	{
	ASSERT(aIteration >= 0 && aIteration < KMaxIterations);
	ASSERT(aThreadNum >= 1 && aThreadNum <= 3);

	TInt script = scriptCombinations[aIteration * 3 + aThreadNum - 1];		
	
	// Set script file
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TDriveName sysdriveName (sysDrive.Name());
	TBuf <60> scriptFile (sysdriveName);
	scriptFile.Append(scripts[script]);
	iScriptFile.Set(scriptFile);

	// Set log file
	iLogFile.Zero();
	TBuf<80> scriptName (sysdriveName);
	scriptName.Append(_L("\\tcertstoreconcurrent\\iteration%02d_thread%d_script%d.txt"));
	TBuf<80> buf ;
	buf.Format(scriptName,aIteration, aThreadNum, script); 
	iLogFile.Append(buf);
	}
void CAMPreInstallApp::MakeAllInstallPathsL()
    {
#ifdef RD_MULTIPLE_DRIVE        
    iInstallDocPathArray = new (ELeave) CDesCArrayFlat( 2 );
    TDriveList driveList;
    TInt driveCount = 0;
    //User::LeaveIfError(iFs.Connect() );
    User::LeaveIfError( DriveInfo::GetUserVisibleDrives(iFs, driveList,driveCount));
    TUint driveStatus = 0;
    for (TInt index(0); index < KMaxDrives; index++)
        {
        if (driveList[index])
            {
            User::LeaveIfError( DriveInfo::GetDriveStatus(iFs, index,
                    driveStatus));
            TFileName path;
            TDriveUnit driveUnit(index);
            if ( !(driveStatus & DriveInfo::EDriveRemote ))
                {
                if (driveStatus & DriveInfo::EDriveRemovable)
                    {
                    path.Zero();
                    path.Append(driveUnit.Name() );
                    path.Append(KPreInstallPath);
                    iInstallDocPathArray->AppendL(path);
                    }
                }
            }
        }
    //iFs.Close();
#else   
    TPtrC mmcDrive(TParsePtrC( PathInfo::MemoryCardRootPath() ).Drive());
    iPreInstallDocumentPath.Append(mmcDrive);
    iPreInstallDocumentPath.Append(KPreInstallPath);
#endif //RD_MULTIPLE_DRIVE 
    }
示例#13
0
// :FIXME: improve API
TInt DKdaChannel::GetCodeSegInfo(RMinKda::TCodeInfoParams* aParams)
	{
	RMinKda::TCodeInfoParams params;
	umemget32(&params, aParams, sizeof(params));

	// :FIXME: Currently code segments are always loaded at the same
	// location in every address space.  Consequently we can ignore
	// the PID provided by the client.
	DProcess* pP = NULL;

	TInt r = KErrNotFound;
	TFileName	nameBuffer;
	nameBuffer.Zero();
	Kern::AccessCode();
	DCodeSeg* pS = DCodeSeg::VerifyHandle(params.iHandle);
	if (pS)
		{
		TModuleMemoryInfo mmi;
		r = pS->GetMemoryInfo(mmi, pP);
		if (r == KErrNone)
			{
			params.iCodeBase = mmi.iCodeBase;
			params.iCodeSize = mmi.iCodeSize;
			XTRAP(r, XT_DEFAULT, nameBuffer.Append(*(pS->iFileName)));
			}
		}
	Kern::EndAccessCode();
	Kern::KUDesPut(*(params.iPathPtr), nameBuffer);
	if (r == KErrBadDescriptor)
		Kern::PanicCurrentThread(KLitKernExec, ECausedException);

	if (r == KErrNone)
		umemput32(aParams, &params, sizeof(params));

	return r;
	}
示例#14
0
//================================================================================
//getPathL
//================================================================================
TBool getPathL(TDes& aPath, RFs& aFs)
	{
	// Generate the folder spec to search in
	TFileName searchSpec;
	TChar driveLetter = 'C';
	searchSpec.Append(driveLetter);
	searchSpec.Append(aPath);

	CDir* entryList = NULL;
	TFindFile finder(aFs);
	TInt ret = finder.FindWildByPath(searchSpec, NULL, entryList);
	if(ret<KErrNone)
		{
		//try z drive
		driveLetter = 'Z';
		searchSpec.Zero();
		searchSpec.Append(driveLetter);
		searchSpec.Append(aPath);
		delete entryList;
		entryList = NULL;

		ret = finder.FindWildByPath(searchSpec, NULL, entryList);
		if	(ret < KErrNone)
			{
			//path not found
			delete entryList;
			test.Printf(_L("files not found\n"));
			return EFalse;
			}
		}

	delete entryList;
	//set path
	aPath.Copy(searchSpec);
	return ETrue;
	}
示例#15
0
void CPixelMetricsMapperAppUi::CreateHeaderFileL() const
    {
    // Open/create resulting file.
    RFile file;
    HBufC* layoutFile = HBufC::NewLC( KMaxFileName );
    *layoutFile = KLayoutSourceFileAndPath;
    TFileName fileName = *layoutFile;
    CleanupStack::PopAndDestroy(layoutFile);
    RFs& fs = CEikonEnv::Static()->FsSession();
    TInt error = file.Open(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText );
    if (error==KErrNotFound)
        {
       file.Create(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText);
        }
    CleanupClosePushL( file );
    file.SetSize( 0 );

    // Make all writes as from textfile.
    TFileText textFile;
    textFile.Set( file );
    textFile.Seek( ESeekStart );

    // Take all layout files from private folder.
    CDir* dirList;
    User::LeaveIfError(fs.GetDir(
        KPixelMetricsDataFiles,
        KEntryAttMaskSupported,
        ESortByName,
        dirList));

    TMySmallBuffer bufferLayoutHdr;
    TMyBigBuffer bufferPMData;
    TInt fileCount = dirList->Count();
    for (TInt i=0;i<fileCount;i++)
        {
        // open sourcefile
        RFile sourceFile;
        TFileName layoutFile = (*dirList)[i].iName;
        User::LeaveIfError( sourceFile.Open(
            fs,layoutFile, EFileRead|EFileShareAny|EFileStreamText ));
        CleanupClosePushL( sourceFile );

        // Make all reads as from textfile.
        TFileText textSourceFile;
        textSourceFile.Set( sourceFile );
        TFileName layoutName = CreateLayoutNameL( textSourceFile );

        // rewind - just in case.
        textSourceFile.Seek( ESeekStart );
        TFileName oneline;
        bufferLayoutHdr.Append(KOpenBrace);
        bufferPMData.Append(KOpenBrace);
        TInt loop = 0;
        FOREVER
            {
            if( textSourceFile.Read(oneline) != KErrNone )
                {
                break;
                }
            // Add commas for all but first line
            if (loop != 0)
                {
                if ( loop <= KHeaderValues-1)
                    {
                    bufferLayoutHdr.Append(KComma);
                    }
                else
                    {
                    if (loop != KHeaderValues)
                        {
                        bufferPMData.Append(KComma);
                        }
                    }
                if (loop==KHeaderValues)
                    {
                    bufferLayoutHdr.Append(_L(",QLatin1String(\""));
                    bufferLayoutHdr.Append(layoutName);
                    bufferLayoutHdr.Append(_L("\")"));
                    }
                }
            // Remove pixel metrics name and ":"
            oneline = oneline.Mid(oneline.Find(KColon)+1);
            // Remove tab
            oneline = oneline.Mid(oneline.Find(KTab)+1);
            // remove crap from the end of line
            TLex lex(oneline);
            TInt nextValue = -666;
            User::LeaveIfError( lex.Val(nextValue) );
            if ( loop <= KHeaderValues-1)
                {
                bufferLayoutHdr.AppendNum(nextValue);
                }
            else
                {
                if (nextValue == -909)
                    bufferPMData.Append(_L("ECommonStyleValue"));
                else
                    bufferPMData.AppendNum(nextValue);
                }
            oneline.Zero();
            loop++;
            }
        file.Flush();
        bufferLayoutHdr.Append(KEndBraceWithCommaAndCRLF);
        bufferPMData.Append(KEndBraceWithCommaAndCRLF);
        CleanupStack::PopAndDestroy(); //sourceFile
        }

    if (fileCount > 0)
        {
        bufferLayoutHdr = bufferLayoutHdr.Left(bufferLayoutHdr.Length()-2);
        bufferPMData = bufferPMData.Left(bufferPMData.Length()-2);
        textFile.Write(bufferLayoutHdr);
        textFile.Write(KCRLF);
        textFile.Write(bufferPMData);
        }
    delete dirList;

    CleanupStack::PopAndDestroy(); //file
    }
示例#16
0
void CFileEngine::PasteFile(const TDesC& aFilaName)
{
	if(NULL == iCopiedFile)
	{
		iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_Copy_NotSelect),*this,ECmdNull);
	}
	else
	{
		if(!BaflUtils::FileExists(iFs,*iCopiedFile))
		{
			iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FilePaste_SourceNotExist),*this,ECmdCancelCopy);
		}
		else
		{
			TParse parse;
			parse.Set(*iCopiedFile,NULL,NULL);
			const TDesC& driveAndPath = parse.DriveAndPath();
			const TDesC& nameAndExt = parse.NameAndExt();
			
			TFileName desFileName;
			TBool isFolder = EFalse;
			TInt err = BaflUtils::IsFolder(iFs,aFilaName,isFolder);
			if(KErrNone == err && isFolder)
			{
				desFileName.Append(aFilaName);
				if(desFileName.Right(1).Compare(_L("\\"))!=0)
				{
					desFileName.Append(_L("\\"));
				}
				desFileName.Append(nameAndExt);
			}
			else
			{
				TParse parseDes;
				parseDes.Set(aFilaName,NULL,NULL);
				
				desFileName.Append(parseDes.DriveAndPath());
				if(parseDes.DriveAndPath().Right(1).Compare(_L("\\"))!=0)
				{
					desFileName.Append(_L("\\"));
				}
				desFileName.Append(nameAndExt);
			}
			iMainEngine.WriteLog16(*iCopiedFile);
			iMainEngine.WriteLog16(desFileName);

			TInt result = CheckDiskSpace(*iCopiedFile,desFileName);
			if(1 == result)
			{
				iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_SaveAs_NoSpace),*this,ECmdCancelCopy);
			}
			else if(2 == result)
			{
				iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FilePaste_OtherError),*this,ECmdCancelCopy);
			}
			else
			{
				if(BaflUtils::FileExists(iFs,desFileName))
				{
					TParse parseTemp;
					parseTemp.Set(desFileName,NULL,NULL);

					desFileName.Zero();
					desFileName.Append(parseTemp.DriveAndPath());
					desFileName.Append(iMainEngine.GetDesById(ETurkeyTextRes_Copy_SameName));
					desFileName.Append(parseTemp.NameAndExt());
				}

				iFileActiveEngine.CopyFile(*iCopiedFile,desFileName,this);

				iDialog = iControlFactory.CreateWaitDialog(iMainEngine.GetDesById(ETurkeyTextRes_NewSearch_SaveFile),*this,ECmdCopying);
				delete iCopiedFile;
				iCopiedFile = NULL;
			}
			//CleanupStack::PopAndDestroy();	//desFileName
		}
	}
}
示例#17
0
LOCAL_C TBool CompareLogsL()
	{
	TBool errorOccured = EFalse;

	CDesCArray* correctFile = new (ELeave) CDesCArrayFlat(1);
	CPtrCArray* resultFile = new (ELeave) CPtrCArray(1);

	TParse parsedFileName;
	TParse parsedResultFileName;
	TFileName name;
	name.Append(KOkFileNameEntryStructure);
	testUtils->ResolveFile(KComponent, name, parsedFileName);
	correctFile->AppendL(parsedFileName.FullName());
	name.Zero();
	name.Copy(KFileNameEntryStructure);
	testUtils->ResolveLogFile(name, parsedResultFileName);
	resultFile->AppendL(parsedResultFileName.FullName());

	RFileReadStream file1;
	RFileReadStream file2;
	HBufC8* line1Buffer = HBufC8::NewLC(1024);
	TPtr8 line1 = line1Buffer->Des();
	TBuf8<1> aChar1;

	HBufC8* line2Buffer = HBufC8::NewLC(1024);
	TPtr8 line2 = line2Buffer->Des();
	TBuf8<1> aChar2;

	for(TInt i=0; i<correctFile->MdcaCount(); i++)
		{
		TFileName file1Name = correctFile->MdcaPoint(i);

		TFileName file2Name = resultFile->MdcaPoint(i);

		TInt error1=KErrNone;
		TInt error2=KErrNone;
		
		test.Printf(_L("\n%s"), file2Name.PtrZ());

		error1=file1.Open(testUtils->FileSession(), file1Name, EFileShareAny);
		if(error1!=KErrNone)
			{
			errorOccured = ETrue;
			}
		else
			{
			error2=file2.Open(testUtils->FileSession(), file2Name, EFileShareAny);
			if(error2!=KErrNone)
				{
				errorOccured = ETrue;
				}
			}
		
		if((error1==KErrNone)&&(error2==KErrNone))
			{
			// read the file into the conversion object
			TBool finished = EFalse;
	
			do	{
				line1.FillZ();
				line1.SetLength(0);
				// compile the lines one char at a time
				do	{
					TRAPD( error, file1.ReadL(aChar1, 1) ); 
					if (error!=KErrEof)
						line1.Append(aChar1);
					else
						{
						finished = ETrue;
						break;
						}
					// stop at the end of line or no more data
					}
				while((aChar1[0]!=0x0A)&&(line1.Length()<1024));

				line2.FillZ();
				line2.SetLength(0);
				do	{
					TRAPD( error, file2.ReadL(aChar2, 1) ); 
					if (error!=KErrEof)
						line2.Append(aChar2);
					else
						{
						finished = ETrue;
						break;
						}
					// stop at the end of line or no more data
					}
				while((aChar2[0]!=0x0A)&&(line2.Length()<1024));
				
				// get rid of white space
				line1.TrimRight();
				line2.TrimRight();

   				if(line1.Compare(line2) != 0)
					{
					// error so no point in continuing to compare!!
					errorOccured = ETrue;
					file1.Close();
					file2.Close();
					delete correctFile;
					delete resultFile;
					CleanupStack::PopAndDestroy(2);  //line 1 , line 2
					return ETrue;
					}
				}
			while(!finished);
			}		

		file1.Close();
		file2.Close();
		}

	delete correctFile;
	delete resultFile;
	CleanupStack::PopAndDestroy(2);  //line 1 , line 2
	
	return errorOccured;
	}