testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/tefutilities/platsec/cleanup/src/cleanup.cpp
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * Plattest_Platsec_Cleanup.exe
       
    16 * Deletes the file specified in the command line. 
       
    17 * Command Line Syntax:
       
    18 * Plattest_Platsec_Cleanup.exe <Filename>
       
    19 * <Filename> can be with path or without path. If path is not
       
    20 * specified, the default path of c:\sys\bin\ will be taken.
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  @file cleanup.cpp
       
    28 */
       
    29 
       
    30 
       
    31 //Epoc include
       
    32 #include <f32file.h>
       
    33 #include <f32image.h>
       
    34 #include <wrapperutilsplugin.h>
       
    35 #include <test/tefutils.h>
       
    36 
       
    37 TParse FileName;
       
    38 
       
    39 _LIT(KDefaultExePath,"?:\\sys\\bin\\");
       
    40 
       
    41 /**
       
    42  Parses the Command Line arguments
       
    43  @return TInt - KErrNone if no error else, system wide error codes
       
    44 */
       
    45 TInt ParseCommandLine()
       
    46       {
       
    47 	TDriveName defaultSysDrive(_L("C:"));
       
    48 	RFs fileServer;
       
    49 	TVersionName version(fileServer.Version().Name());
       
    50 	
       
    51 	RLibrary pluginLibrary;
       
    52 	CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary);
       
    53 	
       
    54 	if (plugin!=NULL)
       
    55 		{
       
    56 		TDriveUnit driveUnit(plugin->GetSystemDrive());
       
    57 		defaultSysDrive.Copy(driveUnit.Name());
       
    58 		delete plugin;
       
    59 		pluginLibrary.Close();
       
    60 		}
       
    61 
       
    62 	  TBuf<256> c;
       
    63       
       
    64       User::CommandLine(c);
       
    65 
       
    66       TLex l(c);
       
    67 
       
    68 	  TFileName defaultExePath(KDefaultExePath);
       
    69 	  defaultExePath.Replace(0, 2, defaultSysDrive);
       
    70 
       
    71       if(FileName.SetNoWild(l.NextToken(),0,&defaultExePath)!=KErrNone)
       
    72             return KErrArgument;
       
    73 
       
    74       // Check we used all the arguments
       
    75       if (l.NextToken() != KNullDesC)
       
    76             return KErrArgument;
       
    77 
       
    78       return KErrNone;
       
    79       }
       
    80 
       
    81 
       
    82 TInt E32Main()
       
    83 	{
       
    84 	TInt r;
       
    85 
       
    86 	//Parses the command line
       
    87 	r = ParseCommandLine();
       
    88 	if(r!=KErrNone)
       
    89 		return r;
       
    90 
       
    91 	//Connects with FileServer
       
    92 	RFs Fs;
       
    93 	r = Fs.Connect();
       
    94 	if(r!=KErrNone)
       
    95 		return r;
       
    96 
       
    97 	//Deletes the File specified
       
    98 	r= Fs.Delete(FileName.FullName());
       
    99 	if(r != KErrNone)
       
   100 		return r;
       
   101 
       
   102 	//Closes the sesssion with FileServer
       
   103 	Fs.Close();
       
   104 
       
   105 	return r;
       
   106 	}