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. |
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 |
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 |
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; |
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 |
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) |
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(); |
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) |
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 }; |
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 } |
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 |