43 } |
43 } |
44 |
44 |
45 void ReadBootSector(TFatBootSector& aBootSector) |
45 void ReadBootSector(TFatBootSector& aBootSector) |
46 { |
46 { |
47 TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
47 TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
48 test_KErrNone(nRes); |
48 test(nRes == KErrNone); |
49 |
49 |
50 if(!aBootSector.IsValid()) |
50 if(!aBootSector.IsValid()) |
51 { |
51 { |
52 test.Printf(_L("Wrong bootsector! Dump:\n")); |
52 test.Printf(_L("Wrong bootsector! Dump:\n")); |
53 aBootSector.PrintDebugInfo(); |
53 aBootSector.PrintDebugInfo(); |
71 longDirNamePath += aLongName; |
71 longDirNamePath += aLongName; |
72 longDirNamePath.Append('\\'); |
72 longDirNamePath.Append('\\'); |
73 |
73 |
74 // Create new directory and check creation |
74 // Create new directory and check creation |
75 TInt r = TheFs.MkDir(longDirNamePath); |
75 TInt r = TheFs.MkDir(longDirNamePath); |
76 test_KErrNone(r); |
76 test(r==KErrNone); |
77 |
77 |
78 TUint dumUint=0; |
78 TUint dumUint=0; |
79 CDir* dumDir; |
79 CDir* dumDir; |
80 r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir); |
80 r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir); |
81 test_KErrNone(r); |
81 test(r==KErrNone); |
82 test_NotNull(dumDir); |
82 test_NotNull(dumDir); |
83 delete dumDir; |
83 delete dumDir; |
84 |
84 |
85 // Check short name |
85 // Check short name |
86 r = TheFs.GetShortName(longDirNamePath, shortName); |
86 r = TheFs.GetShortName(longDirNamePath, shortName); |
87 test_KErrNone(r); |
87 test(r==KErrNone); |
88 r = shortName.Compare(aShortName); |
88 r = shortName.Compare(aShortName); |
89 test_Value(r, r == 0); |
89 test(r==0); |
90 |
90 |
91 // Check long name |
91 // Check long name |
92 shortDirNamePath = gSessionPath; |
92 shortDirNamePath = gSessionPath; |
93 shortDirNamePath += shortName; |
93 shortDirNamePath += shortName; |
94 shortDirNamePath.Append('\\'); |
94 shortDirNamePath.Append('\\'); |
95 r = TheFs.GetLongName(shortDirNamePath, longName); |
95 r = TheFs.GetLongName(shortDirNamePath, longName); |
96 test_KErrNone(r); |
96 test(r==KErrNone); |
97 r = longName.Compare(aLongName); |
97 r = longName.Compare(aLongName); |
98 test_Value(r, r == 0); |
98 test(r==0); |
99 |
99 |
100 r = TheFs.RmDir(longDirNamePath); |
100 r = TheFs.RmDir(longDirNamePath); |
101 test_KErrNone(r); |
101 test(r==KErrNone); |
102 } |
102 } |
103 |
103 |
104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName) |
104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName) |
105 { |
105 { |
106 TFileName lgnFullPath; |
106 TFileName lgnFullPath; |
107 TFileName shnFullPath; |
107 TFileName shnFullPath; |
108 TFileName lgn; |
108 TFileName lgn; |
109 TFileName shn; |
109 TFileName shn; |
110 |
110 |
111 TInt r = TheFs.SessionPath(gSessionPath); |
111 TInt r = TheFs.SessionPath(gSessionPath); |
112 test_KErrNone(r); |
112 test(r==KErrNone); |
113 lgnFullPath = gSessionPath; |
113 lgnFullPath = gSessionPath; |
114 lgnFullPath += aLongName; |
114 lgnFullPath += aLongName; |
115 |
115 |
116 MakeFile_CPTest(lgnFullPath); |
116 MakeFile_CPTest(lgnFullPath); |
117 // Check short name |
117 // Check short name |
118 r = TheFs.GetShortName(lgnFullPath, shn); |
118 r = TheFs.GetShortName(lgnFullPath, shn); |
119 test_KErrNone(r); |
119 test(r==KErrNone); |
120 r = shn.Compare(aShortName); |
120 r = shn.Compare(aShortName); |
121 test_Value(r, r == 0); |
121 test(r==0); |
122 |
122 |
123 // Check long name |
123 // Check long name |
124 shnFullPath = gSessionPath; |
124 shnFullPath = gSessionPath; |
125 shnFullPath += aShortName; |
125 shnFullPath += aShortName; |
126 |
126 |
127 r = TheFs.GetLongName(shnFullPath, lgn); |
127 r = TheFs.GetLongName(shnFullPath, lgn); |
128 test_KErrNone(r); |
128 test(r==KErrNone); |
129 r = lgn.Compare(aLongName); |
129 r = lgn.Compare(aLongName); |
130 test_Value(r, r == 0); |
130 test(r==0); |
131 |
131 |
132 r = TheFs.Delete(lgnFullPath); |
132 r = TheFs.Delete(lgnFullPath); |
133 test_KErrNone(r); |
133 test(r==KErrNone); |
134 |
134 |
135 } |
135 } |
136 #endif //_DEBUG || _DEBUG_RELEASE |
136 #endif //_DEBUG || _DEBUG_RELEASE |
137 |
137 |
138 //---------------------------------------------------------------------------------------------- |
138 //---------------------------------------------------------------------------------------------- |
158 { |
158 { |
159 test.Next(_L("Test unicode volume labels")); |
159 test.Next(_L("Test unicode volume labels")); |
160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
161 |
161 |
162 TInt r = TheFs.SessionPath(gSessionPath); |
162 TInt r = TheFs.SessionPath(gSessionPath); |
163 test_KErrNone(r); |
163 test(r==KErrNone); |
164 TInt driveNum; |
164 TInt driveNum; |
165 r = TheFs.CharToDrive(gSessionPath[0], driveNum); |
165 r = TheFs.CharToDrive(gSessionPath[0], driveNum); |
166 test_KErrNone(r); |
166 test(r==KErrNone); |
167 |
167 |
168 // Retrieves the original volume label |
168 // Retrieves the original volume label |
169 TVolumeInfo vInfo; |
169 TVolumeInfo vInfo; |
170 r = TheFs.Volume(vInfo, driveNum); |
170 r = TheFs.Volume(vInfo, driveNum); |
171 const TInt KVolumeLabelSize = 11; |
171 const TInt KVolumeLabelSize = 11; |
173 |
173 |
174 // Tests setting volume label with unicode characters |
174 // Tests setting volume label with unicode characters |
175 _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0"); |
175 _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0"); |
176 |
176 |
177 r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum); |
177 r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum); |
178 test_KErrNone(r); |
178 test(r==KErrNone); |
179 r = TheFs.Volume(vInfo, driveNum); |
179 r = TheFs.Volume(vInfo, driveNum); |
180 test_KErrNone(r); |
180 test(r==KErrNone); |
181 r = vInfo.iName.Compare(KUnicodeVolumeLabel); |
181 r = vInfo.iName.Compare(KUnicodeVolumeLabel); |
182 test_KErrNone(r); |
182 test(r==KErrNone); |
183 |
183 |
184 // Tests setting volume label with unicode characters that bigger than 11 bytes |
184 // Tests setting volume label with unicode characters that bigger than 11 bytes |
185 _LIT(KVolumeLabelOverflow, "\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0"); |
185 _LIT(KVolumeLabelOverflow, "\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0"); |
186 r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum); |
186 r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum); |
187 test_Value(r, r == KErrOverflow); |
187 test(r==KErrOverflow); |
188 |
188 |
189 // Sets back the original volume label |
189 // Sets back the original volume label |
190 r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum); |
190 r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum); |
191 test_KErrNone(r); |
191 test(r==KErrNone); |
192 r = TheFs.Volume(vInfo, driveNum); |
192 r = TheFs.Volume(vInfo, driveNum); |
193 test_KErrNone(r); |
193 test(r==KErrNone); |
194 r = vInfo.iName.Compare(originalVolumeLabel); |
194 r = vInfo.iName.Compare(originalVolumeLabel); |
195 test_Value(r, r == 0); |
195 test(r==0); |
196 #else |
196 #else |
197 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
197 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
198 #endif // _DEBUG) || _DEBUG_RELEASE |
198 #endif // _DEBUG) || _DEBUG_RELEASE |
199 } |
199 } |
200 |
200 |
430 TFileName sn; |
430 TFileName sn; |
431 TInt r; |
431 TInt r; |
432 MakeFile_CPTest(KTestFileName4C8B); |
432 MakeFile_CPTest(KTestFileName4C8B); |
433 MakeFile_CPTest(KTestFileName7C11B); |
433 MakeFile_CPTest(KTestFileName7C11B); |
434 r = TheFs.GetShortName(KTestFileName7C11B, sn); |
434 r = TheFs.GetShortName(KTestFileName7C11B, sn); |
435 test_KErrNone(r); |
435 test(r==KErrNone); |
436 r = sn.Compare(KTestFileName7C11B_short); |
436 r = sn.Compare(KTestFileName7C11B_short); |
437 test_Value(r, r == 0); |
437 test(r==0); |
438 |
438 |
439 |
439 |
440 MakeFile_CPTest(KTestFileName8C12B); |
440 MakeFile_CPTest(KTestFileName8C12B); |
441 r = TheFs.GetShortName(KTestFileName8C12B, sn); |
441 r = TheFs.GetShortName(KTestFileName8C12B, sn); |
442 test_KErrNone(r); |
442 test(r==KErrNone); |
443 r = sn.Compare(KTestFileName8C12B_short); |
443 r = sn.Compare(KTestFileName8C12B_short); |
444 test_Value(r, r == 0); |
444 test(r==0); |
445 |
445 |
446 r = TheFs.Delete(KTestFileName4C8B); |
446 r = TheFs.Delete(KTestFileName4C8B); |
447 test_KErrNone(r); |
447 test(r==KErrNone); |
448 |
448 |
449 r = TheFs.Delete(KTestFileName7C11B); |
449 r = TheFs.Delete(KTestFileName7C11B); |
450 test_KErrNone(r); |
450 test(r==KErrNone); |
451 |
451 |
452 r = TheFs.Delete(KTestFileName8C12B); |
452 r = TheFs.Delete(KTestFileName8C12B); |
453 test_KErrNone(r); |
453 test(r==KErrNone); |
454 |
454 |
455 #else |
455 #else |
456 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
456 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
457 #endif // _DEBUG) || _DEBUG_RELEASE |
457 #endif // _DEBUG) || _DEBUG_RELEASE |
458 } |
458 } |
507 MakeDir(KTestDirName7C11B); |
507 MakeDir(KTestDirName7C11B); |
508 |
508 |
509 TFileName sn; |
509 TFileName sn; |
510 |
510 |
511 r = TheFs.GetShortName(KTestDirName7C11B, sn); |
511 r = TheFs.GetShortName(KTestDirName7C11B, sn); |
512 test_KErrNone(r); |
512 test(r==KErrNone); |
513 r = sn.Compare(KTestDirName7C11B_short); |
513 r = sn.Compare(KTestDirName7C11B_short); |
514 test_Value(r, r == 0); |
514 test(r==0); |
515 |
515 |
516 MakeDir(KTestDirName8C12B); |
516 MakeDir(KTestDirName8C12B); |
517 r = TheFs.GetShortName(KTestDirName8C12B, sn); |
517 r = TheFs.GetShortName(KTestDirName8C12B, sn); |
518 test_KErrNone(r); |
518 test(r==KErrNone); |
519 r = sn.Compare(KTestDirName8C12B_short); |
519 r = sn.Compare(KTestDirName8C12B_short); |
520 test_Value(r, r == 0); |
520 test(r==0); |
521 |
521 |
522 #else |
522 #else |
523 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
523 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
524 #endif // _DEBUG) || _DEBUG_RELEASE |
524 #endif // _DEBUG) || _DEBUG_RELEASE |
525 } |
525 } |
585 TInt r; |
585 TInt r; |
586 MakeFile_CPTest(KTestFilePathAndName); |
586 MakeFile_CPTest(KTestFilePathAndName); |
587 |
587 |
588 TFileName sn; |
588 TFileName sn; |
589 r = TheFs.GetShortName(KTestFilePathAndName, sn); |
589 r = TheFs.GetShortName(KTestFilePathAndName, sn); |
590 test_KErrNone(r); |
590 test(r==KErrNone); |
591 r = sn.Compare(KTestFileName); |
591 r = sn.Compare(KTestFileName); |
592 test_Value(r, r == 0); |
592 test(r==0); |
593 TFileName ln; |
593 TFileName ln; |
594 r = TheFs.GetLongName(KTestFilePathAndName, ln); |
594 r = TheFs.GetLongName(KTestFilePathAndName, ln); |
595 test_KErrNone(r); |
595 test(r==KErrNone); |
596 r = ln.Compare(KTestFileName); |
596 r = ln.Compare(KTestFileName); |
597 test_Value(r, r == 0); |
597 test(r==0); |
598 |
598 |
599 #else |
599 #else |
600 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
600 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
601 #endif |
601 #endif |
602 } |
602 } |
622 |
622 |
623 RFile file; |
623 RFile file; |
624 TFileName fn = _L("\\ABCD"); |
624 TFileName fn = _L("\\ABCD"); |
625 |
625 |
626 TInt r=file.Create(TheFs,fn,EFileRead); |
626 TInt r=file.Create(TheFs,fn,EFileRead); |
627 test_KErrNone(r); |
627 test(r==KErrNone); |
628 file.Close(); |
628 file.Close(); |
629 |
629 |
630 // Assume this file is the first entry in the root directory |
630 // Assume this file is the first entry in the root directory |
631 r=TheDisk.Open(TheFs,CurrentDrive()); |
631 r=TheDisk.Open(TheFs,CurrentDrive()); |
632 test_KErrNone(r); |
632 test(r==KErrNone); |
633 |
633 |
634 //-- read the 1st dir entry, it should be a DOS entry |
634 //-- read the 1st dir entry, it should be a DOS entry |
635 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
635 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
636 |
636 |
637 TFatDirEntry fatEntry1; |
637 TFatDirEntry fatEntry1; |
695 RFile file; |
695 RFile file; |
696 TFileName fn = _L("\\AB"); |
696 TFileName fn = _L("\\AB"); |
697 |
697 |
698 test.Next(_L("create file \"AB\" under root directory")); |
698 test.Next(_L("create file \"AB\" under root directory")); |
699 TInt r=file.Create(TheFs,fn,EFileRead); |
699 TInt r=file.Create(TheFs,fn,EFileRead); |
700 test_KErrNone(r); |
700 test(r==KErrNone); |
701 file.Close(); |
701 file.Close(); |
702 |
702 |
703 test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing")); |
703 test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing")); |
704 // Assume this file is the first entry in the root directory |
704 // Assume this file is the first entry in the root directory |
705 r=TheDisk.Open(TheFs,CurrentDrive()); |
705 r=TheDisk.Open(TheFs,CurrentDrive()); |
706 test_KErrNone(r); |
706 test(r==KErrNone); |
707 |
707 |
708 //-- read the first dir entry, it should be a DOS entry |
708 //-- read the first dir entry, it should be a DOS entry |
709 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
709 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
710 |
710 |
711 TFatDirEntry fatEntry1; |
711 TFatDirEntry fatEntry1; |
781 MakeFile_CPTest(fn); |
781 MakeFile_CPTest(fn); |
782 |
782 |
783 _LIT(KShortName, "\x3055\x307E\x3056~1"); |
783 _LIT(KShortName, "\x3055\x307E\x3056~1"); |
784 TFileName sn; |
784 TFileName sn; |
785 r = TheFs.GetShortName(fn, sn); |
785 r = TheFs.GetShortName(fn, sn); |
786 test_KErrNone(r); |
786 test(r==KErrNone); |
787 r = sn.Compare(KShortName); |
787 r = sn.Compare(KShortName); |
788 test_Value(r, r == 0); |
788 test(r==0); |
789 |
789 |
790 r = TheFs.ScanDrive(_L("gSessionPath")); |
790 r = TheFs.ScanDrive(_L("gSessionPath")); |
791 test_KErrNone(r); |
791 test(r==KErrNone); |
792 |
792 |
793 r = TheFs.Delete(fn); |
793 r = TheFs.Delete(fn); |
794 test_KErrNone(r); |
794 test(r == KErrNone); |
795 #else |
795 #else |
796 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
796 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
797 #endif // _DEBUG) || _DEBUG_RELEASE |
797 #endif // _DEBUG) || _DEBUG_RELEASE |
798 } |
798 } |
799 |
799 |