48 TBuf<4> driveBuf=_L("?:\\"); |
48 TBuf<4> driveBuf=_L("?:\\"); |
49 driveBuf[0]=(TText)(aDrive+'A'); |
49 driveBuf[0]=(TText)(aDrive+'A'); |
50 RFormat format; |
50 RFormat format; |
51 TInt count; |
51 TInt count; |
52 TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); |
52 TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); |
53 test_KErrNone(r); |
53 test(r==KErrNone); |
54 while(count) |
54 while(count) |
55 { |
55 { |
56 TInt r=format.Next(count); |
56 TInt r=format.Next(count); |
57 test_KErrNone(r); |
57 test(r==KErrNone); |
58 } |
58 } |
59 format.Close(); |
59 format.Close(); |
60 } |
60 } |
61 |
61 |
62 void MakeDir(const TDesC& aDirName) |
62 void MakeDir(const TDesC& aDirName) |
63 // |
63 // |
64 // Make a directory |
64 // Make a directory |
65 // |
65 // |
66 { |
66 { |
67 TInt r=TheFs.MkDirAll(aDirName); |
67 TInt r=TheFs.MkDirAll(aDirName); |
68 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
68 test(r==KErrNone || r==KErrAlreadyExists); |
69 } |
69 } |
70 |
70 |
71 |
71 |
72 void ReportCheckDiskFailure(TInt aRet) |
72 void ReportCheckDiskFailure(TInt aRet) |
73 // |
73 // |
92 // |
92 // |
93 { |
93 { |
94 TParsePtrC path(aSessionPath); |
94 TParsePtrC path(aSessionPath); |
95 test(path.DrivePresent()==EFalse); |
95 test(path.DrivePresent()==EFalse); |
96 TInt r=TheFs.SetSessionPath(aSessionPath); |
96 TInt r=TheFs.SetSessionPath(aSessionPath); |
97 test_KErrNone(r); |
97 test(r==KErrNone); |
98 r=TheFs.SessionPath(gSessionPath); |
98 r=TheFs.SessionPath(gSessionPath); |
99 test_KErrNone(r); |
99 test(r==KErrNone); |
100 r=TheFs.MkDirAll(gSessionPath); |
100 r=TheFs.MkDirAll(gSessionPath); |
101 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
101 test(r==KErrNone || r==KErrAlreadyExists); |
102 } |
102 } |
103 |
103 |
104 TInt CurrentDrive(TChar aDriveChar) |
104 TInt CurrentDrive(TChar aDriveChar) |
105 // |
105 // |
106 // Return the current drive number |
106 // Return the current drive number |
107 // |
107 // |
108 { |
108 { |
109 TInt driveNum; |
109 TInt driveNum; |
110 TInt r = TheFs.CharToDrive(aDriveChar,driveNum); |
110 TInt r = TheFs.CharToDrive(aDriveChar,driveNum); |
111 test_KErrNone(r); |
111 test(r==KErrNone); |
112 gDriveToTest = gSessionPath[0] = (TText)aDriveChar; |
112 gDriveToTest = gSessionPath[0] = (TText)aDriveChar; |
113 return(driveNum); |
113 return(driveNum); |
114 } |
114 } |
115 |
115 |
116 TInt CurrentDrive() |
116 TInt CurrentDrive() |
118 // Return the current drive number |
118 // Return the current drive number |
119 // |
119 // |
120 { |
120 { |
121 TInt driveNum; |
121 TInt driveNum; |
122 TInt r = TheFs.CharToDrive(gSessionPath[0],driveNum); |
122 TInt r = TheFs.CharToDrive(gSessionPath[0],driveNum); |
123 test_KErrNone(r); |
123 test(r==KErrNone); |
124 return(driveNum); |
124 return(driveNum); |
125 } |
125 } |
126 |
126 |
127 void MakeFile(const TDesC& aFileName,const TUidType& aUidType,const TDesC8& aFileContents) |
127 void MakeFile(const TDesC& aFileName,const TUidType& aUidType,const TDesC8& aFileContents) |
128 // |
128 // |
129 // Make a file and write uid and data |
129 // Make a file and write uid and data |
130 // |
130 // |
131 { |
131 { |
132 RFile file; |
132 RFile file; |
133 TInt r=file.Replace(TheFs,aFileName,0); |
133 TInt r=file.Replace(TheFs,aFileName,0); |
134 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
134 test(r==KErrNone || r==KErrPathNotFound); |
135 if (r==KErrPathNotFound) |
135 if (r==KErrPathNotFound) |
136 { |
136 { |
137 r=TheFs.MkDirAll(aFileName); |
137 r=TheFs.MkDirAll(aFileName); |
138 test_KErrNone(r); |
138 test(r==KErrNone); |
139 r=file.Replace(TheFs,aFileName,0); |
139 r=file.Replace(TheFs,aFileName,0); |
140 test_KErrNone(r); |
140 test(r==KErrNone); |
141 } |
141 } |
142 TCheckedUid checkedUid(aUidType); |
142 TCheckedUid checkedUid(aUidType); |
143 TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
143 TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
144 r=file.Write(uidData); |
144 r=file.Write(uidData); |
145 test_KErrNone(r); |
145 test(r==KErrNone); |
146 r=file.Write(aFileContents); |
146 r=file.Write(aFileContents); |
147 test_KErrNone(r); |
147 test(r==KErrNone); |
148 file.Close(); |
148 file.Close(); |
149 } |
149 } |
150 |
150 |
151 void MakeFile(const TDesC& aFileName,const TDesC8& aFileContents) |
151 void MakeFile(const TDesC& aFileName,const TDesC8& aFileContents) |
152 // |
152 // |
158 if(r!=KErrNone && r!=KErrPathNotFound) |
158 if(r!=KErrNone && r!=KErrPathNotFound) |
159 { |
159 { |
160 test.Printf(_L("ERROR: r=%d"),r); |
160 test.Printf(_L("ERROR: r=%d"),r); |
161 test(EFalse); |
161 test(EFalse); |
162 } |
162 } |
163 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
163 test(r==KErrNone || r==KErrPathNotFound); |
164 if (r==KErrPathNotFound) |
164 if (r==KErrPathNotFound) |
165 { |
165 { |
166 r=TheFs.MkDirAll(aFileName); |
166 r=TheFs.MkDirAll(aFileName); |
167 test_KErrNone(r); |
167 test(r==KErrNone); |
168 r=file.Replace(TheFs,aFileName,0); |
168 r=file.Replace(TheFs,aFileName,0); |
169 test_KErrNone(r); |
169 test(r==KErrNone); |
170 } |
170 } |
171 r=file.Write(aFileContents); |
171 r=file.Write(aFileContents); |
172 test_KErrNone(r); |
172 test(r==KErrNone); |
173 file.Close(); |
173 file.Close(); |
174 } |
174 } |
175 |
175 |
176 void MakeFile(const TDesC& aFileName,TInt anAttributes) |
176 void MakeFile(const TDesC& aFileName,TInt anAttributes) |
177 // |
177 // |
178 // Make a file and write something in it |
178 // Make a file and write something in it |
179 // |
179 // |
180 { |
180 { |
181 RFile file; |
181 RFile file; |
182 TInt r=file.Replace(TheFs,aFileName,0); |
182 TInt r=file.Replace(TheFs,aFileName,0); |
183 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
183 test(r==KErrNone || r==KErrPathNotFound); |
184 if (r==KErrPathNotFound) |
184 if (r==KErrPathNotFound) |
185 { |
185 { |
186 r=TheFs.MkDirAll(aFileName); |
186 r=TheFs.MkDirAll(aFileName); |
187 test_KErrNone(r); |
187 test(r==KErrNone); |
188 r=file.Replace(TheFs,aFileName,0); |
188 r=file.Replace(TheFs,aFileName,0); |
189 test_KErrNone(r); |
189 test(r==KErrNone); |
190 } |
190 } |
191 file.Close(); |
191 file.Close(); |
192 r=TheFs.SetAtt(aFileName,anAttributes,0); |
192 r=TheFs.SetAtt(aFileName,anAttributes,0); |
193 test_KErrNone(r); |
193 test(r==KErrNone); |
194 } |
194 } |
195 |
195 |
196 void MakeFile(const TDesC& aFileName) |
196 void MakeFile(const TDesC& aFileName) |
197 // |
197 // |
198 // Make a file |
198 // Make a file |
208 } |
208 } |
209 |
209 |
210 void ReadBootSector(TFatBootSector& aBootSector) |
210 void ReadBootSector(TFatBootSector& aBootSector) |
211 { |
211 { |
212 TInt r = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
212 TInt r = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
213 test_KErrNone(r); |
213 test(r==KErrNone); |
214 |
214 |
215 if(!aBootSector.IsValid()) |
215 if(!aBootSector.IsValid()) |
216 { |
216 { |
217 test.Printf(_L("Wrong bootsector! Dump:\n")); |
217 test.Printf(_L("Wrong bootsector! Dump:\n")); |
218 aBootSector.PrintDebugInfo(); |
218 aBootSector.PrintDebugInfo(); |
556 void RmDir(const TDesC& aDirName) |
556 void RmDir(const TDesC& aDirName) |
557 { |
557 { |
558 TFileName filename_dir = aDirName; |
558 TFileName filename_dir = aDirName; |
559 TInt r = 0; |
559 TInt r = 0; |
560 r = TheFs.SetAtt(filename_dir, 0, KEntryAttReadOnly); |
560 r = TheFs.SetAtt(filename_dir, 0, KEntryAttReadOnly); |
561 test_KErrNone(r); |
561 test(r==KErrNone); |
562 r=gFileMan->RmDir(filename_dir); |
562 r=gFileMan->RmDir(filename_dir); |
563 test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrPathNotFound || r==KErrInUse); |
563 test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound || r==KErrInUse); |
564 } |
564 } |
565 |
565 |
566 // Cleanup test variables |
566 // Cleanup test variables |
567 void Cleanup() |
567 void Cleanup() |
568 { |
568 { |
786 logFileName.Append(KUnderScore); |
786 logFileName.Append(KUnderScore); |
787 logFileName.Append(gDriveToTest); |
787 logFileName.Append(gDriveToTest); |
788 logFileName.Append(KExtension); |
788 logFileName.Append(KExtension); |
789 |
789 |
790 TInt r = file.Create(TheFs, logFileName, EFileRead|EFileWrite); |
790 TInt r = file.Create(TheFs, logFileName, EFileRead|EFileWrite); |
791 test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
791 test(r == KErrNone || r == KErrAlreadyExists); |
792 |
792 |
793 if (r == KErrNone) |
793 if (r == KErrNone) |
794 { |
794 { |
795 tempBuf.Append(KLogFileHeader); |
795 tempBuf.Append(KLogFileHeader); |
796 file.Write(tempBuf); |
796 file.Write(tempBuf); |
797 } |
797 } |
798 |
798 |
799 if (r == KErrAlreadyExists) |
799 if (r == KErrAlreadyExists) |
800 { |
800 { |
801 r = file.Open(TheFs, logFileName, EFileRead|EFileWrite); |
801 r = file.Open(TheFs, logFileName, EFileRead|EFileWrite); |
802 test_KErrNone(r); |
802 test(r == KErrNone); |
803 TInt start = 0; |
803 TInt start = 0; |
804 r=file.Seek(ESeekEnd,start); |
804 r=file.Seek(ESeekEnd,start); |
805 test_KErrNone(r); |
805 test(r == KErrNone); |
806 } |
806 } |
807 |
807 |
808 tempBuf.SetLength(0); |
808 tempBuf.SetLength(0); |
809 tempBuf.Append(KNewLine); |
809 tempBuf.Append(KNewLine); |
810 if(gIOTesting) |
810 if(gIOTesting) |