userlibandfileserver/fileserver/etshell/ts_edshl.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
--- a/userlibandfileserver/fileserver/etshell/ts_edshl.cpp	Tue Aug 31 16:34:26 2010 +0300
+++ b/userlibandfileserver/fileserver/etshell/ts_edshl.cpp	Wed Sep 01 12:34:56 2010 +0100
@@ -532,6 +532,17 @@
 		}
 	}
 
+
+//-------------------------------------------------------------------------
+//-- generic shell commands that don't require sophisticated processing
+
+_LIT(KCmd_Help, "HELP");    ///< displays help
+_LIT(KCmd_Cls,  "CLS");     ///< clears the screen
+_LIT(KCmd_Rem,  "REM");     ///< *.bat processing - commented out line
+_LIT(KCmd_Break,"BREAK");   ///< stops *.bat file execution
+_LIT(KCmd_Exit, "EXIT");    ///< exit the shell
+
+//-------------------------------------------------------------------------
 //////////////////////////////////////
 //CShell
 //////////////////////////////////////
@@ -728,7 +739,7 @@
 				tabCount = 0;
 				
 #if !defined(_EPOC)
-				if(commandText.CompareF(_L("EXIT")) == 0)
+				if(commandText.CompareF(KCmd_Exit) == 0)
 					{
 					exit = ETrue;
 					break;
@@ -816,6 +827,10 @@
 	CleanupStack::PopAndDestroy(fileManObserver);
 	}
 
+
+
+//-------------------------------------------------------------------------
+
 void CShell::DoCommand(TDes& aCommand)
 //
 // Evaluate the commandline and run the command or file
@@ -884,10 +899,13 @@
 		{
 		TInt r;
 		
-		if (aCommand.CompareF(_L("HELP"))==0)
+		if (aCommand.CompareF(KCmd_Help)==0)
 			PrintHelp();
-		else if (aCommand.CompareF(_L("CLS"))==0)
+		else if (aCommand.CompareF(KCmd_Cls)==0)
 			TheConsole->ClearScreen(); 
+		else if (aCommand.CompareF(KCmd_Break)==0)
+			{//-- "break" command, do nothing
+            }
 		else if (aCommand.Length()==2 && TChar(aCommand[0]).IsAlpha() && aCommand[1]==':')
 			ChangeDrive(aCommand[0]);
 		else if (aCommand.Length()!=0)
@@ -1063,10 +1081,17 @@
 			else 
 			PrintError(KErrNotFound);
 			}
-			
-		else if (readBuf.Length()<3 || readBuf.Left(3).CompareF(_L("REM"))!=0)
+		else if (readBuf.Length()<3 || readBuf.Left(3).CompareF(KCmd_Rem)!=0)
+            {
+			//-- check if it is a "break" command. stop execution in this case
+            if(readBuf.CompareF(KCmd_Break) ==0)
+                break; //-- terminate batch file execution        
+            else
 			DoCommand(readBuf);
 		}
+		}
+	
+    
 	file.Close();
 	return KErrNone;
 	}
@@ -1218,7 +1243,7 @@
 	drivePaths[drvNum]=aDrivePath;
 	}
 
-
+//----------------------------------------------------------------------
 TKeyCode CShell::OutputStringToConsole(TBool aPageSwitch,TRefByValue<const TDesC> aFmt,... )
 //function for output of a sring to console
 //aPageSwitch flag indicates that output should be page-by-page 
@@ -1239,6 +1264,7 @@
 	return OutputStringToConsole(KPrompt,aPageSwitch,_L("%S"),&aBuf);
 	}
 
+//----------------------------------------------------------------------
 TKeyCode CShell::OutputStringToConsole(const TDesC& aNotification,TBool aPageSwitch,TRefByValue<const TDesC> aFmt,...)
 	//function for output of a string to console aPageSwitch flag indicates that output should be page-by-page 
 	//if aPageSwitch==ETrue user will be prompted with the message passed as aNotification
@@ -1251,10 +1277,8 @@
 	
 	VA_LIST list;
 	VA_START(list,aFmt);
-	
 	TBuf<0x200> aBuf;
 	//format output string using argumen list
-	
 	//coverity[uninit_use_in_call]
 	TRAP_IGNORE(aBuf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow()
 	//if we are requested to wait for the user input at the end of each page, we check whether output of next piece of text will fit into the screen
@@ -1263,27 +1287,36 @@
 		key=PageSwitchDisplay(aNotification);				
 		}
 	//output current string
-	TheConsole->Write(aBuf);
+	
+	Print(aBuf);
+    
 	return key;			
 	}
 
-TKeyCode CShell::OutputStringToConsole(TBool aPageSwitch, const TDesC& aBuf)
+//----------------------------------------------------------------------
+TKeyCode CShell::WriteBufToConsole(TBool aPageSwitch, const TDesC& aBuf)
 	{
 	_LIT(KPrompt , "Press any key to continue\n");
+    return WriteBufToConsole(aPageSwitch, aBuf, KPrompt);
+	}
 	
+//----------------------------------------------------------------------
+TKeyCode CShell::WriteBufToConsole(TBool aPageSwitch, const TDesC& aBuf, const TDesC& aNotification)
+    {
     TKeyCode key=EKeyNull;	
 
 	//if we are requested to wait for the user input at the end of each page, we check whether output of next piece of text will fit into the screen
 	if (aPageSwitch)
 		{
-		key = PageSwitchDisplay(KPrompt);				
+		key = PageSwitchDisplay(aNotification);				
 		}
-	//output current string
-	TheConsole->Write(aBuf);
+
+    Print(aBuf);
 	
     return key;
 	}
 
+
 TKeyCode CShell::PageSwitchDisplay(const TDesC& aNotification)
 	{
 	//create variable to store code of the key pressed by the user
@@ -1313,3 +1346,9 @@
 		}						
 	return key;			
 	}
+
+
+
+
+
+