530 TRAP_IGNORE(iHistory->InsertL(0, pB)); |
530 TRAP_IGNORE(iHistory->InsertL(0, pB)); |
531 } |
531 } |
532 } |
532 } |
533 } |
533 } |
534 |
534 |
535 |
|
536 //------------------------------------------------------------------------- |
|
537 //-- generic shell commands that don't require sophisticated processing |
|
538 |
|
539 _LIT(KCmd_Help, "HELP"); ///< displays help |
|
540 _LIT(KCmd_Cls, "CLS"); ///< clears the screen |
|
541 _LIT(KCmd_Rem, "REM"); ///< *.bat processing - commented out line |
|
542 _LIT(KCmd_Break,"BREAK"); ///< stops *.bat file execution |
|
543 _LIT(KCmd_Exit, "EXIT"); ///< exit the shell |
|
544 |
|
545 //------------------------------------------------------------------------- |
|
546 ////////////////////////////////////// |
535 ////////////////////////////////////// |
547 //CShell |
536 //CShell |
548 ////////////////////////////////////// |
537 ////////////////////////////////////// |
549 TShellCommand::TShellCommand(const TDesC& aName,const TDesC& aHelp,const TDesC& aHelpDetail,TUint aSwitches,TInt (*aFunction)(TDes&,TUint)) |
538 TShellCommand::TShellCommand(const TDesC& aName,const TDesC& aHelp,const TDesC& aHelpDetail,TUint aSwitches,TInt (*aFunction)(TDes&,TUint)) |
550 :iName(aName), |
539 :iName(aName), |
897 } |
882 } |
898 else //Generic commands |
883 else //Generic commands |
899 { |
884 { |
900 TInt r; |
885 TInt r; |
901 |
886 |
902 if (aCommand.CompareF(KCmd_Help)==0) |
887 if (aCommand.CompareF(_L("HELP"))==0) |
903 PrintHelp(); |
888 PrintHelp(); |
904 else if (aCommand.CompareF(KCmd_Cls)==0) |
889 else if (aCommand.CompareF(_L("CLS"))==0) |
905 TheConsole->ClearScreen(); |
890 TheConsole->ClearScreen(); |
906 else if (aCommand.CompareF(KCmd_Break)==0) |
|
907 {//-- "break" command, do nothing |
|
908 } |
|
909 else if (aCommand.Length()==2 && TChar(aCommand[0]).IsAlpha() && aCommand[1]==':') |
891 else if (aCommand.Length()==2 && TChar(aCommand[0]).IsAlpha() && aCommand[1]==':') |
910 ChangeDrive(aCommand[0]); |
892 ChangeDrive(aCommand[0]); |
911 else if (aCommand.Length()!=0) |
893 else if (aCommand.Length()!=0) |
912 { |
894 { |
913 r=RunBatch(aCommand); |
895 r=RunBatch(aCommand); |
1241 TInt drvNum; |
1216 TInt drvNum; |
1242 __ASSERT_ALWAYS(charToDrive(drvLetter,drvNum)==KErrNone,User::Panic(_L("Invalid drive letter"),0)); |
1217 __ASSERT_ALWAYS(charToDrive(drvLetter,drvNum)==KErrNone,User::Panic(_L("Invalid drive letter"),0)); |
1243 drivePaths[drvNum]=aDrivePath; |
1218 drivePaths[drvNum]=aDrivePath; |
1244 } |
1219 } |
1245 |
1220 |
1246 //---------------------------------------------------------------------- |
1221 |
1247 TKeyCode CShell::OutputStringToConsole(TBool aPageSwitch,TRefByValue<const TDesC> aFmt,... ) |
1222 TKeyCode CShell::OutputStringToConsole(TBool aPageSwitch,TRefByValue<const TDesC> aFmt,... ) |
1248 //function for output of a sring to console |
1223 //function for output of a sring to console |
1249 //aPageSwitch flag indicates that output should be page-by-page |
1224 //aPageSwitch flag indicates that output should be page-by-page |
1250 { |
1225 { |
1251 //create an object to truncate argument list substitution |
1226 //create an object to truncate argument list substitution |
1262 _LIT(KPrompt , "Press any key to continue\n"); |
1237 _LIT(KPrompt , "Press any key to continue\n"); |
1263 |
1238 |
1264 return OutputStringToConsole(KPrompt,aPageSwitch,_L("%S"),&aBuf); |
1239 return OutputStringToConsole(KPrompt,aPageSwitch,_L("%S"),&aBuf); |
1265 } |
1240 } |
1266 |
1241 |
1267 //---------------------------------------------------------------------- |
|
1268 TKeyCode CShell::OutputStringToConsole(const TDesC& aNotification,TBool aPageSwitch,TRefByValue<const TDesC> aFmt,...) |
1242 TKeyCode CShell::OutputStringToConsole(const TDesC& aNotification,TBool aPageSwitch,TRefByValue<const TDesC> aFmt,...) |
1269 //function for output of a string to console aPageSwitch flag indicates that output should be page-by-page |
1243 //function for output of a string to console aPageSwitch flag indicates that output should be page-by-page |
1270 //if aPageSwitch==ETrue user will be prompted with the message passed as aNotification |
1244 //if aPageSwitch==ETrue user will be prompted with the message passed as aNotification |
1271 //code of key pressed will be returned as a return value |
1245 //code of key pressed will be returned as a return value |
1272 { |
1246 { |
1275 //create an object to truncate argument list substitution |
1249 //create an object to truncate argument list substitution |
1276 SimpleOverflowTruncate overflow; |
1250 SimpleOverflowTruncate overflow; |
1277 |
1251 |
1278 VA_LIST list; |
1252 VA_LIST list; |
1279 VA_START(list,aFmt); |
1253 VA_START(list,aFmt); |
|
1254 |
1280 TBuf<0x200> aBuf; |
1255 TBuf<0x200> aBuf; |
1281 //format output string using argumen list |
1256 //format output string using argumen list |
|
1257 |
1282 //coverity[uninit_use_in_call] |
1258 //coverity[uninit_use_in_call] |
1283 TRAP_IGNORE(aBuf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow() |
1259 TRAP_IGNORE(aBuf.AppendFormatList(aFmt,list,&overflow)); // ignore leave in TTimeOverflowLeave::Overflow() |
1284 //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 |
1260 //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 |
1285 if (aPageSwitch) |
1261 if (aPageSwitch) |
1286 { |
1262 { |
1287 key=PageSwitchDisplay(aNotification); |
1263 key=PageSwitchDisplay(aNotification); |
1288 } |
1264 } |
1289 //output current string |
1265 //output current string |
1290 |
1266 TheConsole->Write(aBuf); |
1291 Print(aBuf); |
|
1292 |
|
1293 return key; |
1267 return key; |
1294 } |
1268 } |
1295 |
1269 |
1296 //---------------------------------------------------------------------- |
1270 TKeyCode CShell::OutputStringToConsole(TBool aPageSwitch, const TDesC& aBuf) |
1297 TKeyCode CShell::WriteBufToConsole(TBool aPageSwitch, const TDesC& aBuf) |
|
1298 { |
1271 { |
1299 _LIT(KPrompt , "Press any key to continue\n"); |
1272 _LIT(KPrompt , "Press any key to continue\n"); |
1300 return WriteBufToConsole(aPageSwitch, aBuf, KPrompt); |
1273 |
1301 } |
|
1302 |
|
1303 //---------------------------------------------------------------------- |
|
1304 TKeyCode CShell::WriteBufToConsole(TBool aPageSwitch, const TDesC& aBuf, const TDesC& aNotification) |
|
1305 { |
|
1306 TKeyCode key=EKeyNull; |
1274 TKeyCode key=EKeyNull; |
1307 |
1275 |
1308 //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 |
1276 //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 |
1309 if (aPageSwitch) |
1277 if (aPageSwitch) |
1310 { |
1278 { |
1311 key = PageSwitchDisplay(aNotification); |
1279 key = PageSwitchDisplay(KPrompt); |
1312 } |
1280 } |
1313 |
1281 //output current string |
1314 Print(aBuf); |
1282 TheConsole->Write(aBuf); |
1315 |
1283 |
1316 return key; |
1284 return key; |
1317 } |
1285 } |
1318 |
|
1319 |
1286 |
1320 TKeyCode CShell::PageSwitchDisplay(const TDesC& aNotification) |
1287 TKeyCode CShell::PageSwitchDisplay(const TDesC& aNotification) |
1321 { |
1288 { |
1322 //create variable to store code of the key pressed by the user |
1289 //create variable to store code of the key pressed by the user |
1323 TKeyCode key=EKeyNull; |
1290 TKeyCode key=EKeyNull; |