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