29 #include "u32std.h" |
29 #include "u32std.h" |
30 #include <u32hal.h> |
30 #include <u32hal.h> |
31 #include <nkern/nk_trace.h> |
31 #include <nkern/nk_trace.h> |
32 #include "filesystem_fat.h" |
32 #include "filesystem_fat.h" |
33 |
33 |
34 _LIT(KCrNl, "\r\n"); |
|
35 _LIT(KNl, "\n"); |
|
36 |
|
37 TPtrC ptrFormatHelp=_L("Drive:[\\] [fat12|fat16|fat32] [spc:X] [rs:Y] [ft:Z] [/Q][/S][/E][/F]\nfat12 or fat16 or fat32 specifies explicit FAT type\nspc:X specifies \"X\" sectors per cluster\nrs:Y specifies \"Y\" reserved sectors\nft:Z specifies \"Z\" FAT tables (1 or 2)\n\n/q - QuickFormat, /s - SpecialFormat, /e - ForcedErase\n/f - force formatting (ignore volume being in use)"); |
34 TPtrC ptrFormatHelp=_L("Drive:[\\] [fat12|fat16|fat32] [spc:X] [rs:Y] [ft:Z] [/Q][/S][/E][/F]\nfat12 or fat16 or fat32 specifies explicit FAT type\nspc:X specifies \"X\" sectors per cluster\nrs:Y specifies \"Y\" reserved sectors\nft:Z specifies \"Z\" FAT tables (1 or 2)\n\n/q - QuickFormat, /s - SpecialFormat, /e - ForcedErase\n/f - force formatting (ignore volume being in use)"); |
38 TPtrC ptrMountHelp=_L("Drive:[\\] <fsy:X> <fs:Y> [pext:Z] [/S][/U][/F][/R]\n'X' *.fsy module name, like elocal.fsy\n'Y' file system name, like 'FAT'\n'Z' optional primary extension module name\n/U - dismount FS from the drive e.g 'mount d: /u' \n/U /F force dismounting the FS even if there are opened files on it \n/F - force mounting with dismounting existing FS \n/S - mount drive as synchronous\n/R - remount the file system "); |
35 TPtrC ptrMountHelp=_L("Drive:[\\] <fsy:X> <fs:Y> [pext:Z] [/S][/U][/F][/R]\n'X' *.fsy module name, like elocal.fsy\n'Y' file system name, like 'FAT'\n'Z' optional primary extension module name\n/U - dismount FS from the drive e.g 'mount d: /u' \n/F - force mounting with dismounting existing FS \n/S - mount drive as synchronous\n/R - remount the file system "); |
39 |
36 |
40 TBool CShell::iDbgPrint = EFalse; |
|
41 |
37 |
42 // lint -e40,e30 |
38 // lint -e40,e30 |
43 const TShellCommand CShell::iCommand[ENoShellCommands]= |
39 const TShellCommand CShell::iCommand[ENoShellCommands]= |
44 { |
40 { |
|
41 // TShellCommand(_L("BLANK"),_L("Help"),_L("-?"),TShellCommand::EDSwitch,ShellFunction::BLANK), |
45 TShellCommand(_L("ATTRIB"),_L("Displays or changes file attributes"),_L("[drive:][path][filename] [+R | -R] [+H |-H] [+S | -S] [+A | -A] [/p]\n\n /p - Pause after each screen of information"), TShellCommand::EPSwitch, ShellFunction::Attrib), |
42 TShellCommand(_L("ATTRIB"),_L("Displays or changes file attributes"),_L("[drive:][path][filename] [+R | -R] [+H |-H] [+S | -S] [+A | -A] [/p]\n\n /p - Pause after each screen of information"), TShellCommand::EPSwitch, ShellFunction::Attrib), |
46 TShellCommand(_L("CD"),_L("Change the current directory for a drive"),_L("[path] [/d]\n\n /d - Change drive"),TShellCommand::EDSwitch,ShellFunction::Cd), |
43 TShellCommand(_L("CD"),_L("Change the current directory for a drive"),_L("[path] [/d]\n\n /d - Change drive"),TShellCommand::EDSwitch,ShellFunction::Cd), |
47 TShellCommand(_L("CHKDEPS"),_L("Check the dependencies of an executable or a Dll (ARM only)"),_L("[Filename.EXE] or [Filename.DLL]"),0,ShellFunction::ChkDeps), |
44 TShellCommand(_L("CHKDEPS"),_L("Check the dependencies of an executable or a Dll (ARM only)"),_L("[Filename.EXE] or [Filename.DLL]"),0,ShellFunction::ChkDeps), |
48 TShellCommand(_L("CHKDSK"),_L("Check disk for corruption"),_L("[drive:] [/s][/f|/u]\n\n/s - start ScanDrive instead of CheckDisk\n/f - finalise drive\n/u - unfinalise drive"),TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::EUSwitch,ShellFunction::ChkDsk), |
45 TShellCommand(_L("CHKDSK"),_L("Check disk for corruption"),_L("[drive:] [/s][/f|/u]\n\n/s - start ScanDrive instead of CheckDisk\n/f - finalise drive\n/u - unfinalise drive"),TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::EUSwitch,ShellFunction::ChkDsk), |
49 TShellCommand(_L("COPY"),_L("Copy one (or more) file(s), overwriting existing one(s)"),_L("source [destination]"),TShellCommand::ESSwitch,ShellFunction::Copy), |
46 TShellCommand(_L("COPY"),_L("Copy one (or more) file(s), overwriting existing one(s)"),_L("source [destination]"),TShellCommand::ESSwitch,ShellFunction::Copy), |
50 TShellCommand(_L("DEL"),_L("Delete one file"),_L("[drive:][path][filename]"),TShellCommand::ESSwitch,ShellFunction::Del), |
47 TShellCommand(_L("DEL"),_L("Delete one file"),_L("[drive:][path][filename]"),TShellCommand::ESSwitch,ShellFunction::Del), |
51 TShellCommand(_L("DIR"),_L("Show directory contents"),_L("[drive:][path][filename] [/p][/w]\n\n /p - Pause after each screen of information\n /w - Wide format"),TShellCommand::EPSwitch|TShellCommand::EWSwitch|TShellCommand::EASwitch,ShellFunction::Dir), |
48 TShellCommand(_L("DIR"),_L("Show directory contents"),_L("[drive:][path][filename] [/p][/w]\n\n /p - Pause after each screen of information\n /w - Wide format"),TShellCommand::EPSwitch|TShellCommand::EWSwitch|TShellCommand::EASwitch,ShellFunction::Dir), |
|
49 // TShellCommand(_L("EDLIN"),_L("Edit a text file"),_L("[drive:][path][filename] [/p]\n\n /p - Pause after each screen of information"),TShellCommand::EPSwitch,ShellFunction::Edit), |
52 TShellCommand(_L("FORMAT"),_L("Format a disk"),ptrFormatHelp,TShellCommand::EQSwitch|TShellCommand::ESSwitch|TShellCommand::EESwitch|TShellCommand::EFSwitch,ShellFunction::Format), |
50 TShellCommand(_L("FORMAT"),_L("Format a disk"),ptrFormatHelp,TShellCommand::EQSwitch|TShellCommand::ESSwitch|TShellCommand::EESwitch|TShellCommand::EFSwitch,ShellFunction::Format), |
53 TShellCommand(_L("GOBBLE"),_L("Create a file"),_L("[filename] size [/e]\n\n /e - create an empty file, without writing any data"),TShellCommand::EESwitch,ShellFunction::Gobble), |
51 TShellCommand(_L("GOBBLE"),_L("Create a file"),_L("[filename] size [/e]\n\n /e - create an empty file, without writing any data"),TShellCommand::EESwitch,ShellFunction::Gobble), |
54 TShellCommand(_L("HEXDUMP"),_L("Display the contents of a file in hexadecimal"),_L("[drive:][path][filename] [/p]\n\n /p - Pause after each screen of information\n\n Hit escape to exit from hexdump "),TShellCommand::EPSwitch,ShellFunction::Hexdump), |
52 TShellCommand(_L("HEXDUMP"),_L("Display the contents of a file in hexadecimal"),_L("[drive:][path][filename] [/p]\n\n /p - Pause after each screen of information\n\n Hit escape to exit from hexdump "),TShellCommand::EPSwitch,ShellFunction::Hexdump), |
55 TShellCommand(_L("LABEL"),_L("Set or return the volume label"),_L("[newlabel]"),0,ShellFunction::VolumeLabel), |
53 TShellCommand(_L("LABEL"),_L("Set or return the volume label"),_L("[newlabel]"),0,ShellFunction::VolumeLabel), |
56 TShellCommand(_L("MD"),_L("Make a new directory"),_L("name"),0,ShellFunction::Md), |
54 TShellCommand(_L("MD"),_L("Make a new directory"),_L("name"),0,ShellFunction::Md), |
71 TShellCommand(_L("DEBUGPORT"),_L("Set or get debug port"),_L("[port]"),0,ShellFunction::DebugPort), |
69 TShellCommand(_L("DEBUGPORT"),_L("Set or get debug port"),_L("[port]"),0,ShellFunction::DebugPort), |
72 TShellCommand(_L("PLUGIN"),_L("Manage Plugins"),_L("[name][/A][/R][/M][/D]"),TShellCommand::EASwitch|TShellCommand::ERSwitch|TShellCommand::EMSwitch|TShellCommand::EDSwitch,ShellFunction::Plugin), |
70 TShellCommand(_L("PLUGIN"),_L("Manage Plugins"),_L("[name][/A][/R][/M][/D]"),TShellCommand::EASwitch|TShellCommand::ERSwitch|TShellCommand::EMSwitch|TShellCommand::EDSwitch,ShellFunction::Plugin), |
73 TShellCommand(_L("DRVINFO"),_L("Print information about present drive(s) in the system"),_L("[DriveLetter:[\\]] [/p]\n/p - pause after each drive"),TShellCommand::EPSwitch,ShellFunction::DrvInfo), |
71 TShellCommand(_L("DRVINFO"),_L("Print information about present drive(s) in the system"),_L("[DriveLetter:[\\]] [/p]\n/p - pause after each drive"),TShellCommand::EPSwitch,ShellFunction::DrvInfo), |
74 TShellCommand(_L("SYSINFO"),_L("Print information about system features and status"),_L(""),0,ShellFunction::SysInfo), |
72 TShellCommand(_L("SYSINFO"),_L("Print information about system features and status"),_L(""),0,ShellFunction::SysInfo), |
75 TShellCommand(_L("MOUNT"),_L("Mount / dismount file system on specified drive"),ptrMountHelp,TShellCommand::EUSwitch|TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::ERSwitch,ShellFunction::MountFileSystem), |
73 TShellCommand(_L("MOUNT"),_L("Mount / dismount file system on specified drive"),ptrMountHelp,TShellCommand::EUSwitch|TShellCommand::ESSwitch|TShellCommand::EFSwitch|TShellCommand::ERSwitch,ShellFunction::MountFileSystem), |
76 TShellCommand(_L("ECHO"),_L("Print out the command line to the console and standard debug port."),_L("[line to print out] [/Y/N]\n /Y turn ON copying console output to debug port\n /N turn it OFF "),TShellCommand::EYSwitch|TShellCommand::ENSwitch,ShellFunction::ConsoleEcho), |
74 TShellCommand(_L("ECHO"),_L("Print out the command line to the console and standard debug port."),_L("[line to print out]"),0,ShellFunction::ConsoleEcho), |
77 TShellCommand(_L("RUNEXEC"),_L("Run a program in a loop"),_L("count filename[.exe] [/E/S/R]\n /E - exit early on error\n /S - count in seconds\n zero - run forever\n /R - reset debug regs after each run"),TShellCommand::EESwitch|TShellCommand::ESSwitch|TShellCommand::ERSwitch,ShellFunction::RunExec), |
75 TShellCommand(_L("RUNEXEC"),_L("Run a program in a loop"),_L("count filename[.exe] [/E/S/R]\n /E - exit early on error\n /S - count in seconds\n zero - run forever\n /R - reset debug regs after each run"),TShellCommand::EESwitch|TShellCommand::ESSwitch|TShellCommand::ERSwitch,ShellFunction::RunExec), |
78 |
76 |
79 }; |
77 }; |
80 |
78 |
81 |
79 |
82 LOCAL_C TInt pswd_DrvNbr(TDes &aPath, TInt &aDN); |
80 LOCAL_C TInt pswd_DrvNbr(TDes &aPath, TInt &aDN); |
83 LOCAL_C TInt pswd_Password(TDes &aPath, TInt aPWNbr, TMediaPassword &aPW); |
81 LOCAL_C TInt pswd_Password(TDes &aPath, TInt aPWNbr, TMediaPassword &aPW); |
84 |
82 |
|
83 _LIT(KLitNewLine,"\n"); |
85 void CShell::NewLine() |
84 void CShell::NewLine() |
86 { |
85 { |
87 Printf(KNl); |
86 TheConsole->Printf(KLitNewLine()); |
88 } |
87 } |
89 |
88 |
90 // |
89 // |
91 // Skip the hexadecimal prefix if present and return EHex. Return |
90 // Skip the hexadecimal prefix if present and return EHex. Return |
92 // EDecimal otherwise. |
91 // EDecimal otherwise. |
580 aText.Remove(j); |
576 aText.Remove(j); |
581 } |
577 } |
582 |
578 |
583 } |
579 } |
584 |
580 |
585 /** |
581 |
586 outputs content of the buffer to console according to settings passed in aSwitches |
582 void ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches) |
587 @return ETrue if the user pressed Esc key |
583 //outputs content of the buffer to console according to settings passed in aSwitches |
588 */ |
|
589 TBool ShellFunction::OutputContentsToConsole(RPointerArray<HBufC>& aText,TUint aSwitches) |
|
590 { |
584 { |
591 if ((aText.Count()>0)&&((aSwitches&TShellCommand::EWSwitch)!=0)) |
585 if ((aText.Count()>0)&&((aSwitches&TShellCommand::EWSwitch)!=0)) |
592 AlignTextIntoColumns(aText); |
586 AlignTextIntoColumns(aText); |
593 |
587 |
594 TKeyCode key=EKeyNull; |
588 for (TInt i=0;i<aText.Count();i++) |
595 TInt i; |
589 { |
596 |
590 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]); |
597 for(i=0;i<aText.Count();i++) |
591 CShell::OutputStringToConsole(EFalse,_L("\n")); |
598 { |
|
599 key = CShell::WriteBufToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),*aText[i]); |
|
600 if(key == EKeyEscape) |
|
601 break; |
|
602 |
|
603 key = CShell::WriteBufToConsole(EFalse,_L("\n")); |
|
604 if(key == EKeyEscape) |
|
605 break; |
|
606 |
|
607 } |
|
608 |
|
609 //-- clean up string array |
|
610 for(i=0; i<aText.Count(); i++) |
|
611 { |
|
612 delete aText[i]; |
592 delete aText[i]; |
613 } |
593 } |
614 |
594 //empty string array |
615 aText.Reset(); |
595 aText.Reset(); |
616 |
|
617 return (key == EKeyEscape); |
|
618 } |
596 } |
619 |
597 |
620 |
598 |
621 void ShellFunction::OutputDirContentL(CDir* aDirList,RPointerArray<HBufC>& aText,TUint aSwitches) |
599 void ShellFunction::OutputDirContentL(CDir* aDirList,RPointerArray<HBufC>& aText,TUint aSwitches) |
622 //outputs content of a directory to console according to settings passed in aSwitches |
600 //outputs content of a directory to console according to settings passed in aSwitches |
623 { |
601 { |
624 TInt count=aDirList->Count(); |
602 TInt count=aDirList->Count(); |
625 TInt fileCount=0, dirCount=0, printCount=0; |
603 TInt fileCount=0, dirCount=0, printCount=0; |
626 TInt64 byteCount=0; |
604 TInt64 byteCount=0; |
627 TBool bBreak=EFalse; |
|
628 |
605 |
629 //compose an array of strings describing entries in the directory |
606 //compose an array of strings describing entries in the directory |
630 for (TInt j=0;j<count;j++) |
607 for (TInt j=0;j<count;j++) |
631 { |
608 { |
632 HBufC* buf=NULL; |
609 HBufC* buf=NULL; |
658 buf = HBufC::NewL(KMaxFileName+100);//reserve additional space for the creation time information |
635 buf = HBufC::NewL(KMaxFileName+100);//reserve additional space for the creation time information |
659 CleanupStack::PushL(buf); |
636 CleanupStack::PushL(buf); |
660 TPtr name=buf->Des(); |
637 TPtr name=buf->Des(); |
661 name=entry.iName; |
638 name=entry.iName; |
662 |
639 |
663 const TPtrC desName(entry.iName); |
|
664 const TBool bNameCut = desName.Length() > 26; |
|
665 |
|
666 _LIT(KDots, ">.."); //-- will be displayed if the name is longer than 26 characters |
|
667 _LIT(KSpc, " "); |
|
668 |
|
669 |
|
670 if (entry.IsDir()) |
640 if (entry.IsDir()) |
671 { |
641 { |
672 dirCount++; |
642 dirCount++; |
673 |
643 name.Format(_L(" %- 26S <DIR> %+02d/%+02d/%- 4d %02d:%02d:%02d.%06d"), |
674 name.Format(_L(" %- 26S%S<DIR> %+02d/%+02d/%- 4d %02d:%02d:%02d.%03d"), |
644 &entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
675 &desName, |
|
676 bNameCut ? &KDots : &KSpc, |
|
677 modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
|
678 |
|
679 //name.Format(_L(" %- 26S <DIR> %+02d/%+02d/%- 4d %02d:%02d:%02d.%06d"), |
|
680 // &entry.iName,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
|
681 } |
645 } |
682 else |
646 else |
683 { |
647 { |
684 TInt64 entrySize = entry.FileSize(); |
648 TInt64 entrySize = entry.FileSize(); |
685 byteCount+=entrySize; |
649 byteCount+=entrySize; |
686 fileCount++; |
650 fileCount++; |
687 |
651 name.Format(_L(" %- 32S%+ 15Lu %+02d/%+02d/%- 4d %02d:%02d:%02d.%06d"), |
688 name.Format(_L(" %- 26S%S%-11Lu %+02d/%+02d/%- 4d %02d:%02d:%02d.%03d"), |
652 &entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
689 &desName, |
|
690 bNameCut ? &KDots : &KSpc, |
|
691 entrySize, |
|
692 modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
|
693 |
|
694 //name.Format(_L(" %- 32S%+ 15Lu %+02d/%+02d/%- 4d %02d:%02d:%02d.%06d"), |
|
695 // &entry.iName,entrySize,modTime.Day()+1,modTime.Month()+1,modTime.Year(),modTime.Hour(),modTime.Minute(),modTime.Second(),modTime.MicroSecond()); |
|
696 } |
653 } |
697 } |
654 } |
698 User::LeaveIfError(aText.Append(buf )); |
655 User::LeaveIfError(aText.Append(buf )); |
699 printCount++; |
656 printCount++; |
700 |
|
701 //print the contents if a screen size of data is available. This will prevent huge buffer allocation. |
657 //print the contents if a screen size of data is available. This will prevent huge buffer allocation. |
702 if(printCount == CShell::TheConsole->ScreenSize().iHeight) |
658 if(printCount == CShell::TheConsole->ScreenSize().iHeight) |
703 { |
659 { |
704 bBreak = OutputContentsToConsole(aText,aSwitches); |
660 OutputContentsToConsole(aText,aSwitches); |
705 printCount=0; |
661 printCount=0; |
706 } |
662 } |
707 |
|
708 CleanupStack::Pop(); |
663 CleanupStack::Pop(); |
709 |
664 |
710 if(bBreak) |
665 } |
711 break; |
|
712 } |
|
713 |
|
714 if(bBreak) |
|
715 return; //-- the user has interrupted the listing |
|
716 |
|
717 |
|
718 OutputContentsToConsole(aText,aSwitches); |
666 OutputContentsToConsole(aText,aSwitches); |
719 |
667 |
720 //--------------------------------- |
668 //output summary information |
721 //-- print out summary information |
669 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L(" %d File%c\n"),fileCount,(fileCount==1)?' ':'s'); |
722 TBuf<100> buf; |
670 if (fileCount!=0) |
723 buf.Format(_L(" %d File%c"), fileCount, (fileCount==1) ? ' ':'s'); |
671 { |
724 if(fileCount > 0) |
672 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),_L(" %lu byte%c\n"),byteCount,(fileCount==1)?' ':'s'); |
725 { |
673 } |
726 buf.AppendFormat(_L(", %LU bytes"), byteCount); |
674 |
727 } |
675 TBuf<50> buf;// allocate string long enough for additional information(number of directories) |
728 |
|
729 buf.Append(KNl); |
|
730 |
|
731 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0), buf); |
|
732 |
|
733 buf.Format(_L(" %d Director"),dirCount); |
676 buf.Format(_L(" %d Director"),dirCount); |
734 if (dirCount==1) |
677 if (dirCount==1) |
735 buf.AppendFormat(_L("y\n")); |
678 buf.AppendFormat(_L("y\n")); |
736 else |
679 else |
737 buf.AppendFormat(_L("ies\n")); |
680 buf.AppendFormat(_L("ies\n")); |
738 |
681 |
739 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),buf); |
682 CShell::OutputStringToConsole(((aSwitches&TShellCommand::EPSwitch)!=0),buf); |
740 |
|
741 |
|
742 } |
683 } |
743 |
684 |
744 TInt ShellFunction::Dir(TDes& aPath,TUint aSwitches) |
685 TInt ShellFunction::Dir(TDes& aPath,TUint aSwitches) |
745 // |
686 // |
746 // Modified December 1997, to sort entries alphabetically |
687 // Modified December 1997, to sort entries alphabetically |
1053 if(aDrvInfo.iDriveAtt & KDriveAttLocal) aPrintBuf.Append(_L("KDriveAttLocal,")); |
1001 if(aDrvInfo.iDriveAtt & KDriveAttLocal) aPrintBuf.Append(_L("KDriveAttLocal,")); |
1054 if(aDrvInfo.iDriveAtt & KDriveAttRom) aPrintBuf.Append(_L("KDriveAttRom,")); |
1002 if(aDrvInfo.iDriveAtt & KDriveAttRom) aPrintBuf.Append(_L("KDriveAttRom,")); |
1055 if(aDrvInfo.iDriveAtt & KDriveAttRedirected) aPrintBuf.Append(_L("KDriveAttRedirected,")); |
1003 if(aDrvInfo.iDriveAtt & KDriveAttRedirected) aPrintBuf.Append(_L("KDriveAttRedirected,")); |
1056 if(aDrvInfo.iDriveAtt & KDriveAttSubsted) aPrintBuf.Append(_L("KDriveAttSubsted,")); |
1004 if(aDrvInfo.iDriveAtt & KDriveAttSubsted) aPrintBuf.Append(_L("KDriveAttSubsted,")); |
1057 if(aDrvInfo.iDriveAtt & KDriveAttInternal) aPrintBuf.Append(_L("KDriveAttInternal,")); |
1005 if(aDrvInfo.iDriveAtt & KDriveAttInternal) aPrintBuf.Append(_L("KDriveAttInternal,")); |
1058 if(aDrvInfo.iDriveAtt & KDriveAttRemovable) aPrintBuf.Append(_L("KDriveAttRemovable,")); |
1006 if(aDrvInfo.iDriveAtt & KDriveAttRemovable) aPrintBuf.Append(_L("KDriveAttRemovable")); |
1059 |
1007 |
1060 if(aDrvInfo.iDriveAtt & KDriveAttRemote) aPrintBuf.Append(_L("KDriveAttRemote,")); |
1008 if(aDrvInfo.iDriveAtt & KDriveAttRemote) aPrintBuf.Append(_L("KDriveAttRemote")); |
1061 if(aDrvInfo.iDriveAtt & KDriveAttTransaction) aPrintBuf.Append(_L("KDriveAttTransaction,")); |
1009 if(aDrvInfo.iDriveAtt & KDriveAttTransaction) aPrintBuf.Append(_L("KDriveAttTransaction")); |
1062 |
1010 |
1063 if(aDrvInfo.iDriveAtt & KDriveAttPageable) aPrintBuf.Append(_L("KDriveAttPageable,")); |
1011 if(aDrvInfo.iDriveAtt & KDriveAttPageable) aPrintBuf.Append(_L("KDriveAttPageable")); |
1064 if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable) aPrintBuf.Append(_L("KDriveAttLogicallyRemovable,")); |
1012 if(aDrvInfo.iDriveAtt & KDriveAttLogicallyRemovable) aPrintBuf.Append(_L("KDriveAttLogicallyRemovable")); |
1065 if(aDrvInfo.iDriveAtt & KDriveAttHidden) aPrintBuf.Append(_L("KDriveAttHidden,")); |
1013 if(aDrvInfo.iDriveAtt & KDriveAttHidden) aPrintBuf.Append(_L("KDriveAttHidden")); |
1066 |
1014 |
1067 aPrintBuf.Append(_L("\n")); |
1015 aPrintBuf.Append(_L("\n")); |
1068 } |
1016 } |
1069 |
1017 |
1070 //-------------------------------------------------------- |
1018 //-------------------------------------------------------- |
1082 if(aDrvInfo.iMediaAtt & KMediaAttVariableSize) aPrintBuf.Append(_L("KMediaAttVariableSize,")); |
1030 if(aDrvInfo.iMediaAtt & KMediaAttVariableSize) aPrintBuf.Append(_L("KMediaAttVariableSize,")); |
1083 if(aDrvInfo.iMediaAtt & KMediaAttDualDensity) aPrintBuf.Append(_L("KMediaAttDualDensity,")); |
1031 if(aDrvInfo.iMediaAtt & KMediaAttDualDensity) aPrintBuf.Append(_L("KMediaAttDualDensity,")); |
1084 if(aDrvInfo.iMediaAtt & KMediaAttFormattable) aPrintBuf.Append(_L("KMediaAttFormattable,")); |
1032 if(aDrvInfo.iMediaAtt & KMediaAttFormattable) aPrintBuf.Append(_L("KMediaAttFormattable,")); |
1085 if(aDrvInfo.iMediaAtt & KMediaAttWriteProtected) aPrintBuf.Append(_L("KMediaAttWriteProtected,")); |
1033 if(aDrvInfo.iMediaAtt & KMediaAttWriteProtected) aPrintBuf.Append(_L("KMediaAttWriteProtected,")); |
1086 if(aDrvInfo.iMediaAtt & KMediaAttLockable) aPrintBuf.Append(_L("KMediaAttLockable,")); |
1034 if(aDrvInfo.iMediaAtt & KMediaAttLockable) aPrintBuf.Append(_L("KMediaAttLockable,")); |
1087 if(aDrvInfo.iMediaAtt & KMediaAttLocked) aPrintBuf.Append(_L("KMediaAttLocked,")); |
1035 if(aDrvInfo.iMediaAtt & KMediaAttLocked) aPrintBuf.Append(_L("KMediaAttLocked")); |
1088 |
1036 |
1089 if(aDrvInfo.iMediaAtt & KMediaAttHasPassword) aPrintBuf.Append(_L("KMediaAttHasPassword,")); |
1037 if(aDrvInfo.iMediaAtt & KMediaAttHasPassword) aPrintBuf.Append(_L("KMediaAttHasPassword")); |
1090 if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite) aPrintBuf.Append(_L("KMediaAttReadWhileWrite,")); |
1038 if(aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite) aPrintBuf.Append(_L("KMediaAttReadWhileWrite")); |
1091 if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify) aPrintBuf.Append(_L("KMediaAttDeleteNotify,")); |
1039 if(aDrvInfo.iMediaAtt & KMediaAttDeleteNotify) aPrintBuf.Append(_L("KMediaAttDeleteNotify")); |
1092 if(aDrvInfo.iMediaAtt & KMediaAttPageable) aPrintBuf.Append(_L("KMediaAttPageable,")); |
1040 if(aDrvInfo.iMediaAtt & KMediaAttPageable) aPrintBuf.Append(_L("KMediaAttPageable")); |
1093 |
1041 |
1094 |
1042 |
1095 aPrintBuf.Append(_L("\n")); |
1043 aPrintBuf.Append(_L("\n")); |
1096 } |
1044 } |
1097 |
1045 |
1133 @param apConsole pointer to the console to print information into |
1081 @param apConsole pointer to the console to print information into |
1134 @param aFlags specifies which information to print out, @see TPrintDrvInfoFlags |
1082 @param aFlags specifies which information to print out, @see TPrintDrvInfoFlags |
1135 |
1083 |
1136 @return standard error code |
1084 @return standard error code |
1137 */ |
1085 */ |
1138 TInt PrintDrvInfo(RFs& aFs, TInt aDrvNum, TUint aFlags = EAll) |
1086 TInt PrintDrvInfo(RFs& aFs, TInt aDrvNum, CConsoleBase* apConsole, TUint aFlags = EAll) |
1139 { |
1087 { |
1140 TInt nRes; |
1088 TInt nRes; |
1141 TDriveInfo driveInfo; |
1089 TDriveInfo driveInfo; |
1142 TVolumeInfo volInfo; |
1090 TVolumeInfo volInfo; |
1143 TBuf<256> Buf; |
1091 TBuf<256> Buf; |
1144 |
1092 |
1145 //-- get drive info |
1093 //-- get drive info |
1146 nRes = aFs.Drive(driveInfo, aDrvNum); |
1094 nRes = aFs.Drive(driveInfo, aDrvNum); |
1147 if(nRes != KErrNone) |
1095 if(nRes != KErrNone) |
1148 { |
1096 { |
1149 CShell::Printf(_L("Error: %d\n"), nRes); |
1097 CShell::TheConsole->Printf(_L("Error: %d\n"), nRes); |
1150 return nRes; //-- can't get information about the drive |
1098 return nRes; //-- can't get information about the drive |
1151 } |
1099 } |
1152 |
1100 |
1153 |
1101 |
1154 nRes = aFs.Volume(volInfo, aDrvNum); |
1102 nRes = aFs.Volume(volInfo, aDrvNum); |
1155 const TBool bVolumeOK = (nRes == KErrNone); |
1103 const TBool bVolumeOK = (nRes == KErrNone); |
1156 if(!bVolumeOK) |
1104 if(!bVolumeOK) |
1157 {//-- can't get information about the volume. It might be just corrupt/unformatted |
1105 {//-- can't get information about the volume. It might be just corrupt/unformatted |
1158 CShell::Printf(_L("Error getting volume info. code: %d\n"), nRes); |
1106 CShell::TheConsole->Printf(_L("Error getting volume info. code: %d\n"), nRes); |
1159 if(nRes == KErrCorrupt) |
1107 if(nRes == KErrCorrupt) |
1160 { |
1108 { |
1161 CShell::Printf(_L("The volume might be corrupted or not formatted.\n")); |
1109 CShell::TheConsole->Printf(_L("The volume might be corrupted or not formatted.\n")); |
1162 } |
1110 } |
1163 } |
1111 } |
1164 |
1112 |
1165 |
1113 |
1166 //-- Print out information about file system installed |
1114 //-- Print out information about file system installed |
1167 if(aFlags & EFSInfo) |
1115 if(aFlags & EFSInfo) |
1168 { |
1116 { |
1169 //-- print out drive properties |
1117 //-- print out drive properties |
1170 Buf.Format(_L("Drive %c: No:%d"), 'A'+aDrvNum, aDrvNum); |
1118 Buf.Format(_L("\nDrive %c: No:%d"), 'A'+aDrvNum, aDrvNum); |
1171 |
1119 |
1172 //-- find out if the drive is synchronous / asynchronous |
1120 //-- find out if the drive is synchronous / asynchronous |
1173 TPckgBuf<TBool> drvSyncBuf; |
1121 TPckgBuf<TBool> drvSyncBuf; |
1174 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveSync, drvSyncBuf); |
1122 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveSync, drvSyncBuf); |
1175 if(nRes == KErrNone) |
1123 if(nRes == KErrNone) |
1176 { |
1124 { |
1177 Buf.AppendFormat(_L(" Sync:%d"), drvSyncBuf() ? 1:0); |
1125 Buf.AppendFormat(_L(", Sync:%d"), drvSyncBuf() ? 1:0); |
1178 } |
1126 } |
1179 |
1127 |
1180 //-- find out if drive runs a rugged FS (debug mode only) |
1128 //-- find out if drive runs a rugged FS (debug mode only) |
1181 const TInt KControlIoIsRugged=4; |
1129 const TInt KControlIoIsRugged=4; |
1182 TUint8 ruggedFS; |
1130 TUint8 ruggedFS; |
1183 TPtr8 pRugged(&ruggedFS, 1, 1); |
1131 TPtr8 pRugged(&ruggedFS, 1, 1); |
1184 nRes=aFs.ControlIo(aDrvNum, KControlIoIsRugged, pRugged); |
1132 nRes=aFs.ControlIo(aDrvNum, KControlIoIsRugged, pRugged); |
1185 if(nRes == KErrNone) |
1133 if(nRes == KErrNone) |
1186 { |
1134 { |
1187 Buf.AppendFormat(_L(" Rugged:%d"), ruggedFS ? 1:0); |
1135 Buf.AppendFormat(_L(", Rugged:%d"), ruggedFS ? 1:0); |
1188 } |
1136 } |
1189 |
1137 |
1190 CShell::Printf(KNl); |
1138 Buf.Append(_L("\n")); |
1191 Buf.Append(KNl); |
1139 apConsole->Printf(Buf); |
1192 CShell::Printf(Buf); |
1140 |
1193 |
1141 |
1194 //-- print the FS name |
1142 //-- print the FS name |
1195 if(aFs.FileSystemName(Buf, aDrvNum) == KErrNone) |
1143 if(aFs.FileSystemName(Buf, aDrvNum) == KErrNone) |
1196 { |
1144 { |
1197 TFSName fsName; |
1145 TFSName fsName; |
1240 TPckgBuf<TBool> boolPckg; |
1189 TPckgBuf<TBool> boolPckg; |
1241 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveFinalised, boolPckg); |
1190 nRes = aFs.QueryVolumeInfoExt(aDrvNum, EIsDriveFinalised, boolPckg); |
1242 if(nRes == KErrNone) |
1191 if(nRes == KErrNone) |
1243 { |
1192 { |
1244 if(boolPckg() >0) |
1193 if(boolPckg() >0) |
1245 Buf.Copy(_L("Vol:Finalised ")); |
1194 Buf.Copy(_L("Volume: Finalised")); |
1246 else |
1195 else |
1247 Buf.Copy(_L("Vol:Not finalised ")); |
1196 Buf.Copy(_L("Volume: Not finalised")); |
1248 } |
1197 } |
1249 |
1198 |
1250 //-- print out cluster size that FS reported |
1199 //-- print out cluster size that FS reported |
1251 TVolumeIOParamInfo volIoInfo; |
1200 TVolumeIOParamInfo volIoInfo; |
1252 nRes = aFs.VolumeIOParam(aDrvNum, volIoInfo); |
1201 nRes = aFs.VolumeIOParam(aDrvNum, volIoInfo); |
1253 if(nRes == KErrNone) |
1202 if(nRes == KErrNone) |
1254 { |
1203 { |
1255 if(volIoInfo.iBlockSize >= 0) |
1204 if(volIoInfo.iBlockSize >= 0) |
1256 { |
1205 { |
1257 Buf.AppendFormat(_L("BlkSz:%d "), volIoInfo.iBlockSize); |
1206 Buf.AppendFormat(_L(", BlkSz:%d"), volIoInfo.iBlockSize); |
1258 } |
1207 } |
1259 |
1208 |
1260 if(volIoInfo.iClusterSize >= 0) |
1209 if(volIoInfo.iClusterSize >= 0) |
1261 { |
1210 { |
1262 Buf.AppendFormat(_L("ClSz:%d "), volIoInfo.iClusterSize); |
1211 Buf.AppendFormat(_L(", ClSz:%d"), volIoInfo.iClusterSize); |
1263 } |
1212 } |
1264 |
1213 |
1265 Buf.AppendFormat(_L("CacheFlags:0x%x "), volInfo.iFileCacheFlags); |
1214 Buf.AppendFormat(_L(", CacheFlags:0x%x"), volInfo.iFileCacheFlags); |
1266 |
1215 |
1267 } |
1216 } |
1268 |
1217 |
1269 |
1218 |
1270 if(Buf.Length()) |
1219 if(Buf.Length()) |
1271 { |
1220 { |
1272 Buf.Append(KNl); |
1221 Buf.Append(_L("\n")); |
1273 CShell::Printf(Buf); |
1222 apConsole->Printf(Buf); |
1274 } |
1223 } |
1275 |
1224 |
1276 } |
1225 } |
1277 } |
1226 } |
1278 }//if(aFlags & EFSInfo) |
1227 }//if(aFlags & EFSInfo) |
1279 |
1228 |
1280 //-- print media attributes |
1229 //-- print media attributes |
1281 if(aFlags & EMediaTypeInfo) |
1230 if(aFlags & EMediaTypeInfo) |
1282 { |
1231 { |
1283 FormatDrvMediaTypeInfo(driveInfo, Buf); |
1232 FormatDrvMediaTypeInfo(driveInfo, Buf); |
1284 CShell::Printf(Buf); |
1233 apConsole->Printf(Buf); |
|
1234 |
1285 } |
1235 } |
1286 |
1236 |
1287 //-- print drive attributes |
1237 //-- print drive attributes |
1288 if(aFlags & EDrvAttInfo) |
1238 if(aFlags & EDrvAttInfo) |
1289 { |
1239 { |
1290 FormatDriveAttInfo(driveInfo, Buf); |
1240 FormatDriveAttInfo(driveInfo, Buf); |
1291 CShell::Printf(Buf); |
1241 apConsole->Printf(Buf); |
1292 } |
1242 } |
1293 |
1243 |
1294 //-- print media attributes |
1244 //-- print media attributes |
1295 if(aFlags & EMediaAttInfo) |
1245 if(aFlags & EMediaAttInfo) |
1296 { |
1246 { |
1297 FormatMediaAttInfo(driveInfo, Buf); |
1247 FormatMediaAttInfo(driveInfo, Buf); |
1298 CShell::Printf(Buf); |
1248 apConsole->Printf(Buf); |
1299 } |
1249 } |
1300 |
1250 |
1301 |
1251 |
1302 //-- print volume information |
1252 //-- print volume information |
1303 if(bVolumeOK && (aFlags & EVolInfo)) |
1253 if(bVolumeOK && (aFlags & EVolInfo)) |
1304 { |
1254 { |
1305 FormatVolInfo(volInfo, Buf); |
1255 FormatVolInfo(volInfo, Buf); |
1306 CShell::Printf(Buf); |
1256 apConsole->Printf(Buf); |
1307 } |
1257 } |
1308 |
1258 |
1309 return KErrNone; |
1259 return KErrNone; |
1310 } |
1260 } |
1311 |
1261 |
1384 |
1334 |
1385 //-- get drives list |
1335 //-- get drives list |
1386 nRes=TheShell->TheFs.DriveList(driveList); |
1336 nRes=TheShell->TheFs.DriveList(driveList); |
1387 if(nRes != KErrNone) |
1337 if(nRes != KErrNone) |
1388 { |
1338 { |
1389 CShell::Printf(_L("\nError: %d"), nRes); |
1339 CShell::TheConsole->Printf(_L("\nError: %d"), nRes); |
1390 return nRes; |
1340 return nRes; |
1391 } |
1341 } |
1392 |
1342 |
1393 if(nDrv >=0) |
1343 if(nDrv >=0) |
1394 {//-- the drive is specified |
1344 {//-- the drive is specified |
1395 if(!driveList[nDrv]) |
1345 if(!driveList[nDrv]) |
1396 { |
1346 { |
1397 CShell::Printf(_L("Invalid drive specification\n")); |
1347 CShell::TheConsole->Printf(_L("Invalid drive specification\n")); |
1398 return KErrNone; |
1348 return KErrNone; |
1399 } |
1349 } |
1400 |
1350 |
1401 PrintDrvInfo(TheShell->TheFs, nDrv); |
1351 PrintDrvInfo(TheShell->TheFs, nDrv, CShell::TheConsole); |
1402 } |
1352 } |
1403 else |
1353 else |
1404 {//-- print information about all drives in the system |
1354 {//-- print information about all drives in the system |
1405 for (nDrv=0; nDrv < KMaxDrives; nDrv++) |
1355 for (nDrv=0; nDrv < KMaxDrives; nDrv++) |
1406 { |
1356 { |
1407 if(!driveList[nDrv]) |
1357 if(!driveList[nDrv]) |
1408 continue; //-- skip unexisting drive |
1358 continue; //-- skip unexisting drive |
1409 |
1359 |
1410 PrintDrvInfo(TheShell->TheFs, nDrv); |
1360 PrintDrvInfo(TheShell->TheFs, nDrv, CShell::TheConsole); |
1411 |
1361 |
1412 if(aSwitches & TShellCommand::EPSwitch) |
1362 if(aSwitches & TShellCommand::EPSwitch) |
1413 {//-- /p switch, pause after each drive |
1363 {//-- /p switch, pause after each drive |
1414 CShell::Printf(_L("\n--- press any key to continue or Esc to exit ---\n")); |
1364 CShell::TheConsole->Printf(_L("\n--- press any key to continue or Esc to exit ---\n")); |
1415 |
1365 |
1416 TKeyCode key = CShell::TheConsole->Getch(); |
1366 TKeyCode key = CShell::TheConsole->Getch(); |
1417 if (key==EKeyEscape) |
1367 if (key==EKeyEscape) |
1418 break; |
1368 break; |
1419 } |
1369 } |
1420 else |
1370 else |
1421 { |
1371 { |
1422 CShell::Printf(_L("\n----------\n")); |
1372 CShell::TheConsole->Printf(_L("\n----------\n")); |
1423 CShell::Printf(_L("\n--- press any key to continue or Esc to exit ---\n")); |
|
1424 |
|
1425 } |
1373 } |
1426 } |
1374 } |
1427 } |
1375 } |
1428 |
1376 |
1429 return KErrNone; |
1377 return KErrNone; |
1468 |
1416 |
1469 |
1417 |
1470 |
1418 |
1471 |
1419 |
1472 //----------------------------------------------------------------------------------------------------------------------- |
1420 //----------------------------------------------------------------------------------------------------------------------- |
1473 TInt DoDismountFS(RFs& aFs, TInt aDrvNum, TBool aForceDismount) |
1421 TInt DoDismountFS(RFs& aFs, TInt aDrvNum) |
1474 { |
1422 { |
1475 TInt nRes; |
1423 TInt nRes; |
1476 TBuf<40> fsName; |
1424 TBuf<40> fsName; |
1477 |
1425 |
1478 nRes = aFs.FileSystemName(fsName, aDrvNum); |
1426 nRes = aFs.FileSystemName(fsName, aDrvNum); |
1479 |
1427 |
1480 if(nRes != KErrNone) |
1428 if(nRes != KErrNone) |
1481 return KErrNotFound;//-- nothing to dismount |
1429 return KErrNotFound;//-- nothing to dismount |
1482 |
1430 |
1483 if(!aForceDismount) |
|
1484 {//-- gaceful attempt to dismount the FS |
|
1485 nRes = aFs.DismountFileSystem(fsName, aDrvNum); |
1431 nRes = aFs.DismountFileSystem(fsName, aDrvNum); |
1486 if(nRes != KErrNone) |
1432 if(nRes != KErrNone) |
1487 { |
1433 { |
1488 CShell::TheConsole->Printf(_L("Can't dismount FS!\n")); |
1434 CShell::TheConsole->Printf(_L("Can't dismount FS!\n")); |
1489 return nRes; |
1435 return nRes; |
1490 } |
1436 } |
1491 else |
1437 else |
1492 { |
1438 { |
1493 CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum); |
1439 CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum); |
1494 return KErrNone; |
1440 return KErrNone; |
1495 } |
|
1496 } |
|
1497 else |
|
1498 {//-- dismount by force |
|
1499 TRequestStatus rqStat; |
|
1500 aFs.NotifyDismount(aDrvNum, rqStat, EFsDismountForceDismount); |
|
1501 User::WaitForRequest(rqStat); |
|
1502 |
|
1503 CShell::TheConsole->Printf(_L("'%S' filesystem Forcedly dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum); |
|
1504 |
|
1505 return rqStat.Int(); |
|
1506 } |
1441 } |
1507 } |
1442 } |
1508 |
1443 |
1509 //----------------------------------------------------------------------------------------------------------------------- |
1444 //----------------------------------------------------------------------------------------------------------------------- |
1510 TInt DoRemountFS(RFs& aFs, TInt aDrvNum) |
1445 TInt DoRemountFS(RFs& aFs, TInt aDrvNum) |
1578 |
1513 |
1579 //----------------------------------------------------------------------------------------------------------------------- |
1514 //----------------------------------------------------------------------------------------------------------------------- |
1580 /** |
1515 /** |
1581 Mount or dismount the file system on the specified drive. |
1516 Mount or dismount the file system on the specified drive. |
1582 |
1517 |
1583 MOUNT <DriveLetter:[\]> <FSY:xxx> <FS:yyy> [PEXT:zzz] [/S] [/U] [/F] |
1518 MOUNT <DriveLetter:[\]> <FSY:xxx> <FS:yyy> [PEXT:zzz] [/S] [/U] |
1584 |
1519 |
1585 xxx is the *.fsy file system plugin name, like "elocal.fsy" or "elocal" |
1520 xxx is the *.fsy file system plugin name, like "elocal.fsy" or "elocal" |
1586 yyy is the file system name that the fsy module exports, like "FAT" |
1521 yyy is the file system name that the fsy module exports, like "FAT" |
1587 zzz is the optional parameter that specifies primary extension name |
1522 zzz is the optional parameter that specifies primary extension name |
1588 |
1523 |
1589 /u dismounts a filesystem on the specified drive; e.g. "mount d: /u" |
1524 /u dismounts a filesystem on the specified drive; e.g. "mount d: /u" |
1590 additional switch /f in conjunction with /u will perform "forced unmounting" i.e. unmounting the FS |
1525 /s for mounting FS specifies that the drive will be mounted as synchronous one. |
1591 even it has opened files and / or directories. E.g. "mount d: /u /f" |
1526 /f for forcing mounting the FS; the previous one will be automatically dismounted |
1592 |
1527 /r remount existing FS (dismount and mount it back) |
1593 |
|
1594 /s for mounting FS specifies that the drive will be mounted as a synchronous one. |
|
1595 |
|
1596 |
|
1597 /f for forcing mounting the FS; the previous one will be automatically dismounted. |
|
1598 example: "mount d: /f fsy:exfat fs:exfat" this command will dismount whatever FS ic currently mounted and |
|
1599 mount exFAT FS instead |
|
1600 |
|
1601 |
|
1602 |
|
1603 /r remount existing FS (dismount and mount it back); example: "mount d: /r" |
|
1604 */ |
1528 */ |
1605 TInt ShellFunction::MountFileSystem(TDes& aArgs, TUint aSwitches) |
1529 TInt ShellFunction::MountFileSystem(TDes& aArgs, TUint aSwitches) |
1606 { |
1530 { |
1607 ShellFunction::StripQuotes(aArgs); |
1531 ShellFunction::StripQuotes(aArgs); |
1608 aArgs.UpperCase(); |
1532 aArgs.UpperCase(); |
2052 |
1976 |
2053 return nRes; |
1977 return nRes; |
2054 } |
1978 } |
2055 |
1979 |
2056 //----------------------------------------------------------------------------------------------------------------------- |
1980 //----------------------------------------------------------------------------------------------------------------------- |
2057 /** |
1981 |
2058 Hex Dump of a file |
|
2059 */ |
|
2060 TInt ShellFunction::Hexdump(TDes& aPath,TUint aSwitches) |
1982 TInt ShellFunction::Hexdump(TDes& aPath,TUint aSwitches) |
2061 { |
1983 { |
2062 ShellFunction::StripQuotes(aPath); |
1984 ShellFunction::StripQuotes(aPath); |
2063 |
1985 |
2064 ParsePath(aPath); |
1986 ParsePath(aPath); |
2065 |
|
2066 RFile64 file; |
1987 RFile64 file; |
2067 TInt r=file.Open(TheShell->TheFs,aPath,EFileStream); |
1988 TInt r=file.Open(TheShell->TheFs,aPath,EFileStream); |
2068 if (r!=KErrNone) |
1989 if (r!=KErrNone) |
2069 return(r); |
1990 return(r); |
2070 |
1991 |
|
1992 TInt offset=0; |
|
1993 for (;;) |
|
1994 { |
2071 const TInt KLineLength = 16; |
1995 const TInt KLineLength = 16; |
2072 TBuf<0x100> buf; |
1996 |
2073 TBuf<KLineLength> asciiBuf; |
|
2074 TBuf8<KLineLength> line; |
1997 TBuf8<KLineLength> line; |
2075 |
|
2076 for (;;) |
|
2077 { |
|
2078 r=file.Read(line); |
1998 r=file.Read(line); |
2079 if (r != KErrNone || line.Length() == 0) |
1999 if (r != KErrNone || line.Length() == 0) |
2080 break; |
2000 break; |
2081 |
2001 |
2082 buf.Zero(); |
2002 TBuf<KLineLength*3+2> hexaRep; |
2083 asciiBuf.Zero(); |
2003 TBuf<KLineLength> asciiRep; |
2084 |
|
2085 for (TInt i=0; i<KLineLength; i++) |
2004 for (TInt i=0; i<KLineLength; i++) |
2086 { |
2005 { |
2087 if (i == KLineLength/2) |
2006 if (i == KLineLength/2) |
2088 { |
2007 { |
2089 buf.Append(' '); |
2008 hexaRep.Append(' '); |
2090 buf.Append(i<line.Length() ? '|' : ' '); |
2009 hexaRep.Append(i<line.Length() ? '|' : ' '); |
2091 } |
2010 } |
2092 |
2011 |
2093 buf.Append(' '); |
2012 hexaRep.Append(' '); |
2094 |
2013 |
2095 if (i<line.Length()) |
2014 if (i<line.Length()) |
2096 { |
2015 { |
2097 buf.AppendNumFixedWidth(line[i], EHex, 2); |
2016 hexaRep.AppendNumFixedWidth(line[i], EHex, 2); |
2098 asciiBuf.Append(TChar(line[i]).IsPrint() ? line[i] : '.'); |
2017 asciiRep.Append(TChar(line[i]).IsPrint() ? line[i] : '.'); |
2099 } |
2018 } |
2100 else |
2019 else |
2101 buf.AppendFill(' ', 2); |
2020 hexaRep.AppendFill(' ', 2); |
2102 } |
2021 } |
2103 |
2022 |
2104 _LIT(KPrompt , " Hit escape to quit hexdump or any other key to continue\n"); |
2023 _LIT(KPrompt , " Hit escape to quit hexdump or any other key to continue\n"); |
2105 |
2024 _LIT(KLineFmt, " %+07x0:%S %S\n"); |
2106 buf.Append(_L(" ")); |
2025 TKeyCode key=CShell::OutputStringToConsole(KPrompt ,(aSwitches&TShellCommand::EPSwitch)!=0,KLineFmt, offset++,&hexaRep, &asciiRep); |
2107 buf.Append(asciiBuf); |
2026 |
2108 buf.Append(KNl); |
|
2109 |
|
2110 TKeyCode key= CShell::WriteBufToConsole((aSwitches&TShellCommand::EPSwitch)!=0, buf, KPrompt); |
|
2111 if (key==EKeyEscape) |
2027 if (key==EKeyEscape) |
2112 break; |
2028 break; |
2113 } |
2029 } |
2114 |
2030 |
2115 if (r == KErrNone) |
2031 if (r == KErrNone) |
2432 { |
2348 { |
2433 public: |
2349 public: |
2434 TInt DisplayHelp(); |
2350 TInt DisplayHelp(); |
2435 TInt DisplayMessage(const TFullName& aName); |
2351 TInt DisplayMessage(const TFullName& aName); |
2436 TInt DisplayCmdUnknown(); |
2352 TInt DisplayCmdUnknown(); |
2437 void GetAll(const TDes& aName); |
2353 TInt GetAll(const TDes& aName); |
2438 void GetProcesses(const TDes& aName); |
2354 TInt GetProcesses(const TDes& aName); |
2439 void GetThreads(const TDes& aName); |
2355 TInt GetThreads(const TDes& aName); |
2440 void GetChunks(const TDes& aName); |
2356 TInt GetChunks(const TDes& aName); |
2441 void GetServers(const TDes& aName); |
2357 TInt GetServers(const TDes& aName); |
2442 // TInt GetSessions(const TDes& aName); |
2358 // TInt GetSessions(const TDes& aName); |
2443 void GetLibraries(const TDes& aName); |
2359 TInt GetLibraries(const TDes& aName); |
2444 // TInt GetLogicalChannels(const TDes& aName); |
2360 // TInt GetLogicalChannels(const TDes& aName); |
2445 void GetLogicalDevices(const TDes& aName); |
2361 TInt GetLogicalDevices(const TDes& aName); |
2446 void GetPhysicalDevices(const TDes& aName); |
2362 TInt GetPhysicalDevices(const TDes& aName); |
2447 void GetSemaphores(const TDes& aName); |
2363 TInt GetSemaphores(const TDes& aName); |
2448 void GetMutexes(const TDes& aName); |
2364 TInt GetMutexes(const TDes& aName); |
2449 private: |
2365 private: |
2450 void DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription); |
2366 void DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription); |
2451 TBool Prepare(const TFullName& aName); |
2367 TInt Prepare(const TFullName& aName); |
2452 TBool Prepare(const TFullName& aName,TCallBack& aCallBack); |
2368 TInt Prepare(const TFullName& aName,TCallBack& aCallBack); |
2453 TInt Display(TFullName& aName); |
2369 TInt Display(TFullName& aName); |
2454 TFullName iPrevName; |
2370 TFullName iPrevName; |
2455 TCallBack iCallBack; |
2371 TCallBack iCallBack; |
2456 TBool useCallBack; |
2372 TBool useCallBack; |
2457 }; |
2373 }; |
2502 // GetLogicalChannels(aName); |
2419 // GetLogicalChannels(aName); |
2503 GetLogicalDevices(aName); |
2420 GetLogicalDevices(aName); |
2504 GetPhysicalDevices(aName); |
2421 GetPhysicalDevices(aName); |
2505 GetSemaphores(aName); |
2422 GetSemaphores(aName); |
2506 GetMutexes(aName); |
2423 GetMutexes(aName); |
2507 |
2424 return KErrNone; |
2508 } |
2425 } |
2509 |
2426 |
2510 void TShowProcInfo::GetProcesses(const TDes& aName) |
2427 TInt TShowProcInfo::GetProcesses(const TDes& aName) |
2511 { |
2428 { |
2512 |
2429 |
2513 TFindProcess findHb; |
2430 TFindProcess findHb; |
2514 findHb.Find(aName); |
2431 findHb.Find(aName); |
2515 TFullName name; |
2432 TFullName name; |
2516 |
2433 Prepare(_L("PROCESSES")); |
2517 if(!Prepare(_L("PROCESSES"))) |
|
2518 return; |
|
2519 |
|
2520 while (findHb.Next(name)==KErrNone) |
2434 while (findHb.Next(name)==KErrNone) |
2521 { |
2435 { |
2522 Display(name); |
2436 Display(name); |
2523 } |
2437 } |
2524 |
2438 return KErrNone; |
2525 } |
2439 } |
2526 |
2440 |
2527 void TShowProcInfo::GetThreads(const TDes& aName) |
2441 TInt TShowProcInfo::GetThreads(const TDes& aName) |
2528 { |
2442 { |
2529 TInt threads=0; |
2443 TInt threads=0; |
2530 TFindThread findHb; |
2444 TFindThread findHb; |
2531 findHb.Find(aName); |
2445 findHb.Find(aName); |
2532 TFullName name; |
2446 TFullName name; |
2533 TAny* findPtr=(TAny*)&findHb; |
2447 TAny* findPtr=(TAny*)&findHb; |
2534 |
2448 |
2535 // Modified by WR, November 1997 |
2449 // Modified by WR, November 1997 |
2536 TCallBack threadCallBack(GetThreadInfo,findPtr); |
2450 TCallBack threadCallBack(GetThreadInfo,findPtr); |
2537 |
2451 Prepare(_L("THREADS"),threadCallBack); |
2538 if(!Prepare(_L("THREADS"),threadCallBack)) |
|
2539 return; |
|
2540 |
|
2541 while (findHb.Next(name)==KErrNone) |
2452 while (findHb.Next(name)==KErrNone) |
2542 { |
2453 { |
2543 Display(name); |
2454 Display(name); |
2544 threads += 1; |
2455 threads += 1; |
2545 } |
2456 } |
2654 } |
2558 } |
2655 return KErrNone; |
2559 return KErrNone; |
2656 } |
2560 } |
2657 */ |
2561 */ |
2658 |
2562 |
2659 void TShowProcInfo::GetLogicalDevices(const TDes& aName) |
2563 TInt TShowProcInfo::GetLogicalDevices(const TDes& aName) |
2660 { |
2564 { |
2661 |
2565 |
2662 TFindLogicalDevice findHb; |
2566 TFindLogicalDevice findHb; |
2663 findHb.Find(aName); |
2567 findHb.Find(aName); |
2664 TFullName name; |
2568 TFullName name; |
2665 |
2569 Prepare(_L("LOGICAL DEVICES")); |
2666 if(!Prepare(_L("LOGICAL DEVICES"))) |
|
2667 return; |
|
2668 |
|
2669 while (findHb.Next(name)==KErrNone) |
2570 while (findHb.Next(name)==KErrNone) |
2670 { |
2571 { |
2671 Display(name); |
2572 Display(name); |
2672 } |
2573 } |
2673 |
2574 return KErrNone; |
2674 } |
2575 } |
2675 |
2576 |
2676 void TShowProcInfo::GetPhysicalDevices(const TDes& aName) |
2577 TInt TShowProcInfo::GetPhysicalDevices(const TDes& aName) |
2677 { |
2578 { |
2678 |
2579 |
2679 TFindPhysicalDevice findHb; |
2580 TFindPhysicalDevice findHb; |
2680 findHb.Find(aName); |
2581 findHb.Find(aName); |
2681 TFullName name; |
2582 TFullName name; |
2682 |
2583 Prepare(_L("PHYSICAL DEVICES")); |
2683 if(!Prepare(_L("PHYSICAL DEVICES"))) |
|
2684 return; |
|
2685 |
|
2686 while (findHb.Next(name)==KErrNone) |
2584 while (findHb.Next(name)==KErrNone) |
2687 { |
2585 { |
2688 Display(name); |
2586 Display(name); |
2689 } |
2587 } |
2690 |
2588 return KErrNone; |
2691 } |
2589 } |
2692 |
2590 |
2693 void TShowProcInfo::GetSemaphores(const TDes& aName) |
2591 TInt TShowProcInfo::GetSemaphores(const TDes& aName) |
2694 { |
2592 { |
2695 TFindSemaphore findHb; |
2593 TFindSemaphore findHb; |
2696 findHb.Find(aName); |
2594 findHb.Find(aName); |
2697 TFullName name; |
2595 TFullName name; |
2698 if(!Prepare(_L("SEMAPHORES"))) |
2596 Prepare(_L("SEMAPHORES")); |
2699 return; |
|
2700 |
|
2701 while (findHb.Next(name)==KErrNone) |
2597 while (findHb.Next(name)==KErrNone) |
2702 { |
2598 { |
2703 Display(name); |
2599 Display(name); |
2704 } |
2600 } |
2705 |
2601 return KErrNone; |
2706 } |
2602 } |
2707 |
2603 |
2708 void TShowProcInfo::GetMutexes(const TDes& aName) |
2604 TInt TShowProcInfo::GetMutexes(const TDes& aName) |
2709 { |
2605 { |
2710 |
2606 |
2711 TFindMutex findHb; |
2607 TFindMutex findHb; |
2712 findHb.Find(aName); |
2608 findHb.Find(aName); |
2713 TFullName name; |
2609 TFullName name; |
2714 if(!Prepare(_L("MUTEXES"))) |
2610 Prepare(_L("MUTEXES")); |
2715 return; |
|
2716 while (findHb.Next(name)==KErrNone) |
2611 while (findHb.Next(name)==KErrNone) |
2717 { |
2612 { |
2718 Display(name); |
2613 Display(name); |
2719 } |
2614 } |
2720 |
2615 return KErrNone; |
2721 } |
2616 } |
2722 |
2617 |
2723 void TShowProcInfo::DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription) |
2618 void TShowProcInfo::DisplayHelpLine(const TDesC& aCommand, const TDesC& aDescription) |
2724 { |
2619 { |
2725 CShell::OutputStringToConsole(ETrue,_L("%- *S%S\n"),8,&aCommand,&aDescription); |
2620 CShell::OutputStringToConsole(ETrue,_L("%- *S%S\n"),8,&aCommand,&aDescription); |
2726 } |
2621 } |
2727 |
2622 |
2728 |
2623 |
2729 TBool TShowProcInfo::Prepare(const TFullName& aName) |
2624 TInt TShowProcInfo::Prepare(const TFullName& aName) |
2730 { |
2625 { |
2731 |
2626 |
2732 iPrevName=_L(""); |
2627 iPrevName=_L(""); |
2733 TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName); |
2628 CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName); |
2734 |
|
2735 if(key==EKeyEscape) |
|
2736 return EFalse; |
|
2737 |
|
2738 useCallBack=EFalse; |
2629 useCallBack=EFalse; |
2739 return ETrue; |
2630 return KErrNone; |
2740 } |
2631 } |
2741 |
2632 |
2742 TBool TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack) |
2633 TInt TShowProcInfo::Prepare(const TFullName& aName,TCallBack& aCallBack) |
2743 { |
2634 { |
|
2635 |
2744 iPrevName=_L(""); |
2636 iPrevName=_L(""); |
2745 TKeyCode key = CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName); |
2637 CShell::OutputStringToConsole(ETrue,_L("--%S-->\n"),&aName); |
2746 |
|
2747 if(key==EKeyEscape) |
|
2748 return EFalse; |
|
2749 |
|
2750 |
|
2751 useCallBack=ETrue; |
2638 useCallBack=ETrue; |
2752 iCallBack=aCallBack; |
2639 iCallBack=aCallBack; |
2753 |
2640 return KErrNone; |
2754 return ETrue; |
|
2755 } |
2641 } |
2756 |
2642 |
2757 TInt TShowProcInfo::Display(TFullName& aName) |
2643 TInt TShowProcInfo::Display(TFullName& aName) |
2758 |
2644 |
2759 // Modifications by WR, November 1997 |
2645 // Modifications by WR, November 1997 |