コード例 #1
0
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
    }
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;
}
コード例 #3
0
ファイル: server.cpp プロジェクト: Seikareikou/symbian
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);
    }
コード例 #4
0
// EPOC default constructor can leave.
void CPosResourceReader::ConstructL(const TDesC& aPath)
    {
    User::LeaveIfError(iFileSession.Connect());

    TFindFile* filefinder = new (ELeave) TFindFile(iFileSession);
    CleanupStack::PushL(filefinder);

    TParse* fileparser = new (ELeave) TParse;
    CleanupStack::PushL(fileparser);
    fileparser->Set(aPath, NULL, NULL);

    User::LeaveIfError(filefinder->FindByDir(fileparser->NameAndExt(),
        fileparser->DriveAndPath()));
    
    iResourceFile.OpenL(iFileSession, filefinder->File());
    iResourceFile.ConfirmSignatureL(0);
    
    CleanupStack::Pop(2, filefinder); // fileparser
    delete filefinder;
    delete fileparser;
    }
コード例 #5
0
void CSmilTranslatorTestUtils::RunTestL()
	{
	TRequestStatus *s = &iStatus;

	// used to generate a leave if an out of memory error was encountered, specifically
	// during the memory test loop in E32Main().  This is necessary because leaves in
	// the .dll Active Object RunL() functions do not return to this application, so
	// have to be Trapped in the Active objects and translated into an error code.
	TBool memoryError = EFalse;

	switch(iState)
		{
	case KInit:
		{
		// Utility class for file manipulation
		iFileFinder = new TFindFile(iSession);

		TPtrC errorFileName(KErrorFileName);

		// create err dir if doesn't exist - this api ignores the file name (ignores everything after final '/')
		fileSystem.MkDirAll(KErrorFileName);

		// overwrite any existing file of this name
		iErr = iErrorFile.Replace(iSession, errorFileName, EFileWrite | EFileStreamText);

		if(iErr == KErrNone)
			{
			TBuf<1> bom;
			bom.Append(CEditableText::EByteOrderMark);
			iErrorFile.Write(DES_AS_8_BIT(bom));
			// will search multiple directories, but halt after completing current directory
			// if at least one match is made.  Remembers which directories have been searched
			// in order to continue search using .FindWild() function later
			iErr = iFileFinder->FindWildByPath(KWildName, &KInputPathList, iFileList);
			iIndex = 0;
			}

		if(iErr == KErrNone)
			{
			iState = KParseFile;
			}
		else
			{
			iState = KEnd;
			}
		User::RequestComplete(s, KErrNone);
		SetActive();
		}
		break;

	case KParseFile:
		{
		++iFilesProcessed;
		iErr = KErrNone;

		TParse fullEntry;
		fullEntry.Set((*iFileList)[iIndex++].iName,& iFileFinder->File(),NULL);
		iInputFileName = fullEntry.FullName(); // extract individual path + name from list
		SetOutputFileName(); // output name is based on input one

		iOutputMsg = KStartFile;
		iOutputMsg.Append(iInputFileName);		// display full path
		test.Start(iOutputMsg);				// print to console

		// test console automatically places output on a new line, for output
		// to error file we need to add white space ready for next line
		iOutputMsg.Append(KOutputNewLine);
		iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));	// print to error file

		// schedule Parser active object for call to it's RunL function
		if (testConfig->DataMode() == CTestConfig::EBufferData)
			{
			// We're testing the buffering API...
			// Create a data supplier object and pass it in to the parser
			delete iDataSupplier;
			iDataSupplier = NULL;
			iDataSupplier = CTestDataSupplier::NewL(iSession, iInputFileName);
			iParser->ParseSource(iDataSupplier);
			}
		else
			{
			if( iUseFileHandle )
				{
				RFile file;
				User::LeaveIfError(file.Open(iSession, iInputFileName, EFileRead | EFileShareReadersOnly));
			// 	No function declaration of ParseFile() that take RFile Object parameter
			//	iParser->ParseFile(file);
				iParser->ParseFile(iSession, iInputFileName);
				}
			else
				{
				// We're testing the file mode so parse the file.
				iParser->ParseFile(iSession, iInputFileName);
				}
			}

		iState = KCheckResults;
		iStatus = KRequestPending;
		SetActive();
		}
		break;

	case KCheckResults:
		{
		// when execution begins again one parse followed by a compose would have
		// completed for the current file, handle any error messages generated here
		iErr = iParser->Error();
		TInt severity = iParser->ErrorSeverity();
		if(iErr != KErrNone)
			{
			iOutputMsg = KParseError;
			AppendErrorStr(iErr, iOutputMsg);
			AppendSeverityStr(severity, iOutputMsg);
			iOutputMsg.Append(KOutputNewLine);
			
			// IF there are no more errors for this file bung in an
			// extra line to make output more prominent
			if(iComposer->Error() == KErrNone)
				{
				iOutputMsg.Append(KOutputNewLine);
				}
			test.Printf(iOutputMsg);						// print to console
			iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));	// print to error file
			
			if(iErr == KErrNoMemory)
				{
				memoryError = ETrue;
				}
			}

		iErr = iComposer->Error();
		severity = iComposer->ErrorSeverity();
		if(iErr != KErrNone)
			{
			iOutputMsg = KComposeError;
			AppendErrorStr(iErr, iOutputMsg);
			AppendSeverityStr(severity, iOutputMsg);
			iOutputMsg.Append(KOutputNewLine);
			iOutputMsg.Append(KOutputNewLine);								
			test.Printf(iOutputMsg);
			iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));
			
			if(iErr == KErrNoMemory)
				{
				memoryError = ETrue;
				}
			}

		test.End();

		// if the OOM condition occured during Parsing or Composing
		if(memoryError)
			{
			User::Leave(KErrNoMemory);
			}

		iState = KParseFile;

		if(iIndex >= iFileList->Count())
			{
			// fileList must be deleted after each loop prior to being passed
			// back to fileFinder (unnecessary after KErrNotFound)
			delete iFileList;
			iFileList = 0; // Just in case it doesn't get set in the FindWild

			// continue wildcard search for next directory in list
			iErr = iFileFinder->FindWild(iFileList);
			iIndex = 0;
			if(iErr != KErrNone)
				iState = KEnd;
			}

		SetActive();
		User::RequestComplete(s, KErrNone);
		}
		break;

	default:
	case KEnd:
		{
		TTime endTime;
		TTimeIntervalSeconds interval;
		endTime.UniversalTime();
		endTime.SecondsFrom(iStartTime, interval);

		TBuf<100> time;
		_LIT(KComposeTime, "Total time for composing: %d microseconds\n");
		time.Format(KComposeTime, iComposeTime);
		iErrorFile.Write(DES_AS_8_BIT(time));

		_LIT(KTimeTaken, "Total time for tests: %d seconds");
		time.Format(KTimeTaken, interval.Int());
		iErrorFile.Write(DES_AS_8_BIT(time));


		delete iFileFinder;
		delete iDataSupplier;
		CActiveScheduler::Stop();
		}
		break;
		}
	}