os/persistentdata/featuremgmt/featuremgr/test/helper/pluginhelper/src/pluginhelper.cpp
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
25 #include <e32def_private.h>
27 void CopyFileL(const TDesC& aSourceFile, const TDesC& aDestFile)
31 CleanupClosePushL(fs);
32 fs.MkDirAll(aDestFile);
33 CFileMan* fileMan = CFileMan::NewL( fs );
34 // Copy feature file to file manager private data cage.
35 //Ignore any errors as the file or path may not exist
36 fileMan->Copy(aSourceFile, aDestFile);
37 CleanupStack::PopAndDestroy(&fs);
40 void DeleteFileL(const TDesC& aFile)
44 CleanupClosePushL(fs);
45 fs.SetAtt(aFile, 0, KEntryAttReadOnly);
46 //Ignore any errors as the file or path may not exist
48 CleanupStack::PopAndDestroy(&fs);
52 TInt CheckFile(const TDesC& aFile)
57 TInt err = file.Open(fs,aFile,EFileRead);
58 if (err!=KErrNotFound)
71 TInt ParseSwitch(const TDesC& aSwitch, const TDesC& aFile)
74 return CheckFile(aFile);
76 return KErrNotSupported;
81 HBufC* cmdLine = HBufC::NewL(User::CommandLineLength());
82 CleanupStack::PushL(cmdLine);
84 TPtr cmdLinePtr(cmdLine->Des());
85 User::CommandLine(cmdLinePtr);
87 const TInt KMaxNumTokens = 2;
88 TPtrC tokens[KMaxNumTokens];
91 for (i = 0; !lex.Eos() && i < KMaxNumTokens; i++)
93 tokens[i].Set(lex.NextToken());
99 DeleteFileL(tokens[0]);
104 if (tokens[0][0]=='-')
106 User::LeaveIfError(ParseSwitch(tokens[0].Right(tokens[0].Length()-1),tokens[1]));
110 CopyFileL(tokens[0],tokens[1]);
114 CleanupStack::PopAndDestroy(cmdLine);
119 CTrapCleanup* cleanup = CTrapCleanup::New();
121 TRAPD(err, ::DoMainL());