userlibandfileserver/fileserver/etshell/ts_com.cpp
branchRCL_3
changeset 294 039a3e647356
parent 257 3e88ff8f41d5
equal deleted inserted replaced
268:345b1ca54e88 294:039a3e647356
    29 #include "u32std.h"
    29 #include "u32std.h"
    30 #include <u32hal.h>
    30 #include <u32hal.h>
    31 #include <nkern/nk_trace.h>
    31 #include <nkern/nk_trace.h>
    32 #include "filesystem_fat.h"
    32 #include "filesystem_fat.h"
    33 
    33 
    34 _LIT(KCrNl, "\r\n");
       
    35 _LIT(KNl, "\n");
       
    36 
       
    37     TPtrC ptrFormatHelp=_L("Drive:[\\] [fat12|fat16|fat32] [spc:X] [rs:Y] [ft:Z] [/Q][/S][/E][/F]\nfat12 or fat16 or fat32 specifies explicit FAT type\nspc:X specifies \"X\" sectors per cluster\nrs:Y specifies \"Y\" reserved sectors\nft:Z specifies \"Z\" FAT tables (1 or 2)\n\n/q - QuickFormat, /s - SpecialFormat, /e - ForcedErase\n/f - force formatting (ignore volume being in use)");
    34     TPtrC ptrFormatHelp=_L("Drive:[\\] [fat12|fat16|fat32] [spc:X] [rs:Y] [ft:Z] [/Q][/S][/E][/F]\nfat12 or fat16 or fat32 specifies explicit FAT type\nspc:X specifies \"X\" sectors per cluster\nrs:Y specifies \"Y\" reserved sectors\nft:Z specifies \"Z\" FAT tables (1 or 2)\n\n/q - QuickFormat, /s - SpecialFormat, /e - ForcedErase\n/f - force formatting (ignore volume being in use)");
    38 TPtrC ptrMountHelp=_L("Drive:[\\]  <fsy:X> <fs:Y> [pext:Z] [/S][/U][/F][/R]\n'X' *.fsy module name, like elocal.fsy\n'Y' file system name, like 'FAT'\n'Z' optional primary extension module name\n/U - dismount FS from the drive e.g 'mount d: /u' \n/U /F force dismounting the FS even if there are opened files on it \n/F - force mounting with dismounting existing FS \n/S - mount drive as synchronous\n/R - remount the file system ");
    35     TPtrC ptrMountHelp=_L("Drive:[\\]  <fsy:X> <fs:Y> [pext:Z] [/S][/U][/F][/R]\n'X' *.fsy module name, like elocal.fsy\n'Y' file system name, like 'FAT'\n'Z' optional primary extension module name\n/U - dismount FS from the drive e.g 'mount d: /u' \n/F - force mounting with dismounting existing FS \n/S - mount drive as synchronous\n/R - remount the file system ");
    39 
    36 
    40 TBool CShell::iDbgPrint = EFalse;
       
    41 
    37 
    42 //	lint -e40,e30
    38 //	lint -e40,e30
    43 const TShellCommand CShell::iCommand[ENoShellCommands]=
    39 const TShellCommand CShell::iCommand[ENoShellCommands]=
    44 	{
    40 	{
       
    41 //	TShellCommand(_L("BLANK"),_L("Help"),_L("-?"),TShellCommand::EDSwitch,ShellFunction::BLANK),
    45 	TShellCommand(_L("ATTRIB"),_L("Displays or changes file attributes"),_L("[drive:][path][filename] [+R | -R] [+H |-H] [+S | -S] [+A | -A] [/p]\n\n  /p - Pause after each screen of information"), TShellCommand::EPSwitch, ShellFunction::Attrib),
    42 	TShellCommand(_L("ATTRIB"),_L("Displays or changes file attributes"),_L("[drive:][path][filename] [+R | -R] [+H |-H] [+S | -S] [+A | -A] [/p]\n\n  /p - Pause after each screen of information"), TShellCommand::EPSwitch, ShellFunction::Attrib),
    46 	TShellCommand(_L("CD"),_L("Change the current directory for a drive"),_L("[path] [/d]\n\n  /d - Change drive"),TShellCommand::EDSwitch,ShellFunction::Cd),
    43 	TShellCommand(_L("CD"),_L("Change the current directory for a drive"),_L("[path] [/d]\n\n  /d - Change drive"),TShellCommand::EDSwitch,ShellFunction::Cd),
    47 	TShellCommand(_L("CHKDEPS"),_L("Check the dependencies of an executable or a Dll (ARM only)"),_L("[Filename.EXE] or [Filename.DLL]"),0,ShellFunction::ChkDeps),
    44 	TShellCommand(_L("CHKDEPS"),_L("Check the dependencies of an executable or a Dll (ARM only)"),_L("[Filename.EXE] or [Filename.DLL]"),0,ShellFunction::ChkDeps),
    48 	TShellCommand(_L("CHKDSK"),_L("Check disk for corruption"),_L("[drive:] [/s][/f|/u]\n\n/s - start ScanDrive instead of CheckDisk\n/f - finalise drive\n/u - unfinalise drive"),TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::EUSwitch,ShellFunction::ChkDsk),
    45 	TShellCommand(_L("CHKDSK"),_L("Check disk for corruption"),_L("[drive:] [/s][/f|/u]\n\n/s - start ScanDrive instead of CheckDisk\n/f - finalise drive\n/u - unfinalise drive"),TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::EUSwitch,ShellFunction::ChkDsk),
    49 	TShellCommand(_L("COPY"),_L("Copy one (or more) file(s), overwriting existing one(s)"),_L("source [destination]"),TShellCommand::ESSwitch,ShellFunction::Copy),
    46 	TShellCommand(_L("COPY"),_L("Copy one (or more) file(s), overwriting existing one(s)"),_L("source [destination]"),TShellCommand::ESSwitch,ShellFunction::Copy),
    50 	TShellCommand(_L("DEL"),_L("Delete one file"),_L("[drive:][path][filename]"),TShellCommand::ESSwitch,ShellFunction::Del),
    47 	TShellCommand(_L("DEL"),_L("Delete one file"),_L("[drive:][path][filename]"),TShellCommand::ESSwitch,ShellFunction::Del),
    51 	TShellCommand(_L("DIR"),_L("Show directory contents"),_L("[drive:][path][filename] [/p][/w]\n\n  /p - Pause after each screen of information\n  /w - Wide format"),TShellCommand::EPSwitch|TShellCommand::EWSwitch|TShellCommand::EASwitch,ShellFunction::Dir),
    48 	TShellCommand(_L("DIR"),_L("Show directory contents"),_L("[drive:][path][filename] [/p][/w]\n\n  /p - Pause after each screen of information\n  /w - Wide format"),TShellCommand::EPSwitch|TShellCommand::EWSwitch|TShellCommand::EASwitch,ShellFunction::Dir),
       
    49 //	TShellCommand(_L("EDLIN"),_L("Edit a text file"),_L("[drive:][path][filename] [/p]\n\n  /p - Pause after each screen of information"),TShellCommand::EPSwitch,ShellFunction::Edit),
    52     TShellCommand(_L("FORMAT"),_L("Format a disk"),ptrFormatHelp,TShellCommand::EQSwitch|TShellCommand::ESSwitch|TShellCommand::EESwitch|TShellCommand::EFSwitch,ShellFunction::Format),
    50     TShellCommand(_L("FORMAT"),_L("Format a disk"),ptrFormatHelp,TShellCommand::EQSwitch|TShellCommand::ESSwitch|TShellCommand::EESwitch|TShellCommand::EFSwitch,ShellFunction::Format),
    53     TShellCommand(_L("GOBBLE"),_L("Create a file"),_L("[filename] size [/e]\n\n /e - create an empty file, without writing any data"),TShellCommand::EESwitch,ShellFunction::Gobble),
    51     TShellCommand(_L("GOBBLE"),_L("Create a file"),_L("[filename] size [/e]\n\n /e - create an empty file, without writing any data"),TShellCommand::EESwitch,ShellFunction::Gobble),
    54 	TShellCommand(_L("HEXDUMP"),_L("Display the contents of a file in hexadecimal"),_L("[drive:][path][filename] [/p]\n\n  /p - Pause after each screen of information\n\n  Hit escape to exit from hexdump "),TShellCommand::EPSwitch,ShellFunction::Hexdump),
    52 	TShellCommand(_L("HEXDUMP"),_L("Display the contents of a file in hexadecimal"),_L("[drive:][path][filename] [/p]\n\n  /p - Pause after each screen of information\n\n  Hit escape to exit from hexdump "),TShellCommand::EPSwitch,ShellFunction::Hexdump),
    55 	TShellCommand(_L("LABEL"),_L("Set or return the volume label"),_L("[newlabel]"),0,ShellFunction::VolumeLabel),
    53 	TShellCommand(_L("LABEL"),_L("Set or return the volume label"),_L("[newlabel]"),0,ShellFunction::VolumeLabel),
    56 	TShellCommand(_L("MD"),_L("Make a new directory"),_L("name"),0,ShellFunction::Md),
    54 	TShellCommand(_L("MD"),_L("Make a new directory"),_L("name"),0,ShellFunction::Md),
    71 	TShellCommand(_L("DEBUGPORT"),_L("Set or get debug port"),_L("[port]"),0,ShellFunction::DebugPort),
    69 	TShellCommand(_L("DEBUGPORT"),_L("Set or get debug port"),_L("[port]"),0,ShellFunction::DebugPort),
    72 	TShellCommand(_L("PLUGIN"),_L("Manage Plugins"),_L("[name][/A][/R][/M][/D]"),TShellCommand::EASwitch|TShellCommand::ERSwitch|TShellCommand::EMSwitch|TShellCommand::EDSwitch,ShellFunction::Plugin),
    70 	TShellCommand(_L("PLUGIN"),_L("Manage Plugins"),_L("[name][/A][/R][/M][/D]"),TShellCommand::EASwitch|TShellCommand::ERSwitch|TShellCommand::EMSwitch|TShellCommand::EDSwitch,ShellFunction::Plugin),
    73     TShellCommand(_L("DRVINFO"),_L("Print information about present drive(s) in the system"),_L("[DriveLetter:[\\]] [/p]\n/p - pause after each drive"),TShellCommand::EPSwitch,ShellFunction::DrvInfo),
    71     TShellCommand(_L("DRVINFO"),_L("Print information about present drive(s) in the system"),_L("[DriveLetter:[\\]] [/p]\n/p - pause after each drive"),TShellCommand::EPSwitch,ShellFunction::DrvInfo),
    74 	TShellCommand(_L("SYSINFO"),_L("Print information about system features and status"),_L(""),0,ShellFunction::SysInfo),
    72 	TShellCommand(_L("SYSINFO"),_L("Print information about system features and status"),_L(""),0,ShellFunction::SysInfo),
    75     TShellCommand(_L("MOUNT"),_L("Mount / dismount file system on specified drive"),ptrMountHelp,TShellCommand::EUSwitch|TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::ERSwitch,ShellFunction::MountFileSystem),
    73     TShellCommand(_L("MOUNT"),_L("Mount / dismount file system on specified drive"),ptrMountHelp,TShellCommand::EUSwitch|TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::ERSwitch,ShellFunction::MountFileSystem),
    76     TShellCommand(_L("ECHO"),_L("Print out the command line to the console and standard debug port."),_L("[line to print out] [/Y/N]\n /Y turn ON copying console output to debug port\n /N turn it OFF "),TShellCommand::EYSwitch|TShellCommand::ENSwitch,ShellFunction::ConsoleEcho),
    74     TShellCommand(_L("ECHO"),_L("Print out the command line to the console and standard debug port."),_L("[line to print out]"),0,ShellFunction::ConsoleEcho),
    77 	TShellCommand(_L("RUNEXEC"),_L("Run a program in a loop"),_L("count filename[.exe] [/E/S/R]\n	/E - exit early on error\n	/S - count in seconds\n	     zero - run forever\n	/R - reset debug regs after each run"),TShellCommand::EESwitch|TShellCommand::ESSwitch|TShellCommand::ERSwitch,ShellFunction::RunExec),
    75 	TShellCommand(_L("RUNEXEC"),_L("Run a program in a loop"),_L("count filename[.exe] [/E/S/R]\n	/E - exit early on error\n	/S - count in seconds\n	     zero - run forever\n	/R - reset debug regs after each run"),TShellCommand::EESwitch|TShellCommand::ESSwitch|TShellCommand::ERSwitch,ShellFunction::RunExec),
    78 
    76 
    79     };
    77     };
    80 
    78 
    81 
    79 
    82 LOCAL_C TInt pswd_DrvNbr(TDes &aPath, TInt &aDN);
    80 LOCAL_C TInt pswd_DrvNbr(TDes &aPath, TInt &aDN);
    83 LOCAL_C TInt pswd_Password(TDes &aPath, TInt aPWNbr, TMediaPassword &aPW);
    81 LOCAL_C TInt pswd_Password(TDes &aPath, TInt aPWNbr, TMediaPassword &aPW);
    84 
    82 
       
    83 _LIT(KLitNewLine,"\n");
    85 void CShell::NewLine()
    84 void CShell::NewLine()
    86 	{
    85 	{
    87 	Printf(KNl);
    86 	TheConsole->Printf(KLitNewLine());
    88 	}
    87 	}
    89 
    88 
    90 //
    89 //
    91 // Skip the hexadecimal prefix if present and return EHex.  Return
    90 // Skip the hexadecimal prefix if present and return EHex.  Return
    92 // EDecimal otherwise.
    91 // EDecimal otherwise.
   362     {//-- run CheckDisk on the specified drive
   361     {//-- run CheckDisk on the specified drive
   363         nRes=TheShell->TheFs.CheckDisk(aPath);
   362         nRes=TheShell->TheFs.CheckDisk(aPath);
   364 	    if (nRes<0)
   363 	    if (nRes<0)
   365 		    return(nRes);
   364 		    return(nRes);
   366 
   365 
   367 	    //-- this is, actually, FAT FS specific error codes. Other file systems can report different values.
       
   368 	    switch(nRes)
   366 	    switch(nRes)
   369 		    {
   367 		    {
   370 	    case 0:
   368 	    case 0:
   371 		    CShell::TheConsole->Printf(_L("Completed - no errors found\n"));
   369 		    CShell::TheConsole->Printf(_L("Complete - no errors\n"));
   372 		    break;
   370 		    break;
   373 	    case 1:
   371 	    case 1:
   374 		    CShell::TheConsole->Printf(_L("Error - File cluster chain contains a bad value (<2 or >maxCluster)\n"));
   372 		    CShell::TheConsole->Printf(_L("Error - File cluster chain contains a bad value (<2 or >maxCluster)\n"));
   375 		    break;
   373 		    break;
   376 	    case 2:
   374 	    case 2:
   494 	TVolumeInfo vol;
   492 	TVolumeInfo vol;
   495 	TInt drive;
   493 	TInt drive;
   496 	TInt r=CShell::TheFs.CharToDrive(CShell::currentPath[0], drive);
   494 	TInt r=CShell::TheFs.CharToDrive(CShell::currentPath[0], drive);
   497 	if (r!=KErrNone)
   495 	if (r!=KErrNone)
   498 		return(r);
   496 		return(r);
   499 	
       
   500 	if (aPath.Length()==0)
   497 	if (aPath.Length()==0)
   501 		{
   498 		{
   502 		r=CShell::TheFs.Volume(vol, drive);
   499 		r=CShell::TheFs.Volume(vol, drive);
   503 		if (r==KErrNone)
   500 		if (r==KErrNone)
   504 			CShell::Printf(_L("Volume Label:%S\n"),&vol.iName);
   501 			CShell::TheConsole->Printf(_L("Volume = %S\n"),&vol.iName);
   505 		return(r);
   502 		return(r);
   506 		}
   503 		}
   507 	
       
   508 	r=CShell::TheFs.SetVolumeLabel(aPath, drive);
   504 	r=CShell::TheFs.SetVolumeLabel(aPath, drive);
   509 	return(r);
   505 	return(r);
   510 	}
   506 	}
   511 
   507 
   512 TInt ShellFunction::Del(TDes& aPath,TUint aSwitches)
   508 TInt ShellFunction::Del(TDes& aPath,TUint aSwitches)
   580 		aText.Remove(j);
   576 		aText.Remove(j);
   581 		}
   577 		}
   582 
   578 
   583 }
   579 }
   584 
   580 
   585 /**
   581 
   586     outputs content of the buffer to console according to settings passed in aSwitches
   582 void ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches)
   587     @return ETrue if the user pressed Esc key 
   583 //outputs content of the buffer to console according to settings passed in aSwitches
   588 */
       
   589 TBool ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches)
       
   590 	{
   584 	{
   591 	if ((aText.Count()>0)&&((aSwitches&TShellCommand::EWSwitch)!=0))
   585 	if ((aText.Count()>0)&&((aSwitches&TShellCommand::EWSwitch)!=0))
   592 		AlignTextIntoColumns(aText);
   586 		AlignTextIntoColumns(aText);
   593 
   587 
   594 	TKeyCode key=EKeyNull;
   588 	for (TInt i=0;i<aText.Count();i++)
   595     TInt i;
   589 		{
   596 
   590 		CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]);
   597     for(i=0;i<aText.Count();i++)
   591 		CShell::OutputStringToConsole(EFalse,_L("\n"));
   598 		{                                             
       
   599 		key = CShell::WriteBufToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]);
       
   600 		if(key == EKeyEscape)
       
   601             break;
       
   602         
       
   603         key = CShell::WriteBufToConsole(EFalse,_L("\n"));
       
   604 		if(key == EKeyEscape)
       
   605             break;
       
   606 
       
   607 		}
       
   608     
       
   609     //-- clean up string array
       
   610     for(i=0; i<aText.Count(); i++)
       
   611         {
       
   612 		delete aText[i];
   592 		delete aText[i];
   613 		}
   593 		}
   614 	
   594 	//empty string array
   615 	aText.Reset();
   595 	aText.Reset();
   616 
       
   617     return (key == EKeyEscape);
       
   618 	}
   596 	}
   619 
   597 
   620 
   598 
   621 void ShellFunction::OutputDirContentL(CDir* aDirList,RPointerArray<HBufC>& aText,TUint aSwitches)
   599 void ShellFunction::OutputDirContentL(CDir* aDirList,RPointerArray<HBufC>& aText,TUint aSwitches)
   622 //outputs content of a directory to console according to settings passed in aSwitches
   600 //outputs content of a directory to console according to settings passed in aSwitches
   623 	{
   601 	{
   624 	TInt count=aDirList->Count();
   602 	TInt count=aDirList->Count();
   625 	TInt fileCount=0, dirCount=0, printCount=0;
   603 	TInt fileCount=0, dirCount=0, printCount=0;
   626 	TInt64 byteCount=0;
   604 	TInt64 byteCount=0;
   627     TBool bBreak=EFalse;
       
   628 
   605 
   629 	//compose an array of strings describing entries in the directory
   606 	//compose an array of strings describing entries in the directory
   630 	for (TInt j=0;j<count;j++)
   607 	for (TInt j=0;j<count;j++)
   631 		{
   608 		{
   632 		HBufC* buf=NULL;
   609 		HBufC* buf=NULL;
   658 			buf = HBufC::NewL(KMaxFileName+100);//reserve additional space for the creation time information
   635 			buf = HBufC::NewL(KMaxFileName+100);//reserve additional space for the creation time information
   659 			CleanupStack::PushL(buf);
   636 			CleanupStack::PushL(buf);
   660 			TPtr name=buf->Des();
   637 			TPtr name=buf->Des();
   661 			name=entry.iName;
   638 			name=entry.iName;
   662 
   639 
   663             const TPtrC desName(entry.iName);
       
   664             const TBool bNameCut = desName.Length() > 26;
       
   665 
       
   666             _LIT(KDots, ">.."); //-- will be displayed if the name is longer than 26 characters
       
   667             _LIT(KSpc,  "   ");
       
   668 			
       
   669             
       
   670 			if (entry.IsDir())
   640 			if (entry.IsDir())
   671 				{
   641 				{
   672 				dirCount++;
   642 				dirCount++;
   673 				
   643 				name.Format(_L(" %- 26S   <DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
   674                 name.Format(_L(" %- 26S%S<DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%03d"),
   644 											&entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
   675 				    &desName,
       
   676                     bNameCut ? &KDots : &KSpc,
       
   677                     modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
       
   678 				
       
   679                 //name.Format(_L(" %- 26S   <DIR>         %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
       
   680 				//							&entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
       
   681 				}
   645 				}
   682 			else
   646 			else
   683 				{
   647 				{
   684 				TInt64 entrySize = entry.FileSize();
   648 				TInt64 entrySize = entry.FileSize();
   685 				byteCount+=entrySize;
   649 				byteCount+=entrySize;
   686 				fileCount++;
   650 				fileCount++;
   687 
   651  				name.Format(_L(" %- 32S%+ 15Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
   688                 name.Format(_L(" %- 26S%S%-11Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%03d"),
   652  											&entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
   689  				    &desName,
       
   690                     bNameCut ? &KDots : &KSpc,
       
   691                     entrySize,
       
   692                     modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
       
   693  				
       
   694                 //name.Format(_L(" %- 32S%+ 15Lu   %+02d/%+02d/%- 4d  %02d:%02d:%02d.%06d"),
       
   695  				//							&entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond());
       
   696 				}
   653 				}
   697 			}
   654 			}
   698 		User::LeaveIfError(aText.Append(buf ));
   655 		User::LeaveIfError(aText.Append(buf ));
   699 		printCount++;
   656 		printCount++;
   700 		
       
   701 		//print the contents if a screen size of data is available. This will prevent huge buffer allocation.
   657 		//print the contents if a screen size of data is available. This will prevent huge buffer allocation.
   702 		if(printCount == CShell::TheConsole->ScreenSize().iHeight)
   658 		if(printCount == CShell::TheConsole->ScreenSize().iHeight)
   703 			{
   659 			{
   704 			bBreak = OutputContentsToConsole(aText,aSwitches);
   660 			OutputContentsToConsole(aText,aSwitches);
   705 			printCount=0;
   661 			printCount=0;
   706 			}
   662 			}
   707 		
       
   708 		CleanupStack::Pop();
   663 		CleanupStack::Pop();
   709 
   664 
   710         if(bBreak)
   665 		}
   711             break;    
       
   712 		}
       
   713 	
       
   714     if(bBreak)
       
   715         return; //-- the user has interrupted the listing
       
   716 
       
   717     
       
   718 	OutputContentsToConsole(aText,aSwitches);
   666 	OutputContentsToConsole(aText,aSwitches);
   719 
   667 
   720 	//---------------------------------
   668 	//output summary information
   721     //-- print out summary information
   669 	CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L("    %d File%c\n"),fileCount,(fileCount==1)?' ':'s');
   722 	TBuf<100> buf;
   670 	if (fileCount!=0)
   723     buf.Format(_L("    %d File%c"), fileCount, (fileCount==1) ? ' ':'s');
   671 		{
   724     if(fileCount > 0)
   672 		CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L("  %lu byte%c\n"),byteCount,(fileCount==1)?' ':'s');
   725 		{
   673 		}
   726         buf.AppendFormat(_L(", %LU bytes"), byteCount);
   674 
   727 		}
   675 	TBuf<50> buf;// allocate string long enough for additional information(number of directories)
   728 
       
   729     buf.Append(KNl);
       
   730     
       
   731     CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0), buf);
       
   732     
       
   733 	buf.Format(_L("    %d Director"),dirCount);
   676 	buf.Format(_L("    %d Director"),dirCount);
   734 	if (dirCount==1)
   677 	if (dirCount==1)
   735 		buf.AppendFormat(_L("y\n"));
   678 		buf.AppendFormat(_L("y\n"));
   736 	else
   679 	else
   737 		buf.AppendFormat(_L("ies\n"));
   680 		buf.AppendFormat(_L("ies\n"));
   738 
   681 
   739 	CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),buf);
   682 	CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),buf);
   740 
       
   741     
       
   742 	}
   683 	}
   743 
   684 
   744 TInt ShellFunction::Dir(TDes& aPath,TUint aSwitches)
   685 TInt ShellFunction::Dir(TDes& aPath,TUint aSwitches)
   745 //
   686 //
   746 //	Modified December 1997, to sort entries alphabetically
   687 //	Modified December 1997, to sort entries alphabetically
   762 	else file.Close();
   703 	else file.Close();
   763 
   704 
   764 	TInt r=dir.Open(TheShell->TheFs,aPath,KEntryAttMaskSupported);
   705 	TInt r=dir.Open(TheShell->TheFs,aPath,KEntryAttMaskSupported);
   765 	if (r!=KErrNone)
   706 	if (r!=KErrNone)
   766 		{
   707 		{
   767 		CShell::Printf(_L("File or directory not found\n"));
   708 		CShell::TheConsole->Printf(_L("File or directory not found\n"));
   768 		return(KErrNone);
   709 		return(KErrNone);
   769 		}
   710 		}
   770 
   711 
   771 	CDir* anEntryList;
   712 	CDir* anEntryList;
   772 	r=TheShell->TheFs.GetDir(aPath,KEntryAttMaskSupported,ESortByName,anEntryList);
   713 	r=TheShell->TheFs.GetDir(aPath,KEntryAttMaskSupported,ESortByName,anEntryList);
   777 		}
   718 		}
   778     CleanupStack::PushL(anEntryList);
   719     CleanupStack::PushL(anEntryList);
   779 
   720 
   780 	//Sets the new length of path to the position of the last path delimiter +1
   721 	//Sets the new length of path to the position of the last path delimiter +1
   781 	aPath.SetLength(aPath.LocateReverse(KPathDelimiter)+1);
   722 	aPath.SetLength(aPath.LocateReverse(KPathDelimiter)+1);
   782 	CShell::Printf(_L("Directory of %S\n"),&aPath);
   723 	CShell::TheConsole->Printf(_L("Directory of %S\n"),&aPath);
   783 
   724 
   784 	//allocate array to be used as an output buffer
   725 	//allocate array to be used as an output buffer
   785 	RPointerArray<HBufC>* text=new(ELeave) RPointerArray<HBufC>();
   726 	RPointerArray<HBufC>* text=new(ELeave) RPointerArray<HBufC>();
   786 	TRAPD(error,OutputDirContentL(anEntryList,*text,aSwitches));
   727 	TRAPD(error,OutputDirContentL(anEntryList,*text,aSwitches));
   787 	//we are not interesed in the error code because we need empty the buffer in any case
   728 	//we are not interesed in the error code because we need empty the buffer in any case
   795 	else
   736 	else
   796 		return(KErrNone);
   737 		return(KErrNone);
   797 	};
   738 	};
   798 
   739 
   799 
   740 
       
   741 TInt ShellFunction::Edit(TDes& /*aPath*/,TUint /*aSwitches*/)
       
   742 //
       
   743 //	Dummy, used by edlin (now retired)
       
   744 //
       
   745 	{
       
   746 	return(KErrNone);
       
   747 	}
   800 
   748 
   801 
   749 
   802 TInt ShellFunction::Attrib(TDes& aPath,TUint aSwitches)
   750 TInt ShellFunction::Attrib(TDes& aPath,TUint aSwitches)
   803 {
   751 {
   804 	ShellFunction::StripQuotes(aPath);
   752 	ShellFunction::StripQuotes(aPath);
  1053         if(aDrvInfo.iDriveAtt & KDriveAttLocal)         aPrintBuf.Append(_L("KDriveAttLocal,"));
  1001         if(aDrvInfo.iDriveAtt & KDriveAttLocal)         aPrintBuf.Append(_L("KDriveAttLocal,"));
  1054         if(aDrvInfo.iDriveAtt & KDriveAttRom)           aPrintBuf.Append(_L("KDriveAttRom,"));
  1002         if(aDrvInfo.iDriveAtt & KDriveAttRom)           aPrintBuf.Append(_L("KDriveAttRom,"));
  1055         if(aDrvInfo.iDriveAtt & KDriveAttRedirected)    aPrintBuf.Append(_L("KDriveAttRedirected,"));
  1003         if(aDrvInfo.iDriveAtt & KDriveAttRedirected)    aPrintBuf.Append(_L("KDriveAttRedirected,"));
  1056         if(aDrvInfo.iDriveAtt & KDriveAttSubsted)       aPrintBuf.Append(_L("KDriveAttSubsted,"));
  1004         if(aDrvInfo.iDriveAtt & KDriveAttSubsted)       aPrintBuf.Append(_L("KDriveAttSubsted,"));
  1057         if(aDrvInfo.iDriveAtt & KDriveAttInternal)      aPrintBuf.Append(_L("KDriveAttInternal,"));
  1005         if(aDrvInfo.iDriveAtt & KDriveAttInternal)      aPrintBuf.Append(_L("KDriveAttInternal,"));
  1058         if(aDrvInfo.iDriveAtt & KDriveAttRemovable)     aPrintBuf.Append(_L("KDriveAttRemovable,"));
  1006         if(aDrvInfo.iDriveAtt & KDriveAttRemovable)     aPrintBuf.Append(_L("KDriveAttRemovable"));
  1059 
  1007 
  1060         if(aDrvInfo.iDriveAtt & KDriveAttRemote)        aPrintBuf.Append(_L("KDriveAttRemote,"));
  1008         if(aDrvInfo.iDriveAtt & KDriveAttRemote)        aPrintBuf.Append(_L("KDriveAttRemote"));
  1061         if(aDrvInfo.iDriveAtt & KDriveAttTransaction)   aPrintBuf.Append(_L("KDriveAttTransaction,"));
  1009         if(aDrvInfo.iDriveAtt & KDriveAttTransaction)   aPrintBuf.Append(_L("KDriveAttTransaction"));
  1062 
  1010 
  1063         if(aDrvInfo.iDriveAtt & KDriveAttPageable)              aPrintBuf.Append(_L("KDriveAttPageable,"));
  1011         if(aDrvInfo.iDriveAtt & KDriveAttPageable)              aPrintBuf.Append(_L("KDriveAttPageable"));
  1064         if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable)    aPrintBuf.Append(_L("KDriveAttLogicallyRemovable,"));
  1012         if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable)    aPrintBuf.Append(_L("KDriveAttLogicallyRemovable"));
  1065         if(aDrvInfo.iDriveAtt & KDriveAttHidden)                aPrintBuf.Append(_L("KDriveAttHidden,"));
  1013         if(aDrvInfo.iDriveAtt & KDriveAttHidden)                aPrintBuf.Append(_L("KDriveAttHidden"));
  1066 
  1014 
  1067         aPrintBuf.Append(_L("\n"));
  1015         aPrintBuf.Append(_L("\n"));
  1068     }
  1016     }
  1069 
  1017 
  1070 //--------------------------------------------------------
  1018 //--------------------------------------------------------
  1082         if(aDrvInfo.iMediaAtt & KMediaAttVariableSize)      aPrintBuf.Append(_L("KMediaAttVariableSize,"));
  1030         if(aDrvInfo.iMediaAtt & KMediaAttVariableSize)      aPrintBuf.Append(_L("KMediaAttVariableSize,"));
  1083         if(aDrvInfo.iMediaAtt & KMediaAttDualDensity)       aPrintBuf.Append(_L("KMediaAttDualDensity,"));
  1031         if(aDrvInfo.iMediaAtt & KMediaAttDualDensity)       aPrintBuf.Append(_L("KMediaAttDualDensity,"));
  1084         if(aDrvInfo.iMediaAtt & KMediaAttFormattable)       aPrintBuf.Append(_L("KMediaAttFormattable,"));
  1032         if(aDrvInfo.iMediaAtt & KMediaAttFormattable)       aPrintBuf.Append(_L("KMediaAttFormattable,"));
  1085         if(aDrvInfo.iMediaAtt & KMediaAttWriteProtected)    aPrintBuf.Append(_L("KMediaAttWriteProtected,"));
  1033         if(aDrvInfo.iMediaAtt & KMediaAttWriteProtected)    aPrintBuf.Append(_L("KMediaAttWriteProtected,"));
  1086         if(aDrvInfo.iMediaAtt & KMediaAttLockable)          aPrintBuf.Append(_L("KMediaAttLockable,"));
  1034         if(aDrvInfo.iMediaAtt & KMediaAttLockable)          aPrintBuf.Append(_L("KMediaAttLockable,"));
  1087         if(aDrvInfo.iMediaAtt & KMediaAttLocked)            aPrintBuf.Append(_L("KMediaAttLocked,"));
  1035         if(aDrvInfo.iMediaAtt & KMediaAttLocked)            aPrintBuf.Append(_L("KMediaAttLocked"));
  1088 
  1036 
  1089         if(aDrvInfo.iMediaAtt & KMediaAttHasPassword)       aPrintBuf.Append(_L("KMediaAttHasPassword,"));
  1037         if(aDrvInfo.iMediaAtt & KMediaAttHasPassword)       aPrintBuf.Append(_L("KMediaAttHasPassword"));
  1090         if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite)    aPrintBuf.Append(_L("KMediaAttReadWhileWrite,"));
  1038         if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite)    aPrintBuf.Append(_L("KMediaAttReadWhileWrite"));
  1091         if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify)      aPrintBuf.Append(_L("KMediaAttDeleteNotify,"));
  1039         if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify)      aPrintBuf.Append(_L("KMediaAttDeleteNotify"));
  1092         if(aDrvInfo.iMediaAtt & KMediaAttPageable)          aPrintBuf.Append(_L("KMediaAttPageable,"));
  1040         if(aDrvInfo.iMediaAtt & KMediaAttPageable)          aPrintBuf.Append(_L("KMediaAttPageable"));
  1093         
  1041         
  1094 
  1042 
  1095         aPrintBuf.Append(_L("\n"));
  1043         aPrintBuf.Append(_L("\n"));
  1096     }
  1044     }
  1097 
  1045 
  1103     @param  volInfo     volume information
  1051     @param  volInfo     volume information
  1104     @param  aPrintBuf   buffer where the information will be printed to.
  1052     @param  aPrintBuf   buffer where the information will be printed to.
  1105 */
  1053 */
  1106 void FormatVolInfo(const TVolumeInfo& volInfo , TDes& aPrintBuf)
  1054 void FormatVolInfo(const TVolumeInfo& volInfo , TDes& aPrintBuf)
  1107     {
  1055     {
  1108    	aPrintBuf.Format(_L("VolSz:%ld Free:%ld"),volInfo.iSize, volInfo.iFree);
  1056    	aPrintBuf.Format(_L("VolSz:%ld Free:%ld\n"),volInfo.iSize, volInfo.iFree);
  1109    	aPrintBuf.AppendFormat(_L("\r\nVolId:0x%x VolName:%S\n"),volInfo.iUniqueID, &volInfo.iName);
  1057    	aPrintBuf.AppendFormat(_L("VolId:0x%x VolName:%S\n"),volInfo.iUniqueID, &volInfo.iName);
  1110     }
  1058     }
  1111 
  1059 
  1112 //--------------------------------------------------------
  1060 //--------------------------------------------------------
  1113 
  1061 
  1114 /** Bit flags that specify which information will be printed by PrintDrvInfo() */
  1062 /** Bit flags that specify which information will be printed by PrintDrvInfo() */
  1133     @param  apConsole   pointer to the console to print information into
  1081     @param  apConsole   pointer to the console to print information into
  1134     @param  aFlags      specifies which information to print out, @see TPrintDrvInfoFlags
  1082     @param  aFlags      specifies which information to print out, @see TPrintDrvInfoFlags
  1135 
  1083 
  1136     @return standard error code
  1084     @return standard error code
  1137 */
  1085 */
  1138 TInt PrintDrvInfo(RFs& aFs, TInt aDrvNum, TUint aFlags = EAll)
  1086 TInt PrintDrvInfo(RFs& aFs, TInt aDrvNum, CConsoleBase* apConsole, TUint aFlags = EAll)
  1139     {
  1087     {
  1140 	TInt        nRes;
  1088 	TInt        nRes;
  1141 	TDriveInfo 	driveInfo;
  1089 	TDriveInfo 	driveInfo;
  1142 	TVolumeInfo volInfo;
  1090 	TVolumeInfo volInfo;
  1143 	TBuf<256>   Buf;
  1091 	TBuf<256>   Buf;
  1144 
  1092 
  1145 	//-- get drive info
  1093 	//-- get drive info
  1146 	nRes = aFs.Drive(driveInfo, aDrvNum);
  1094 	nRes = aFs.Drive(driveInfo, aDrvNum);
  1147 	if(nRes != KErrNone)
  1095 	if(nRes != KErrNone)
  1148 		{
  1096 		{
  1149         CShell::Printf(_L("Error: %d\n"), nRes);
  1097 		CShell::TheConsole->Printf(_L("Error: %d\n"), nRes);
  1150 		return nRes;   //-- can't get information about the drive
  1098 		return nRes;   //-- can't get information about the drive
  1151 		}
  1099 		}
  1152 
  1100 
  1153 	
  1101 	
  1154     nRes = aFs.Volume(volInfo, aDrvNum);
  1102     nRes = aFs.Volume(volInfo, aDrvNum);
  1155     const TBool bVolumeOK  = (nRes == KErrNone);
  1103     const TBool bVolumeOK  = (nRes == KErrNone);
  1156 	if(!bVolumeOK)
  1104 	if(!bVolumeOK)
  1157 	{//-- can't get information about the volume. It might be just corrupt/unformatted
  1105 	{//-- can't get information about the volume. It might be just corrupt/unformatted
  1158         CShell::Printf(_L("Error getting volume info. code: %d\n"), nRes);
  1106 		CShell::TheConsole->Printf(_L("Error getting volume info. code: %d\n"), nRes);
  1159         if(nRes == KErrCorrupt)
  1107         if(nRes == KErrCorrupt)
  1160         {
  1108         {
  1161             CShell::Printf(_L("The volume might be corrupted or not formatted.\n"));
  1109             CShell::TheConsole->Printf(_L("The volume might be corrupted or not formatted.\n"));
  1162         }
  1110         }
  1163 	}
  1111 	}
  1164 
  1112 
  1165 
  1113 
  1166 	//-- Print out information about file system installed
  1114 	//-- Print out information about file system installed
  1167 	if(aFlags & EFSInfo)
  1115 	if(aFlags & EFSInfo)
  1168     {
  1116     {
  1169         //-- print out drive properties
  1117         //-- print out drive properties
  1170         Buf.Format(_L("Drive %c: No:%d"), 'A'+aDrvNum, aDrvNum);
  1118         Buf.Format(_L("\nDrive %c: No:%d"), 'A'+aDrvNum, aDrvNum);
  1171         
  1119         
  1172         //-- find out if the drive is synchronous / asynchronous
  1120         //-- find out if the drive is synchronous / asynchronous
  1173         TPckgBuf<TBool> drvSyncBuf;
  1121         TPckgBuf<TBool> drvSyncBuf;
  1174         nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveSync, drvSyncBuf);
  1122         nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveSync, drvSyncBuf);
  1175         if(nRes == KErrNone)
  1123         if(nRes == KErrNone)
  1176         {
  1124         {
  1177             Buf.AppendFormat(_L(" Sync:%d"), drvSyncBuf() ? 1:0);        
  1125             Buf.AppendFormat(_L(", Sync:%d"), drvSyncBuf() ? 1:0);        
  1178         }
  1126         }
  1179 
  1127 
  1180         //-- find out if drive runs a rugged FS (debug mode only)
  1128         //-- find out if drive runs a rugged FS (debug mode only)
  1181         const TInt KControlIoIsRugged=4;
  1129         const TInt KControlIoIsRugged=4;
  1182         TUint8 ruggedFS;
  1130         TUint8 ruggedFS;
  1183         TPtr8 pRugged(&ruggedFS, 1, 1);
  1131         TPtr8 pRugged(&ruggedFS, 1, 1);
  1184         nRes=aFs.ControlIo(aDrvNum, KControlIoIsRugged, pRugged);
  1132         nRes=aFs.ControlIo(aDrvNum, KControlIoIsRugged, pRugged);
  1185         if(nRes == KErrNone)
  1133         if(nRes == KErrNone)
  1186         {
  1134         {
  1187             Buf.AppendFormat(_L(" Rugged:%d"), ruggedFS ? 1:0);        
  1135             Buf.AppendFormat(_L(", Rugged:%d"), ruggedFS ? 1:0);        
  1188         }
  1136         }
  1189 
  1137 
  1190         CShell::Printf(KNl);
  1138         Buf.Append(_L("\n"));
  1191         Buf.Append(KNl);
  1139         apConsole->Printf(Buf);
  1192         CShell::Printf(Buf);
  1140 
  1193 
  1141 
  1194 	    //-- print the FS name
  1142 	    //-- print the FS name
  1195 	    if(aFs.FileSystemName(Buf, aDrvNum) == KErrNone)
  1143 	    if(aFs.FileSystemName(Buf, aDrvNum) == KErrNone)
  1196 	    {
  1144 	    {
  1197 	        TFSName fsName;
  1145 	        TFSName fsName;
  1207             if(nRes == KErrNone)
  1155             if(nRes == KErrNone)
  1208             {   
  1156             {   
  1209                  Buf.AppendFormat(_L(" PExt:%S"), &fsName);
  1157                  Buf.AppendFormat(_L(" PExt:%S"), &fsName);
  1210             }
  1158             }
  1211 
  1159 
  1212             CShell::Printf(_L("Mounted FS:%S\n"), &Buf);
  1160 
  1213 
  1161             apConsole->Printf(_L("Mounted FS:%S\n"), &Buf);
  1214             //-- print out the list of supported file systems if there are more than 0
  1162 
  1215             nRes = aFs.SupportedFileSystemName(fsName, aDrvNum, 0); //-- try to get 1st child name
  1163             //-- print out the list of supported file systems if there are more than 1
       
  1164             nRes = aFs.SupportedFileSystemName(fsName, aDrvNum, 0+1); //-- try to get 2nd child name
  1216             if(nRes == KErrNone)
  1165             if(nRes == KErrNone)
  1217             {
  1166             {
  1218                 Buf.Copy(_L("Supported FS: "));
  1167                 Buf.Copy(_L("Supported FS: "));
  1219                 for(TInt i=0; ;++i)
  1168                 for(TInt i=0; ;++i)
  1220                 {
  1169                 {
  1223                         break;
  1172                         break;
  1224 
  1173 
  1225                     Buf.AppendFormat(_L("%S, "), &fsName);
  1174                     Buf.AppendFormat(_L("%S, "), &fsName);
  1226                 }
  1175                 }
  1227             
  1176             
  1228                 Buf.Append(KNl);
  1177                 Buf.Append(_L("\n"));
  1229                 CShell::Printf(Buf);
  1178                 apConsole->Printf(Buf);
  1230             }
  1179             }
  1231 
  1180 
  1232 
  1181 
  1233 
  1182 
  1234             
  1183             
  1240                 TPckgBuf<TBool> boolPckg;
  1189                 TPckgBuf<TBool> boolPckg;
  1241                 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveFinalised, boolPckg);
  1190                 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveFinalised, boolPckg);
  1242                 if(nRes == KErrNone)
  1191                 if(nRes == KErrNone)
  1243                 {
  1192                 {
  1244                     if(boolPckg() >0)
  1193                     if(boolPckg() >0)
  1245                         Buf.Copy(_L("Vol:Finalised "));
  1194                         Buf.Copy(_L("Volume: Finalised"));
  1246                     else
  1195                     else
  1247                         Buf.Copy(_L("Vol:Not finalised "));
  1196                         Buf.Copy(_L("Volume: Not finalised"));
  1248                 }
  1197                 }
  1249 
  1198 
  1250                 //-- print out cluster size that FS reported
  1199                 //-- print out cluster size that FS reported
  1251                 TVolumeIOParamInfo volIoInfo;
  1200                 TVolumeIOParamInfo volIoInfo;
  1252                 nRes = aFs.VolumeIOParam(aDrvNum, volIoInfo);
  1201                 nRes = aFs.VolumeIOParam(aDrvNum, volIoInfo);
  1253                 if(nRes == KErrNone)
  1202                 if(nRes == KErrNone)
  1254                 {
  1203                 {
  1255                     if(volIoInfo.iBlockSize >= 0)
  1204                     if(volIoInfo.iBlockSize >= 0)
  1256                     {
  1205                     {
  1257                         Buf.AppendFormat(_L("BlkSz:%d "), volIoInfo.iBlockSize);
  1206                         Buf.AppendFormat(_L(", BlkSz:%d"), volIoInfo.iBlockSize);
  1258                     }
  1207                     }
  1259                     
  1208                     
  1260                     if(volIoInfo.iClusterSize >= 0)
  1209                     if(volIoInfo.iClusterSize >= 0)
  1261                     {
  1210                     {
  1262                         Buf.AppendFormat(_L("ClSz:%d "), volIoInfo.iClusterSize);
  1211                         Buf.AppendFormat(_L(", ClSz:%d"), volIoInfo.iClusterSize);
  1263                     }
  1212                     }
  1264 
  1213 
  1265                     Buf.AppendFormat(_L("CacheFlags:0x%x "), volInfo.iFileCacheFlags);
  1214                     Buf.AppendFormat(_L(", CacheFlags:0x%x"), volInfo.iFileCacheFlags);
  1266                 
  1215                 
  1267                 }
  1216                 }
  1268 
  1217 
  1269 
  1218 
  1270                 if(Buf.Length())
  1219                 if(Buf.Length())
  1271                 {
  1220                 {
  1272                     Buf.Append(KNl);
  1221                     Buf.Append(_L("\n"));
  1273                     CShell::Printf(Buf);
  1222                     apConsole->Printf(Buf);    
  1274                 }
  1223                 }
  1275 
  1224 
  1276             }
  1225             }
  1277 	    }
  1226 	    }
  1278     }//if(aFlags & EFSInfo)
  1227     }//if(aFlags & EFSInfo)
  1279 
  1228 
  1280 	//-- print media attributes
  1229 	//-- print media attributes
  1281 	if(aFlags & EMediaTypeInfo)
  1230 	if(aFlags & EMediaTypeInfo)
  1282     {
  1231     {
  1283         FormatDrvMediaTypeInfo(driveInfo, Buf);
  1232         FormatDrvMediaTypeInfo(driveInfo, Buf);
  1284         CShell::Printf(Buf);
  1233 	    apConsole->Printf(Buf);
       
  1234 
  1285 	}
  1235 	}
  1286     
  1236     
  1287     //-- print drive attributes
  1237     //-- print drive attributes
  1288 	if(aFlags & EDrvAttInfo)
  1238 	if(aFlags & EDrvAttInfo)
  1289     {
  1239     {
  1290         FormatDriveAttInfo(driveInfo, Buf);
  1240         FormatDriveAttInfo(driveInfo, Buf);
  1291         CShell::Printf(Buf);
  1241 	    apConsole->Printf(Buf);
  1292     }
  1242     }
  1293 
  1243 
  1294     //-- print media attributes
  1244     //-- print media attributes
  1295 	if(aFlags & EMediaAttInfo)
  1245 	if(aFlags & EMediaAttInfo)
  1296     {
  1246     {
  1297 	    FormatMediaAttInfo(driveInfo, Buf);
  1247 	    FormatMediaAttInfo(driveInfo, Buf);
  1298         CShell::Printf(Buf);
  1248 	    apConsole->Printf(Buf);
  1299     }
  1249     }
  1300 
  1250 
  1301 
  1251 
  1302 	//-- print volume information
  1252 	//-- print volume information
  1303 	if(bVolumeOK && (aFlags & EVolInfo))
  1253 	if(bVolumeOK && (aFlags & EVolInfo))
  1304     {
  1254     {
  1305 	    FormatVolInfo(volInfo, Buf);
  1255 	    FormatVolInfo(volInfo, Buf);
  1306         CShell::Printf(Buf);
  1256 	    apConsole->Printf(Buf);
  1307     }
  1257     }
  1308 	
  1258 	
  1309     return KErrNone;
  1259     return KErrNone;
  1310 	}
  1260 	}
  1311 
  1261 
  1372 	else
  1322 	else
  1373 		{//-- print info about specified drive
  1323 		{//-- print info about specified drive
  1374 		nDrv = DoExtractDriveLetter(aArgs);
  1324 		nDrv = DoExtractDriveLetter(aArgs);
  1375         if(nDrv < 0)
  1325         if(nDrv < 0)
  1376             {
  1326             {
  1377             CShell::Printf(_L("Invalid drive specification\n"));    
  1327             CShell::TheConsole->Printf(_L("Invalid drive specifier!\n"));    
  1378             return KErrNone;
  1328             return KErrNone;
  1379             }
  1329             }
  1380 		}
  1330 		}
  1381 
  1331 
  1382 	TInt nRes;
  1332 	TInt nRes;
  1384 
  1334 
  1385 	//-- get drives list
  1335 	//-- get drives list
  1386 	nRes=TheShell->TheFs.DriveList(driveList);
  1336 	nRes=TheShell->TheFs.DriveList(driveList);
  1387 	if(nRes != KErrNone)
  1337 	if(nRes != KErrNone)
  1388 		{
  1338 		{
  1389         CShell::Printf(_L("\nError: %d"), nRes);
  1339 		CShell::TheConsole->Printf(_L("\nError: %d"), nRes);
  1390 		return nRes;
  1340 		return nRes;
  1391 		}
  1341 		}
  1392 
  1342 
  1393 	if(nDrv >=0)
  1343 	if(nDrv >=0)
  1394 		{//-- the drive is specified
  1344 		{//-- the drive is specified
  1395 		if(!driveList[nDrv])
  1345 		if(!driveList[nDrv])
  1396 			{
  1346 			{
  1397             CShell::Printf(_L("Invalid drive specification\n"));
  1347 			CShell::TheConsole->Printf(_L("Invalid drive specification\n"));
  1398 			return KErrNone;
  1348 			return KErrNone;
  1399 			}
  1349 			}
  1400 
  1350 
  1401 		PrintDrvInfo(TheShell->TheFs, nDrv);
  1351 		PrintDrvInfo(TheShell->TheFs, nDrv, CShell::TheConsole);
  1402 		}
  1352 		}
  1403 	else
  1353 	else
  1404 		{//-- print information about all drives in the system
  1354 		{//-- print information about all drives in the system
  1405 		for (nDrv=0; nDrv < KMaxDrives; nDrv++)
  1355 		for (nDrv=0; nDrv < KMaxDrives; nDrv++)
  1406 			{
  1356 			{
  1407 			if(!driveList[nDrv])
  1357 			if(!driveList[nDrv])
  1408 				continue;   //-- skip unexisting drive
  1358 				continue;   //-- skip unexisting drive
  1409 
  1359 
  1410 			PrintDrvInfo(TheShell->TheFs, nDrv);
  1360 			PrintDrvInfo(TheShell->TheFs, nDrv, CShell::TheConsole);
  1411 
  1361 
  1412 			if(aSwitches & TShellCommand::EPSwitch)
  1362 			if(aSwitches & TShellCommand::EPSwitch)
  1413 				{//-- /p switch, pause after each drive
  1363 				{//-- /p switch, pause after each drive
  1414                 CShell::Printf(_L("\n--- press any key to continue or Esc to exit ---\n"));
  1364 				CShell::TheConsole->Printf(_L("\n--- press any key to continue or Esc to exit ---\n"));
  1415 
  1365 
  1416 				TKeyCode key = CShell::TheConsole->Getch();
  1366 				TKeyCode key = CShell::TheConsole->Getch();
  1417 				if (key==EKeyEscape)
  1367 				if (key==EKeyEscape)
  1418 					break;
  1368 					break;
  1419 				}
  1369 				}
  1420 			else
  1370 			else
  1421 				{
  1371 				{
  1422 				CShell::Printf(_L("\n----------\n"));
  1372 				CShell::TheConsole->Printf(_L("\n----------\n"));
  1423                 CShell::Printf(_L("\n--- press any key to continue or Esc to exit ---\n"));
       
  1424 
       
  1425 				}
  1373 				}
  1426 		}
  1374 		}
  1427 	}
  1375 	}
  1428 
  1376 
  1429 	return KErrNone;
  1377 	return KErrNone;
  1468 
  1416 
  1469 
  1417 
  1470 
  1418 
  1471 
  1419 
  1472 //-----------------------------------------------------------------------------------------------------------------------
  1420 //-----------------------------------------------------------------------------------------------------------------------
  1473 TInt DoDismountFS(RFs& aFs, TInt aDrvNum, TBool aForceDismount)
  1421 TInt DoDismountFS(RFs& aFs, TInt aDrvNum)
  1474 {
  1422 {
  1475     TInt        nRes;
  1423     TInt        nRes;
  1476     TBuf<40>    fsName;
  1424     TBuf<40>    fsName;
  1477 
  1425 
  1478     nRes = aFs.FileSystemName(fsName, aDrvNum);
  1426     nRes = aFs.FileSystemName(fsName, aDrvNum);
  1479 
  1427 
  1480     if(nRes != KErrNone)
  1428     if(nRes != KErrNone)
  1481         return KErrNotFound;//-- nothing to dismount
  1429         return KErrNotFound;//-- nothing to dismount
  1482         
  1430         
  1483     if(!aForceDismount)    
       
  1484     {//-- gaceful attempt to dismount the FS
       
  1485     nRes = aFs.DismountFileSystem(fsName, aDrvNum);
  1431     nRes = aFs.DismountFileSystem(fsName, aDrvNum);
  1486     if(nRes != KErrNone)
  1432     if(nRes != KErrNone)
  1487     {
  1433     {
  1488         CShell::TheConsole->Printf(_L("Can't dismount FS!\n"));
  1434         CShell::TheConsole->Printf(_L("Can't dismount FS!\n"));
  1489         return nRes;
  1435         return nRes;
  1490     }
  1436     }
  1491     else
  1437     else
  1492     {
  1438     {
  1493     CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
  1439     CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
  1494     return KErrNone;
  1440     return KErrNone;
  1495     }
       
  1496 }
       
  1497     else
       
  1498     {//-- dismount by force
       
  1499         TRequestStatus rqStat;
       
  1500         aFs.NotifyDismount(aDrvNum, rqStat, EFsDismountForceDismount);  
       
  1501         User::WaitForRequest(rqStat);
       
  1502         
       
  1503         CShell::TheConsole->Printf(_L("'%S' filesystem Forcedly dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
       
  1504 
       
  1505         return rqStat.Int(); 
       
  1506     }
  1441     }
  1507 }
  1442 }
  1508 
  1443 
  1509 //-----------------------------------------------------------------------------------------------------------------------
  1444 //-----------------------------------------------------------------------------------------------------------------------
  1510 TInt DoRemountFS(RFs& aFs, TInt aDrvNum)
  1445 TInt DoRemountFS(RFs& aFs, TInt aDrvNum)
  1546             return KErrNotSupported;
  1481             return KErrNotSupported;
  1547         }
  1482         }
  1548     }
  1483     }
  1549 
  1484 
  1550     //-- 4. dismount the file system
  1485     //-- 4. dismount the file system
  1551     nRes = DoDismountFS(aFs, aDrvNum, EFalse);
  1486     nRes = DoDismountFS(aFs, aDrvNum);
  1552     if(nRes != KErrNone)
  1487     if(nRes != KErrNone)
  1553         return nRes;
  1488         return nRes;
  1554 
  1489 
  1555     //-- 5. mount the FS back
  1490     //-- 5. mount the FS back
  1556     if(pextName.Length() > 0)
  1491     if(pextName.Length() > 0)
  1578 
  1513 
  1579 //-----------------------------------------------------------------------------------------------------------------------
  1514 //-----------------------------------------------------------------------------------------------------------------------
  1580 /**
  1515 /**
  1581     Mount or dismount the file system on the specified drive.
  1516     Mount or dismount the file system on the specified drive.
  1582 
  1517 
  1583     MOUNT <DriveLetter:[\]> <FSY:xxx> <FS:yyy> [PEXT:zzz] [/S] [/U] [/F]
  1518     MOUNT <DriveLetter:[\]> <FSY:xxx> <FS:yyy> [PEXT:zzz] [/S] [/U]
  1584   
  1519   
  1585     xxx is the *.fsy file system plugin name, like "elocal.fsy" or "elocal"
  1520     xxx is the *.fsy file system plugin name, like "elocal.fsy" or "elocal"
  1586     yyy is the file system name that the fsy module exports, like "FAT"
  1521     yyy is the file system name that the fsy module exports, like "FAT"
  1587     zzz is the optional parameter that specifies primary extension name
  1522     zzz is the optional parameter that specifies primary extension name
  1588 
  1523 
  1589     /u dismounts a filesystem on the specified drive; e.g. "mount d: /u"
  1524     /u dismounts a filesystem on the specified drive; e.g. "mount d: /u"
  1590         additional switch /f in conjunction with /u will perform "forced unmounting" i.e. unmounting the FS 
  1525     /s for mounting FS specifies that the drive will be mounted as synchronous one.
  1591         even it has opened files and / or directories. E.g. "mount d: /u /f"
  1526     /f for forcing mounting the FS; the previous one will be automatically dismounted
  1592 
  1527     /r remount existing FS (dismount and mount it back)
  1593     
       
  1594     /s for mounting FS specifies that the drive will be mounted as a synchronous one.
       
  1595         
       
  1596 
       
  1597     /f for forcing mounting the FS; the previous one will be automatically dismounted. 
       
  1598         example: "mount d: /f fsy:exfat fs:exfat" this command will dismount whatever FS ic currently mounted and 
       
  1599         mount exFAT FS instead
       
  1600 
       
  1601 
       
  1602     
       
  1603     /r remount existing FS (dismount and mount it back); example: "mount d: /r"
       
  1604 */
  1528 */
  1605 TInt ShellFunction::MountFileSystem(TDes& aArgs, TUint aSwitches)
  1529 TInt ShellFunction::MountFileSystem(TDes& aArgs, TUint aSwitches)
  1606 {
  1530 {
  1607 	ShellFunction::StripQuotes(aArgs);
  1531 	ShellFunction::StripQuotes(aArgs);
  1608     aArgs.UpperCase();
  1532     aArgs.UpperCase();
  1633     {
  1557     {
  1634         nRes = DoRemountFS(fs, drvNum);
  1558         nRes = DoRemountFS(fs, drvNum);
  1635         return nRes;
  1559         return nRes;
  1636     }
  1560     }
  1637     
  1561     
  1638     //-- check if we dismounting the FS (/U switch).
  1562     //-- check if we dismounting the FS (/U switch)
  1639     if(aSwitches & TShellCommand::EUSwitch)
  1563     if(aSwitches & TShellCommand::EUSwitch)
  1640     {//-- also take nto account "/f" switch for forced dismounting
  1564     {
  1641         nRes = DoDismountFS(fs, drvNum, (aSwitches & TShellCommand::EFSwitch));
  1565         nRes = DoDismountFS(fs, drvNum);
  1642         
  1566         
  1643         if(nRes == KErrNotFound)
  1567         if(nRes == KErrNotFound)
  1644         {//-- nothing to dismount
  1568         {//-- nothing to dismount
  1645             CShell::TheConsole->Printf(_L("specified drive doesn't have FS mounted\n"));
  1569             CShell::TheConsole->Printf(_L("specified drive doesn't have FS mounted\n"));
  1646             return KErrNone;
  1570             return KErrNone;
  1650     }
  1574     }
  1651     
  1575     
  1652     //-- check if we need to forcedly dismount the existing FS (/F switch)
  1576     //-- check if we need to forcedly dismount the existing FS (/F switch)
  1653     if(aSwitches & TShellCommand::EFSwitch)
  1577     if(aSwitches & TShellCommand::EFSwitch)
  1654     {
  1578     {
  1655         nRes = DoDismountFS(fs, drvNum, EFalse);
  1579         nRes = DoDismountFS(fs, drvNum);
  1656         
  1580         
  1657         if(nRes != KErrNotFound && nRes !=KErrNone)
  1581         if(nRes != KErrNotFound && nRes !=KErrNone)
  1658             return nRes;
  1582             return nRes;
  1659     }
  1583     }
  1660 
  1584 
  1736         CShell::TheConsole->Printf(_L("Error mounting the filesystem! (%d)\n"), nRes);
  1660         CShell::TheConsole->Printf(_L("Error mounting the filesystem! (%d)\n"), nRes);
  1737         return nRes;
  1661         return nRes;
  1738     }
  1662     }
  1739 
  1663 
  1740 
  1664 
  1741     PrintDrvInfo(fs, drvNum, EFSInfo | EVolInfo);
  1665     PrintDrvInfo(fs, drvNum, CShell::TheConsole, EFSInfo | EVolInfo);
  1742 
  1666 
  1743     return KErrNone;
  1667     return KErrNone;
  1744 }
  1668 }
  1745 
  1669 
  1746 
  1670 
  2052     
  1976     
  2053     return nRes;
  1977     return nRes;
  2054     }
  1978     }
  2055 
  1979 
  2056 //-----------------------------------------------------------------------------------------------------------------------
  1980 //-----------------------------------------------------------------------------------------------------------------------
  2057 /**
  1981 
  2058     Hex Dump of a file
       
  2059 */
       
  2060 TInt ShellFunction::Hexdump(TDes& aPath,TUint aSwitches)
  1982 TInt ShellFunction::Hexdump(TDes& aPath,TUint aSwitches)
  2061 	{
  1983 	{
  2062 	ShellFunction::StripQuotes(aPath);
  1984 	ShellFunction::StripQuotes(aPath);
  2063 
  1985 
  2064 	ParsePath(aPath);
  1986 	ParsePath(aPath);
  2065 	
       
  2066 	RFile64 file;
  1987 	RFile64 file;
  2067 	TInt r=file.Open(TheShell->TheFs,aPath,EFileStream);
  1988 	TInt r=file.Open(TheShell->TheFs,aPath,EFileStream);
  2068 	if (r!=KErrNone)
  1989 	if (r!=KErrNone)
  2069 		return(r);
  1990 		return(r);
  2070 
  1991 
       
  1992 	TInt offset=0;
       
  1993 	for (;;)
       
  1994 		{
  2071 		const TInt KLineLength = 16;
  1995 		const TInt KLineLength = 16;
  2072     TBuf<0x100> buf;
  1996 
  2073     TBuf<KLineLength> asciiBuf;
       
  2074 		TBuf8<KLineLength> line;
  1997 		TBuf8<KLineLength> line;
  2075 
       
  2076 	for (;;)
       
  2077 		{
       
  2078 		r=file.Read(line);
  1998 		r=file.Read(line);
  2079 		if (r != KErrNone || line.Length() == 0)
  1999 		if (r != KErrNone || line.Length() == 0)
  2080 			break;
  2000 			break;
  2081 
  2001 
  2082 		buf.Zero();
  2002 		TBuf<KLineLength*3+2> hexaRep;
  2083         asciiBuf.Zero();
  2003 		TBuf<KLineLength> asciiRep;
  2084 		
       
  2085 		for (TInt i=0; i<KLineLength; i++)
  2004 		for (TInt i=0; i<KLineLength; i++)
  2086 			{
  2005 			{
  2087 			if (i == KLineLength/2)
  2006 			if (i == KLineLength/2)
  2088 				{
  2007 				{
  2089 				buf.Append(' ');
  2008 				hexaRep.Append(' ');
  2090 				buf.Append(i<line.Length() ? '|' : ' ');
  2009 				hexaRep.Append(i<line.Length() ? '|' : ' ');
  2091 				}
  2010 				}
  2092 
  2011 
  2093             buf.Append(' ');
  2012 			hexaRep.Append(' ');
  2094 
  2013 
  2095 			if (i<line.Length())
  2014 			if (i<line.Length())
  2096 				{
  2015 				{
  2097 				buf.AppendNumFixedWidth(line[i], EHex, 2);
  2016 				hexaRep.AppendNumFixedWidth(line[i], EHex, 2);
  2098 				asciiBuf.Append(TChar(line[i]).IsPrint() ? line[i] : '.');
  2017 				asciiRep.Append(TChar(line[i]).IsPrint() ? line[i] : '.');
  2099 				}
  2018 				}
  2100 			else
  2019 			else
  2101 				buf.AppendFill(' ', 2);
  2020 				hexaRep.AppendFill(' ', 2);
  2102 			}
  2021 			}
  2103 
  2022 
  2104 		_LIT(KPrompt , " Hit escape to quit hexdump or any other key to continue\n");
  2023 		_LIT(KPrompt , " Hit escape to quit hexdump or any other key to continue\n");
  2105 		
  2024 		_LIT(KLineFmt, " %+07x0:%S %S\n");
  2106         buf.Append(_L(" "));
  2025 		TKeyCode key=CShell::OutputStringToConsole(KPrompt ,(aSwitches&TShellCommand::EPSwitch)!=0,KLineFmt, offset++,&hexaRep, &asciiRep);
  2107         buf.Append(asciiBuf);
  2026 
  2108         buf.Append(KNl);
       
  2109 
       
  2110         TKeyCode key= CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, buf, KPrompt);
       
  2111 		if (key==EKeyEscape)
  2027 		if (key==EKeyEscape)
  2112 				break;
  2028 				break;
  2113 		}
  2029 		}
  2114 
  2030 
  2115 	if (r == KErrNone)
  2031 	if (r == KErrNone)
  2209     if(r != KErrNone)
  2125     if(r != KErrNone)
  2210         goto fail;
  2126         goto fail;
  2211 
  2127 
  2212 
  2128 
  2213     if(!(aSwitches&TShellCommand::EESwitch))
  2129     if(!(aSwitches&TShellCommand::EESwitch))
  2214     {//-- fill created file with random data
  2130     {//-- fill created file with randomn data
  2215 
  2131 
  2216 	    while(rem)
  2132 	    while(rem)
  2217 	    {
  2133 	    {
  2218 	        const TInt s=(TInt)Min((TInt64)KBufSize, rem);
  2134 	        const TInt s=(TInt)Min((TInt64)KBufSize, rem);
  2219 
  2135 
  2432 	{
  2348 	{
  2433 public:
  2349 public:
  2434 	TInt DisplayHelp();
  2350 	TInt DisplayHelp();
  2435 	TInt DisplayMessage(const TFullName& aName);
  2351 	TInt DisplayMessage(const TFullName& aName);
  2436 	TInt DisplayCmdUnknown();
  2352 	TInt DisplayCmdUnknown();
  2437 	void GetAll(const TDes& aName);
  2353 	TInt GetAll(const TDes& aName);
  2438 	void GetProcesses(const TDes& aName);
  2354 	TInt GetProcesses(const TDes& aName);
  2439 	void GetThreads(const TDes& aName);
  2355 	TInt GetThreads(const TDes& aName);
  2440 	void GetChunks(const TDes& aName);
  2356 	TInt GetChunks(const TDes& aName);
  2441 	void GetServers(const TDes& aName);
  2357 	TInt GetServers(const TDes& aName);
  2442 //	TInt GetSessions(const TDes& aName);
  2358 //	TInt GetSessions(const TDes& aName);
  2443 	void GetLibraries(const TDes& aName);
  2359 	TInt GetLibraries(const TDes& aName);
  2444 //	TInt GetLogicalChannels(const TDes& aName);
  2360 //	TInt GetLogicalChannels(const TDes& aName);
  2445 	void GetLogicalDevices(const TDes& aName);
  2361 	TInt GetLogicalDevices(const TDes& aName);
  2446 	void GetPhysicalDevices(const TDes& aName);
  2362 	TInt GetPhysicalDevices(const TDes& aName);
  2447 	void GetSemaphores(const TDes& aName);
  2363 	TInt GetSemaphores(const TDes& aName);
  2448 	void GetMutexes(const TDes& aName);
  2364 	TInt GetMutexes(const TDes& aName);
  2449 private:
  2365 private:
  2450 	void DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription);
  2366 	void DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription);
  2451 	TBool Prepare(const TFullName& aName);
  2367 	TInt Prepare(const TFullName& aName);
  2452 	TBool Prepare(const TFullName& aName,TCallBack& aCallBack);
  2368 	TInt Prepare(const TFullName& aName,TCallBack& aCallBack);
  2453 	TInt Display(TFullName& aName);
  2369 	TInt Display(TFullName& aName);
  2454 	TFullName iPrevName;
  2370 	TFullName iPrevName;
  2455 	TCallBack iCallBack;
  2371 	TCallBack iCallBack;
  2456 	TBool useCallBack;
  2372 	TBool useCallBack;
  2457 	};
  2373 	};
  2489 	{
  2405 	{
  2490 	CShell::OutputStringToConsole(ETrue,_L("Not supported\n"));
  2406 	CShell::OutputStringToConsole(ETrue,_L("Not supported\n"));
  2491 	return KErrNone;
  2407 	return KErrNone;
  2492 	}
  2408 	}
  2493 
  2409 
  2494 void TShowProcInfo::GetAll(const TDes& aName)
  2410 TInt TShowProcInfo::GetAll(const TDes& aName)
  2495 	{
  2411 	{
       
  2412 
  2496 	GetProcesses(aName);
  2413 	GetProcesses(aName);
  2497 	GetThreads(aName);
  2414 	GetThreads(aName);
  2498 	GetChunks(aName);
  2415 	GetChunks(aName);
  2499 	GetServers(aName);
  2416 	GetServers(aName);
  2500 //	GetSessions(aName);
  2417 //	GetSessions(aName);
  2502 //	GetLogicalChannels(aName);
  2419 //	GetLogicalChannels(aName);
  2503 	GetLogicalDevices(aName);
  2420 	GetLogicalDevices(aName);
  2504 	GetPhysicalDevices(aName);
  2421 	GetPhysicalDevices(aName);
  2505 	GetSemaphores(aName);
  2422 	GetSemaphores(aName);
  2506 	GetMutexes(aName);
  2423 	GetMutexes(aName);
  2507 
  2424 	return KErrNone;
  2508 	}
  2425 	}
  2509 
  2426 
  2510 void TShowProcInfo::GetProcesses(const TDes& aName)
  2427 TInt TShowProcInfo::GetProcesses(const TDes& aName)
  2511 	{
  2428 	{
  2512 
  2429 
  2513 	TFindProcess findHb;
  2430 	TFindProcess findHb;
  2514 	findHb.Find(aName);
  2431 	findHb.Find(aName);
  2515 	TFullName name;
  2432 	TFullName name;
  2516 	
  2433 	Prepare(_L("PROCESSES"));
  2517     if(!Prepare(_L("PROCESSES")))
       
  2518        return;
       
  2519 
       
  2520 	while (findHb.Next(name)==KErrNone)
  2434 	while (findHb.Next(name)==KErrNone)
  2521 		{
  2435 		{
  2522 		Display(name);
  2436 		Display(name);
  2523 		}
  2437 		}
  2524 
  2438 	return KErrNone;
  2525 	}
  2439 	}
  2526 
  2440 
  2527 void TShowProcInfo::GetThreads(const TDes& aName)
  2441 TInt TShowProcInfo::GetThreads(const TDes& aName)
  2528 	{
  2442 	{
  2529 	TInt threads=0;
  2443 	TInt threads=0;
  2530 	TFindThread findHb;
  2444 	TFindThread findHb;
  2531 	findHb.Find(aName);
  2445 	findHb.Find(aName);
  2532 	TFullName name;
  2446 	TFullName name;
  2533 	TAny* findPtr=(TAny*)&findHb;
  2447 	TAny* findPtr=(TAny*)&findHb;
  2534 
  2448 
  2535 //	Modified by WR, November 1997
  2449 //	Modified by WR, November 1997
  2536 	TCallBack threadCallBack(GetThreadInfo,findPtr);
  2450 	TCallBack threadCallBack(GetThreadInfo,findPtr);
  2537 	
  2451 	Prepare(_L("THREADS"),threadCallBack);
  2538     if(!Prepare(_L("THREADS"),threadCallBack))
       
  2539         return;
       
  2540 
       
  2541 	while (findHb.Next(name)==KErrNone)
  2452 	while (findHb.Next(name)==KErrNone)
  2542 		{
  2453 		{
  2543 		Display(name);
  2454 		Display(name);
  2544 		threads += 1;
  2455 		threads += 1;
  2545 		}
  2456 		}
  2547 		{
  2458 		{
  2548 		TFullName message;
  2459 		TFullName message;
  2549 		message.Format(_L("? No threads called %S"), &aName);
  2460 		message.Format(_L("? No threads called %S"), &aName);
  2550 		DisplayMessage(message);
  2461 		DisplayMessage(message);
  2551 		}
  2462 		}
  2552 	
  2463 	return KErrNone;
  2553     
  2464 //	End of modification
  2554 	}
  2465 	}
  2555 
  2466 
  2556 
  2467 
  2557 void TShowProcInfo::GetChunks(const TDes& aName)
  2468 TInt TShowProcInfo::GetChunks(const TDes& aName)
  2558 	{
  2469 	{
  2559 
  2470 
  2560 	TFindChunk findHb;
  2471 	TFindChunk findHb;
  2561 	findHb.Find(aName);
  2472 	findHb.Find(aName);
  2562 	TFullName name;
  2473 	TFullName name;
  2563 	TAny* namePtr=(TAny*)&name;
  2474 	TAny* namePtr=(TAny*)&name;
  2564 	TCallBack chunkCallBack(GetChunkInfo,namePtr);
  2475 	TCallBack chunkCallBack(GetChunkInfo,namePtr);
  2565 	
  2476 	Prepare(_L("CHUNKS & SIZES"),chunkCallBack);
  2566     if(!Prepare(_L("CHUNKS & SIZES"),chunkCallBack))
       
  2567         return;
       
  2568 
       
  2569 	TInt totalChunkSize=0;
  2477 	TInt totalChunkSize=0;
  2570 	TInt protectedChunks = 0;
  2478 	TInt protectedChunks = 0;
  2571 	while (findHb.Next(name)==KErrNone)
  2479 	while (findHb.Next(name)==KErrNone)
  2572 		{
  2480 		{
  2573 		Display(name);
  2481 		Display(name);
  2590 */
  2498 */
  2591 		}
  2499 		}
  2592 	CShell::OutputStringToConsole(ETrue,_L("  Total Chunk Size = %dk\n"),totalChunkSize);
  2500 	CShell::OutputStringToConsole(ETrue,_L("  Total Chunk Size = %dk\n"),totalChunkSize);
  2593 	if(protectedChunks)
  2501 	if(protectedChunks)
  2594 		CShell::OutputStringToConsole(ETrue,_L("  %d Protected chunks not counted\n"),protectedChunks);
  2502 		CShell::OutputStringToConsole(ETrue,_L("  %d Protected chunks not counted\n"),protectedChunks);
  2595 	
  2503 	return KErrNone;
  2596     
  2504 	}
  2597 	}
  2505 
  2598 
  2506 TInt TShowProcInfo::GetServers(const TDes& aName)
  2599 void TShowProcInfo::GetServers(const TDes& aName)
       
  2600 	{
  2507 	{
  2601 
  2508 
  2602 	TFindServer findHb;
  2509 	TFindServer findHb;
  2603 	findHb.Find(aName);
  2510 	findHb.Find(aName);
  2604 	TFullName name;
  2511 	TFullName name;
  2605 	if(!Prepare(_L("SERVERS")))
  2512 	Prepare(_L("SERVERS"));
  2606         return;
       
  2607 
       
  2608 	while (findHb.Next(name)==KErrNone)
  2513 	while (findHb.Next(name)==KErrNone)
  2609 		{
  2514 		{
  2610 		Display(name);
  2515 		Display(name);
  2611 		}
  2516 		}
       
  2517 	return KErrNone;
  2612 	}
  2518 	}
  2613 
  2519 
  2614 /*	TInt TShowProcInfo::GetSessions(const TDes& aName)
  2520 /*	TInt TShowProcInfo::GetSessions(const TDes& aName)
  2615 	{
  2521 	{
  2616 
  2522 
  2623 		Display(name);
  2529 		Display(name);
  2624 		}
  2530 		}
  2625 	return KErrNone;
  2531 	return KErrNone;
  2626 	}
  2532 	}
  2627 */
  2533 */
  2628 void TShowProcInfo::GetLibraries(const TDes& aName)
  2534 TInt TShowProcInfo::GetLibraries(const TDes& aName)
  2629 	{
  2535 	{
  2630 
  2536 
  2631 	TFindLibrary findHb;
  2537 	TFindLibrary findHb;
  2632 	findHb.Find(aName);
  2538 	findHb.Find(aName);
  2633 	TFullName name;
  2539 	TFullName name;
  2634 	if(!Prepare(_L("LIBRARIES")))
  2540 	Prepare(_L("LIBRARIES"));
  2635         return;
       
  2636 
       
  2637 	while (findHb.Next(name)==KErrNone)
  2541 	while (findHb.Next(name)==KErrNone)
  2638 		{
  2542 		{
  2639 		Display(name);
  2543 		Display(name);
  2640 		}
  2544 		}
  2641 	
  2545 	return KErrNone;
  2642 	}
  2546 	}
  2643 /*
  2547 /*
  2644 TInt TShowProcInfo::GetLogicalChannels(const TDes& aName)
  2548 TInt TShowProcInfo::GetLogicalChannels(const TDes& aName)
  2645 	{
  2549 	{
  2646 
  2550 
  2654 		}
  2558 		}
  2655 	return KErrNone;
  2559 	return KErrNone;
  2656 	}
  2560 	}
  2657 */
  2561 */
  2658 
  2562 
  2659 void TShowProcInfo::GetLogicalDevices(const TDes& aName)
  2563 TInt TShowProcInfo::GetLogicalDevices(const TDes& aName)
  2660 	{
  2564 	{
  2661 
  2565 
  2662 	TFindLogicalDevice findHb;
  2566 	TFindLogicalDevice findHb;
  2663 	findHb.Find(aName);
  2567 	findHb.Find(aName);
  2664 	TFullName name;
  2568 	TFullName name;
  2665 
  2569 	Prepare(_L("LOGICAL DEVICES"));
  2666 	if(!Prepare(_L("LOGICAL DEVICES")))
       
  2667         return;
       
  2668 
       
  2669 	while (findHb.Next(name)==KErrNone)
  2570 	while (findHb.Next(name)==KErrNone)
  2670 		{
  2571 		{
  2671 		Display(name);
  2572 		Display(name);
  2672 		}
  2573 		}
  2673 	
  2574 	return KErrNone;
  2674 	}
  2575 	}
  2675 
  2576 
  2676 void TShowProcInfo::GetPhysicalDevices(const TDes& aName)
  2577 TInt TShowProcInfo::GetPhysicalDevices(const TDes& aName)
  2677 	{
  2578 	{
  2678 
  2579 
  2679 	TFindPhysicalDevice findHb;
  2580 	TFindPhysicalDevice findHb;
  2680 	findHb.Find(aName);
  2581 	findHb.Find(aName);
  2681 	TFullName name;
  2582 	TFullName name;
  2682 	
  2583 	Prepare(_L("PHYSICAL DEVICES"));
  2683     if(!Prepare(_L("PHYSICAL DEVICES")))
       
  2684         return;
       
  2685 
       
  2686 	while (findHb.Next(name)==KErrNone)
  2584 	while (findHb.Next(name)==KErrNone)
  2687 		{
  2585 		{
  2688 		Display(name);
  2586 		Display(name);
  2689 		}
  2587 		}
  2690 	
  2588 	return KErrNone;
  2691 	}
  2589 	}
  2692 
  2590 
  2693 void TShowProcInfo::GetSemaphores(const TDes& aName)
  2591 TInt TShowProcInfo::GetSemaphores(const TDes& aName)
  2694 	{
  2592 	{
  2695 	TFindSemaphore findHb;
  2593 	TFindSemaphore findHb;
  2696 	findHb.Find(aName);
  2594 	findHb.Find(aName);
  2697 	TFullName name;
  2595 	TFullName name;
  2698 	if(!Prepare(_L("SEMAPHORES")))
  2596 	Prepare(_L("SEMAPHORES"));
  2699         return;
       
  2700 
       
  2701 	while (findHb.Next(name)==KErrNone)
  2597 	while (findHb.Next(name)==KErrNone)
  2702 		{
  2598 		{
  2703 		Display(name);
  2599 		Display(name);
  2704 		}
  2600 		}
  2705 	
  2601 	return KErrNone;
  2706 	}
  2602 	}
  2707 
  2603 
  2708 void TShowProcInfo::GetMutexes(const TDes& aName)
  2604 TInt TShowProcInfo::GetMutexes(const TDes& aName)
  2709 	{
  2605 	{
  2710 
  2606 
  2711 	TFindMutex findHb;
  2607 	TFindMutex findHb;
  2712 	findHb.Find(aName);
  2608 	findHb.Find(aName);
  2713 	TFullName name;
  2609 	TFullName name;
  2714 	if(!Prepare(_L("MUTEXES")))
  2610 	Prepare(_L("MUTEXES"));
  2715         return;
       
  2716 	while (findHb.Next(name)==KErrNone)
  2611 	while (findHb.Next(name)==KErrNone)
  2717 		{
  2612 		{
  2718 		Display(name);
  2613 		Display(name);
  2719 		}
  2614 		}
  2720 	
  2615 	return KErrNone;
  2721 	}
  2616 	}
  2722 
  2617 
  2723 void TShowProcInfo::DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription)
  2618 void TShowProcInfo::DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription)
  2724 	{
  2619 	{
  2725 	CShell::OutputStringToConsole(ETrue,_L("%- *S%S\n"),8,&aCommand,&aDescription);
  2620 	CShell::OutputStringToConsole(ETrue,_L("%- *S%S\n"),8,&aCommand,&aDescription);
  2726 	}
  2621 	}
  2727 
  2622 
  2728 
  2623 
  2729 TBool TShowProcInfo::Prepare(const TFullName& aName)
  2624 TInt TShowProcInfo::Prepare(const TFullName& aName)
  2730 	{
  2625 	{
  2731 
  2626 
  2732 	iPrevName=_L("");
  2627 	iPrevName=_L("");
  2733 	TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
  2628 	CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
  2734     
       
  2735     if(key==EKeyEscape)
       
  2736         return EFalse;
       
  2737 
       
  2738 	useCallBack=EFalse;
  2629 	useCallBack=EFalse;
  2739     return ETrue;
  2630 	return KErrNone;
  2740 	}
  2631 	}
  2741 
  2632 
  2742 TBool  TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack)
  2633 TInt TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack)
  2743 	{
  2634 	{
       
  2635 
  2744 	iPrevName=_L("");
  2636 	iPrevName=_L("");
  2745 	TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
  2637 	CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName);
  2746 
       
  2747     if(key==EKeyEscape)
       
  2748         return EFalse;
       
  2749 	
       
  2750     
       
  2751 	useCallBack=ETrue;
  2638 	useCallBack=ETrue;
  2752 	iCallBack=aCallBack;
  2639 	iCallBack=aCallBack;
  2753 	
  2640 	return KErrNone;
  2754     return ETrue;
       
  2755 	}
  2641 	}
  2756 
  2642 
  2757 TInt TShowProcInfo::Display(TFullName& aName)
  2643 TInt TShowProcInfo::Display(TFullName& aName)
  2758 
  2644 
  2759 //	Modifications by WR, November 1997
  2645 //	Modifications by WR, November 1997
  2782 				break;
  2668 				break;
  2783 			}
  2669 			}
  2784 		while (posA>=0)
  2670 		while (posA>=0)
  2785 			{
  2671 			{
  2786 			TPtrC16 temp_desc=aName.Left(posA);
  2672 			TPtrC16 temp_desc=aName.Left(posA);
  2787 			
  2673 			CShell::OutputStringToConsole(ETrue,_L("%+ *S\n"),toTab+temp_desc.Left(posA).Length(),&temp_desc);
  2788             TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("%+ *S\n"),toTab+temp_desc.Left(posA).Length(),&temp_desc);
       
  2789 			if (key==EKeyEscape)
       
  2790 			    break;
       
  2791 
       
  2792 			toTab+=3;
  2674 			toTab+=3;
  2793 			aName.Delete(0,posA+2);
  2675 			aName.Delete(0,posA+2);
  2794 			posA=aName.Match(_L("*::*"));
  2676 			posA=aName.Match(_L("*::*"));
  2795 			}
  2677 			}
  2796 		}
  2678 		}
  2817     TBuf<0x1> asterisk=_L("*");
  2699     TBuf<0x1> asterisk=_L("*");
  2818 	TName processPrefix=asterisk;
  2700 	TName processPrefix=asterisk;
  2819 	TBool abort=EFalse;
  2701 	TBool abort=EFalse;
  2820 	TBool processSelected=EFalse;
  2702 	TBool processSelected=EFalse;
  2821 	TBuf<0x16> prompt=_L("ps>");
  2703 	TBuf<0x16> prompt=_L("ps>");
  2822 	showProcInfo.GetProcesses(processPrefix);
  2704 	r=showProcInfo.GetProcesses(processPrefix);
  2823 	do
  2705 	do
  2824 		{
  2706 		{
  2825 		TBuf<0x10> command;
  2707 		TBuf<0x10> command;
  2826 		CShell::TheEditor->Edit(prompt, &command, ETrue);
  2708 		CShell::TheEditor->Edit(prompt, &command, ETrue);
  2827 		while (command.Length() && !abort && r==KErrNone)
  2709 		while (command.Length() && !abort && r==KErrNone)
  2879 					else
  2761 					else
  2880 						{
  2762 						{
  2881 						if (findP.Next(findName)==KErrNone)
  2763 						if (findP.Next(findName)==KErrNone)
  2882 							{
  2764 							{
  2883 							r=showProcInfo.DisplayMessage(_L("command prefixes more than one process"));
  2765 							r=showProcInfo.DisplayMessage(_L("command prefixes more than one process"));
  2884 							showProcInfo.GetProcesses(chosenP);
  2766 							r=showProcInfo.GetProcesses(chosenP);
  2885 							}
  2767 							}
  2886 						else
  2768 						else
  2887 							{
  2769 							{
  2888 							processSelected=ETrue;
  2770 							processSelected=ETrue;
  2889 							processPrefix=chosenP;
  2771 							processPrefix=chosenP;
  2893 						}
  2775 						}
  2894 					}
  2776 					}
  2895 					break;
  2777 					break;
  2896 				case 'A':
  2778 				case 'A':
  2897 					{
  2779 					{
  2898 					showProcInfo.GetAll(processPrefix);
  2780 					r=showProcInfo.GetAll(processPrefix);
  2899 					command.Zero();
  2781 					command.Zero();
  2900 					}
  2782 					}
  2901 					break;
  2783 					break;
  2902 				case 'P':
  2784 				case 'P':
  2903 					showProcInfo.GetProcesses(asterisk);
  2785 					r=showProcInfo.GetProcesses(asterisk);
  2904 					break;
  2786 					break;
  2905 				case 'T':
  2787 				case 'T':
  2906 					showProcInfo.GetThreads(processPrefix);
  2788 					r=showProcInfo.GetThreads(processPrefix);
  2907 					break;
  2789 					break;
  2908 				case 'C':
  2790 				case 'C':
  2909 					showProcInfo.GetChunks(processPrefix);
  2791 					r=showProcInfo.GetChunks(processPrefix);
  2910 					break;
  2792 					break;
  2911 				case 'S':
  2793 				case 'S':
  2912 					showProcInfo.GetServers(processPrefix);
  2794 					r=showProcInfo.GetServers(processPrefix);
  2913 					break;
  2795 					break;
  2914 /*				case 'I':
  2796 /*				case 'I':
  2915 					r=showProcInfo.GetSessions(processPrefix);
  2797 					r=showProcInfo.GetSessions(processPrefix);
  2916 					break;
  2798 					break;
  2917 */				case 'L':
  2799 */				case 'L':
  2918 					showProcInfo.GetLibraries(processPrefix);
  2800 					r=showProcInfo.GetLibraries(processPrefix);
  2919 					break;
  2801 					break;
  2920 //				case 'G':
  2802 //				case 'G':
  2921 //					r=showProcInfo.GetLogicalChannels(processPrefix);
  2803 //					r=showProcInfo.GetLogicalChannels(processPrefix);
  2922 //					break;
  2804 //					break;
  2923 				case 'V':
  2805 				case 'V':
  2924 					showProcInfo.GetLogicalDevices(processPrefix);
  2806 					r=showProcInfo.GetLogicalDevices(processPrefix);
  2925 					break;
  2807 					break;
  2926 				case 'D':
  2808 				case 'D':
  2927 					showProcInfo.GetPhysicalDevices(processPrefix);
  2809 					r=showProcInfo.GetPhysicalDevices(processPrefix);
  2928 					break;
  2810 					break;
  2929 				case 'E':
  2811 				case 'E':
  2930 					showProcInfo.GetSemaphores(processPrefix);
  2812 					r=showProcInfo.GetSemaphores(processPrefix);
  2931 					break;
  2813 					break;
  2932 				case 'M':
  2814 				case 'M':
  2933 					showProcInfo.GetMutexes(processPrefix);
  2815 					r=showProcInfo.GetMutexes(processPrefix);
  2934 					break;
  2816 					break;
  2935 				default:
  2817 				default:
  2936 					{
  2818 					{
  2937 					showProcInfo.DisplayCmdUnknown();
  2819 					showProcInfo.DisplayCmdUnknown();
  2938 					command.Zero();
  2820 					command.Zero();
  3232 	TUint8 c;
  3114 	TUint8 c;
  3233 	for (; p<pE; p+=2)
  3115 	for (; p<pE; p+=2)
  3234 		c=*p, *p=p[1], p[1]=c;
  3116 		c=*p, *p=p[1], p[1]=c;
  3235 	}
  3117 	}
  3236 
  3118 
       
  3119 _LIT(KLitPercentS, "%S");
  3237 TInt ShellFunction::Type(TDes& aPath,TUint aSwitches)
  3120 TInt ShellFunction::Type(TDes& aPath,TUint aSwitches)
  3238 	{
  3121 	{
  3239 	ParsePath(aPath);
  3122 	ParsePath(aPath);
  3240 	RFile64 file;
  3123 	RFile64 file;
  3241 	TInt r=file.Open(TheShell->TheFs,aPath,EFileStreamText|EFileShareReadersOnly);
  3124 	TInt r=file.Open(TheShell->TheFs,aPath,EFileStreamText|EFileShareReadersOnly);
  3293 			}
  3176 			}
  3294 		while ((r=buf.Locate('\n'))!=KErrNotFound)
  3177 		while ((r=buf.Locate('\n'))!=KErrNotFound)
  3295 			{
  3178 			{
  3296 			nchars=0;
  3179 			nchars=0;
  3297 			TPtrC bufLeft=buf.Left(r+1);
  3180 			TPtrC bufLeft=buf.Left(r+1);
  3298             key = CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, bufLeft);
  3181 			key = CShell::OutputStringToConsole((aSwitches&TShellCommand::EPSwitch)!=0,KLitPercentS(), &bufLeft);
  3299 			buf.Set(buf.Mid(r+1));
  3182 			buf.Set(buf.Mid(r+1));
  3300 	
  3183 	
  3301     		if(key == EKeyEscape) 
  3184     		if(key == EKeyEscape) 
  3302                 goto exit;
  3185                 goto exit;
  3303 			}
  3186 			}
  3304 
  3187 
  3305 		nchars=buf.Length();
  3188 		nchars=buf.Length();
  3306 		if (nchars)
  3189 		if (nchars)
  3307 			{
  3190 			{
  3308     		key = CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, buf);
  3191             key = CShell::OutputStringToConsole((aSwitches&TShellCommand::EPSwitch)!=0,KLitPercentS(), &buf);
  3309 
       
  3310     		if(key == EKeyEscape) 
  3192     		if(key == EKeyEscape) 
  3311                 goto exit;
  3193                 goto exit;
  3312 
  3194 
  3313             }
  3195             }
  3314 
  3196 
  3720 			}
  3602 			}
  3721 		}
  3603 		}
  3722 	return err;
  3604 	return err;
  3723 	}
  3605 	}
  3724 
  3606 
  3725 
  3607 _LIT(KCrNl, "\r\n");
  3726 
       
  3727 //----------------------------------------------------------------------
       
  3728 void CShell::Print(const TDesC16& aBuf)
       
  3729 {
       
  3730 
       
  3731     TheConsole->Write(aBuf);
       
  3732 
       
  3733     if(iDbgPrint)
       
  3734     {
       
  3735         const TInt bufLen = aBuf.Length();
       
  3736         
       
  3737         if(bufLen >1 && aBuf[bufLen-1] == '\n' && aBuf[bufLen-2] != '\r')
       
  3738             {
       
  3739             RDebug::RawPrint(aBuf.Left(bufLen-1));            
       
  3740             RDebug::RawPrint(_L8("\r\n"));
       
  3741             }
       
  3742         else if(bufLen == 1 && aBuf[bufLen-1] == '\n')
       
  3743             {
       
  3744             RDebug::RawPrint(_L8("\r\n"));
       
  3745             }
       
  3746         else
       
  3747             {
       
  3748             RDebug::RawPrint(aBuf);
       
  3749             }
       
  3750     }
       
  3751 
       
  3752 }
       
  3753 
       
  3754 void CShell::Printf(TRefByValue<const TDesC16> aFmt, ...)
       
  3755 {
       
  3756 	TBuf<0x200> buf;
       
  3757 	VA_LIST list;					
       
  3758 	VA_START(list, aFmt);
       
  3759 	// coverity[uninit_use_in_call]
       
  3760 	buf.FormatList(aFmt, list);			
       
  3761 
       
  3762     if(!buf.Length())
       
  3763         return;
       
  3764 
       
  3765     Print(buf);
       
  3766 }
       
  3767 
  3608 
  3768 void SIPrintf(TRefByValue<const TDesC16> aFmt, ...)
  3609 void SIPrintf(TRefByValue<const TDesC16> aFmt, ...)
  3769 	{
  3610 	{
  3770 	TBuf<0x200> buf;
  3611 	TBuf<256> buf;
  3771 	VA_LIST list;					
  3612 	VA_LIST list;					
  3772 	VA_START(list, aFmt);
  3613 	VA_START(list, aFmt);
  3773 	// coverity[uninit_use_in_call]
  3614 	// coverity[uninit_use_in_call]
  3774 	buf.FormatList(aFmt, list);			
  3615 	buf.FormatList(aFmt, list);			
  3775 	buf.Append(KCrNl);					
  3616 	buf.Append(KCrNl);					
  3840 	aProg.UpperCase();
  3681 	aProg.UpperCase();
  3841 	if (aProg.FindF(_L(".EXE")) == KErrNotFound && (aProg.Length()+4) <= KShellMaxCommandLine)
  3682 	if (aProg.FindF(_L(".EXE")) == KErrNotFound && (aProg.Length()+4) <= KShellMaxCommandLine)
  3842 		aProg.Append(_L(".EXE"));
  3683 		aProg.Append(_L(".EXE"));
  3843 
  3684 
  3844 #ifdef _DEBUG
  3685 #ifdef _DEBUG
  3845 	CShell::Printf(_L("RUNEXEC: command %S, parameters %S, count %d, forever %d, issecs %d, exiterr %d"),
  3686 	SIPrintf(_L("RUNEXEC: command %S, parameters %S, count %d, forever %d, issecs %d, exiterr %d"),
  3846 		&aProg, &parameters, count, forever, countIsSecs, exitOnErr); 
  3687 		&aProg, &parameters, count, forever, countIsSecs, exitOnErr); 
  3847 #endif
  3688 #endif
  3848 	TInt i=0;
  3689 	TInt i=0;
  3849 	FOREVER
  3690 	FOREVER
  3850 		{
  3691 		{
  3855 		TBuf<KMaxExitCategoryName> exitCat(0);
  3696 		TBuf<KMaxExitCategoryName> exitCat(0);
  3856 
  3697 
  3857 		r = newProcess.Create(aProg, parameters);
  3698 		r = newProcess.Create(aProg, parameters);
  3858 		if (r != KErrNone)
  3699 		if (r != KErrNone)
  3859 			{
  3700 			{
  3860 			CShell::Printf(KRunExecFailedProcessCreate, &aProg, r);
  3701 			SIPrintf(KRunExecFailedProcessCreate, &aProg, r);
  3861 			return (r);						// this is systematic - must return
  3702 			return (r);						// this is systematic - must return
  3862 			}
  3703 			}
  3863 		newProcess.Logon(status);
  3704 		newProcess.Logon(status);
  3864 		newProcess.Resume();
  3705 		newProcess.Resume();
  3865 		User::WaitForRequest(status);
  3706 		User::WaitForRequest(status);
  3869 		newProcess.Close();
  3710 		newProcess.Close();
  3870 
  3711 
  3871 		timeCurrent.HomeTime();
  3712 		timeCurrent.HomeTime();
  3872 		timeTaken = timeCurrent.MicroSecondsFrom(timeStart);
  3713 		timeTaken = timeCurrent.MicroSecondsFrom(timeStart);
  3873 		TInt msecs = I64LOW(timeTaken.Int64() / 1000);
  3714 		TInt msecs = I64LOW(timeTaken.Int64() / 1000);
  3874 		CShell::Printf(KRunExecReportStatusAndTime, msecs, i+1, exitType, retcode, &exitCat);
  3715 		SIPrintf(KRunExecReportStatusAndTime, msecs, i+1, exitType, retcode, &exitCat);
  3875 
  3716 
  3876 		if (resetDebugRegs)
  3717 		if (resetDebugRegs)
  3877 			{
  3718 			{
  3878 			TheShell->TheFs.SetDebugRegister(0);
  3719 			TheShell->TheFs.SetDebugRegister(0);
  3879 			User::SetDebugMask(0);
  3720 			User::SetDebugMask(0);
  3936 
  3777 
  3937 
  3778 
  3938 //-------------------------------------------------------------------------
  3779 //-------------------------------------------------------------------------
  3939 /**
  3780 /**
  3940     Print out the command line to the console and standard debug port.
  3781     Print out the command line to the console and standard debug port.
  3941 
       
  3942     echo [some text] [/y] [/n]
       
  3943 
       
  3944 		/Y : switches ON copying console output to the debug port
       
  3945 		/N : switches OFF copying console output to the debug port
       
  3946 
       
  3947 */
  3782 */
  3948 TInt ShellFunction::ConsoleEcho(TDes& aArgs, TUint aSwitches)
  3783 TInt ShellFunction::ConsoleEcho(TDes& aArgs, TUint /*aSwitches*/)
  3949 {
  3784 {
  3950     if(aSwitches & TShellCommand::EYSwitch)
       
  3951     {
       
  3952         CShell::SetDbgConsoleEcho(ETrue);
       
  3953     }
       
  3954     else
       
  3955     if(aSwitches & TShellCommand::ENSwitch)
       
  3956     {
       
  3957         CShell::SetDbgConsoleEcho(EFalse);
       
  3958     }
       
  3959 
       
  3960     if(aArgs.Length())
       
  3961     SIPrintf(aArgs);
  3785     SIPrintf(aArgs);
  3962     
       
  3963     return KErrNone;
  3786     return KErrNone;
  3964 }
  3787 }
  3965 
       
  3966