TBool WidgetUnzipUtilityS60::RunUnzipL()
    {
    CZipFileMember* member = iMembers->NextL();
    if (member)
        {
        CleanupStack::PushL(member);
        RZipFileMemberReaderStream* stream;
        User::LeaveIfError(iZipFile->GetInputStreamL(member, stream));
        CleanupStack::PushL(stream);

        HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());
        TPtr8 bufferPtr(buffer->Des());
        User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));

        TFileName text;
        text.Copy(*iTempZipPath);
        text.Append(_L('\\'));
        text.Append(*member->Name());

        HBufC* zipedFileNameAndPath = text.AllocLC();

        TInt index = zipedFileNameAndPath->LocateReverse('\\');

        if (index >= 0)
            {
            TPtrC path = zipedFileNameAndPath->Left(index + 1);
            iFs.MkDirAll(path); // errors are ok
            }

        if (zipedFileNameAndPath->Right(1).Compare(_L('\\')) != 0)
            {
            RFile file;
            CleanupClosePushL(file);
            file.Replace(iFs,*zipedFileNameAndPath,EFileWrite);
            User::LeaveIfError(file.Write(*buffer));
            CleanupStack::PopAndDestroy(); // file
            }
        iUncompressedSize += member->UncompressedSize();
        CleanupStack::PopAndDestroy(4);
        return ETrue;
        }
    else
        {
        return EFalse;
        }
    }
Example #2
0
/** process the command-line, ; arguments appear in any order
 IN   : User::CommandLine()
 OUT  : iTestCasesIdentities
        iHelpRequested
 		gSemiAutomated
 		gVerboseOutput
 		gOpenIterations
 		gOOMIterations
 		gTestRoleMaster
 		gUSBVidPid
*/
void CTestEngine::ProcessCommandLineL()
	{
	// example t_otgdi.exe /ALL /G:0468 /VERBOSE
	TInt cmdLineLength(User::CommandLineLength());
	HBufC* cmdLine = HBufC::NewMaxLC(cmdLineLength);
	TPtr cmdLinePtr = cmdLine->Des();
	User::CommandLine(cmdLinePtr);
	TBool  tokenParsed(EFalse);

	TLex args(*cmdLine);
	args.SkipSpace(); // args are separated by spaces
	
	// first arg is the exe name, skip it
	TPtrC cmdToken = args.NextToken();
	HBufC* tc = HBufC::NewLC(KParameterTextLenMax);
	*tc = cmdToken;
	while (tc->Length())
		{
		tokenParsed = EFalse;
		
		// '/?' help wanted flag '?' or /? parameter
		TInt pos(0);
		if ((0== tc->FindF(_L("?"))) || (0==tc->FindF(_L("/?")))) 
			{
			iHelpRequested = ETrue;
			tokenParsed = ETrue;
			}	
		
		// '/ALL' parameter
		pos = tc->FindF(KArgAllTestCases);
		if (pos != KErrNotFound)
			{
			AddAllDefaultTests();
			tokenParsed = ETrue;
			}

		// '/AUTO'	
		pos = tc->FindF(KArgAutomatedTest);
		if (pos != KErrNotFound)
			{
			// skip some of the press-any key things
			test.Printf(_L("Test semi-automated mode.\n"));
			OstTrace0(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL, "Test semi-automated mode.\n");
			gSemiAutomated = ETrue;
			tokenParsed = ETrue;
			}

		// '/G:TESTNAME'
		pos = tc->FindF(KArgGoTestCase);
		if (pos != KErrNotFound)
			{ 
			HBufC* tcPart = HBufC::NewLC(KTestCaseIdLength);
			TPtrC testID = tc->Right(tc->Length() - pos - KArgGoTestCase().Length());

			LOG_VERBOSE2(_L("Parameter found:'%S'\n"), &testID);
			if(gVerboseOutput)
			    {
			    OstTraceExt1(TRACE_VERBOSE, CTESTENGINE_PROCESSCOMMANDLINEL_DUP01, "Parameter found:'%S'\n", testID);
			    }

			// Check if it is a test we know of in our suite, users may provide the full  
			// name "PBASE-USB_OTGDI-0466", or just the last 4 digits "0466", in such cases, fetch the full name
			if (!RTestFactory::TestCaseExists(testID))
				{ // try use just the test#part
				TPtr  tcDes = tcPart->Des();

				// build and add the full name
				tcDes.Format(KidFormatterS, &testID);
				if (!RTestFactory::TestCaseExists(tcDes))
					{
					
					test.Printf(_L("Test case does NOT Exist: '%lS'\n"), &testID);
					OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP02, "Test case does NOT Exist: '%lS'\n", testID);
					}
				else
					{ // only the number was supplied, copy the full name
					testID.Set(tcDes);
					}
				}
			// check that it's valid before adding it to the run-list
			if (RTestFactory::TestCaseExists(testID))
				{
				HBufC* testIdentity = HBufC::NewLC(KTestCaseIdLength);
				*testIdentity = testID;
				test.Printf(_L("Test case specified: %lS\n"), testIdentity);
				OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP03, "Test case specified: %lS\n", *testIdentity);

				iTestCasesIdentities.Append(testIdentity);
				CleanupStack::Pop(testIdentity);
				}
			CleanupStack::PopAndDestroy(tcPart);
			tokenParsed = ETrue;
			}
			
		// '/VERBOSE' option	
		pos = tc->FindF(KArgVerboseOutput);
		if (pos != KErrNotFound)
			{ 
			gVerboseOutput = ETrue;
			tokenParsed = ETrue;
			
			// turn on logging of test Printf() output to serial debug/log at the same time
			test.SetLogged(ETrue);
			
			}

		// '/LOOPO:n' option (Set #times to run open/close tests amongst others)
		pos = tc->FindF(KArgSetOpenIterations);
		if (pos != KErrNotFound)
			{ 
			TPtrC iterationStr = tc->Right(tc->Length() - pos - KArgSetOpenIterations().Length());
			TLex  lex(iterationStr);
			lex.Val(gOpenIterations);
			MINMAX_CLAMPVALUE(gOpenIterations, OPEN_MINREPEATS, OPEN_MAXREPEATS);
			tokenParsed = ETrue;
			}

		// '/LOOPM:n' option (Set # of allocs to start at for OOM test)
		pos = tc->FindF(KArgSetOOMIterations);
		if (pos != KErrNotFound)
			{ 
			TPtrC iterationStr = tc->Right(tc->Length() - pos - KArgSetOOMIterations().Length());
			TLex  lex(iterationStr);
			lex.Val(gOOMIterations);
			MINMAX_CLAMPVALUE(gOOMIterations, OOM_MINREPEATS, OOM_MAXREPEATS);
			tokenParsed = ETrue;
			}
		
		
		// '/VID:nnnn' option (Set Symbian or other VID-Pid example /VID:0670)
		pos = tc->FindF(KArgOverrideVidPid);
		if (pos != KErrNotFound)
			{ 
			TPtrC vidpidStr = tc->Right(tc->Length() - pos - KArgOverrideVidPid().Length());
			TUint16 prodID;
			TLex  lex(vidpidStr);
			
			if (KErrNone == lex.Val(prodID, EHex))
				{
				if (prodID> 0xFFFF)
					prodID = 0xFFFF;
				tokenParsed = ETrue;
				LOG_VERBOSE2(_L(" accept param %04X \n\n"), prodID);
				if(gVerboseOutput)
				    {
				    OstTrace1(TRACE_VERBOSE, CTESTENGINE_PROCESSCOMMANDLINEL_DUP05, " accept param %04X \n\n", prodID);
				    }
				gUSBVidPid = prodID; // replace the vid-pid with the user-supplied one 
				}
			else
				{
				// print error
				test.Printf(_L("Warning: VID+PID '%lS' not parsed .\n"), tc);
				OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP06, "Warning: VID+PID '%lS' not parsed .\n", *tc);
				}
			}
		
		// '/SLAVE' (peer)
		pos = tc->FindF(KArgSetRoleSlave);
		if (pos != KErrNotFound)
			{ 
			gTestRoleMaster = EFalse;
			tokenParsed = ETrue;
			}
		// '/MASTER' - default role
		pos = tc->FindF(KArgSetRoleMaster); // note that master is the default role, so this parameter is optional
		if (pos != KErrNotFound)
			{ 
			gTestRoleMaster = ETrue;
			tokenParsed = ETrue;
			}		
		
		if (!tokenParsed)
			{
			// warn about unparsed parameter
			test.Printf(_L("Warning: '%lS'??? not parsed\n"), tc);
			OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP07, "Warning: '%lS'??? not parsed\n", *tc);
			iHelpRequested = ETrue;
			}
			
		// next parameter
		*tc = args.NextToken();
		}
	CleanupStack::PopAndDestroy(tc);
	CleanupStack::PopAndDestroy(cmdLine);
	}