96 break; |
96 break; |
97 } |
97 } |
98 |
98 |
99 RFile file; |
99 RFile file; |
100 TInt r=file.Create(TheFs,fileName,EFileRead); |
100 TInt r=file.Create(TheFs,fileName,EFileRead); |
101 test(r==KErrNone); |
101 test_KErrNone(r); |
102 file.Close(); |
102 file.Close(); |
103 // Assume this file is the first entry in the root directory |
103 // Assume this file is the first entry in the root directory |
104 |
104 |
105 |
105 |
106 r=TheDisk.Open(TheFs,CurrentDrive()); |
106 r=TheDisk.Open(TheFs,CurrentDrive()); |
107 test(r==KErrNone); |
107 test_KErrNone(r); |
108 |
108 |
109 //-- read 1st dir. entry it can be FAT or VFat , depending on the filename |
109 //-- read 1st dir. entry it can be FAT or VFat , depending on the filename |
110 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
110 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
111 |
111 |
112 TFatDirEntry fatEntry1; |
112 TFatDirEntry fatEntry1; |
167 |
167 |
168 RFile file; |
168 RFile file; |
169 TInt r; |
169 TInt r; |
170 |
170 |
171 r=file.Replace(TheFs,_L("\\FILE.TMP"),EFileRead); |
171 r=file.Replace(TheFs,_L("\\FILE.TMP"),EFileRead); |
172 test(r==KErrNone); |
172 test_KErrNone(r); |
173 r=file.Write(_L8("Hello World")); |
173 r=file.Write(_L8("Hello World")); |
174 file.Close(); |
174 file.Close(); |
175 |
175 |
176 r=TheFs.Replace(_L("\\File.tmp"),_L("\\Word")); |
176 r=TheFs.Replace(_L("\\File.tmp"),_L("\\Word")); |
177 test(r==KErrNone); |
177 test_KErrNone(r); |
178 |
178 |
179 CDir* entryCount; |
179 CDir* entryCount; |
180 r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount); |
180 r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount); |
181 test(r==KErrNone); |
181 test_KErrNone(r); |
182 TInt count=entryCount->Count(); |
182 TInt count=entryCount->Count(); |
183 |
183 |
184 test(count==1); |
184 test(count==1); |
185 delete entryCount; |
185 delete entryCount; |
186 } |
186 } |
200 //-- N.B. This shall be the before any dir. entries creation in the root dir |
200 //-- N.B. This shall be the before any dir. entries creation in the root dir |
201 //-- because it directly accesses the directory's 1st file |
201 //-- because it directly accesses the directory's 1st file |
202 DoFiddleWithFileNames(aCase); |
202 DoFiddleWithFileNames(aCase); |
203 |
203 |
204 r=file.Create(TheFs,_L("\\TEST"),EFileRead); |
204 r=file.Create(TheFs,_L("\\TEST"),EFileRead); |
205 test(r==KErrNone); |
205 test_KErrNone(r); |
206 file.Close(); |
206 file.Close(); |
207 |
207 |
208 r=TheFs.Rename(_L("\\TEST"),_L("\\Word")); |
208 r=TheFs.Rename(_L("\\TEST"),_L("\\Word")); |
209 test(r==KErrAlreadyExists); |
209 test_Value(r, r == KErrAlreadyExists); |
210 r=TheFs.Delete(_L("\\TEST")); |
210 r=TheFs.Delete(_L("\\TEST")); |
211 test(r==KErrNone); |
211 test_KErrNone(r); |
212 |
212 |
213 CDir* entryCount; |
213 CDir* entryCount; |
214 r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount); |
214 r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount); |
215 test(r==KErrNone); |
215 test_KErrNone(r); |
216 TInt count=entryCount->Count(); |
216 TInt count=entryCount->Count(); |
217 test(count==1); |
217 test(count==1); |
218 delete entryCount; |
218 delete entryCount; |
219 } |
219 } |
220 |
220 |
239 |
239 |
240 TFileName fn; |
240 TFileName fn; |
241 fn.Format(_L("%c:\\\x60\x60\x60.TXT"), (TUint8)gDriveToTest); |
241 fn.Format(_L("%c:\\\x60\x60\x60.TXT"), (TUint8)gDriveToTest); |
242 |
242 |
243 r = TheFs.Delete(fn); |
243 r = TheFs.Delete(fn); |
244 test(r==KErrNone || r==KErrNotFound); |
244 test_Value(r, r == KErrNone || r==KErrNotFound); |
245 |
245 |
246 r = file.Create(TheFs, fn, EFileRead); |
246 r = file.Create(TheFs, fn, EFileRead); |
247 test(r==KErrNone); |
247 test_KErrNone(r); |
248 file.Close(); |
248 file.Close(); |
249 |
249 |
250 r=TheDisk.Open(TheFs,CurrentDrive()); |
250 r=TheDisk.Open(TheFs,CurrentDrive()); |
251 test(r==KErrNone); |
251 test_KErrNone(r); |
252 |
252 |
253 //-- read 1st dir. it should be DOS Entry |
253 //-- read 1st dir. it should be DOS Entry |
254 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
254 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
255 TFatDirEntry fatEntry1; |
255 TFatDirEntry fatEntry1; |
256 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
256 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
259 test(!fatEntry1.IsVFatEntry()); |
259 test(!fatEntry1.IsVFatEntry()); |
260 |
260 |
261 // tests short name |
261 // tests short name |
262 TFileName sn; |
262 TFileName sn; |
263 r = TheFs.GetShortName(fn, sn); |
263 r = TheFs.GetShortName(fn, sn); |
264 test(r==KErrNone); |
264 test_KErrNone(r); |
265 test(sn.Compare(_L("```.TXT"))==0); |
265 test(sn.Compare(_L("```.TXT"))==0); |
266 |
266 |
267 r = TheFs.Delete(fn); |
267 r = TheFs.Delete(fn); |
268 test(r==KErrNone); |
268 test_KErrNone(r); |
269 } |
269 } |
270 |
270 |
271 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
271 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
272 _LIT(KTestLocale, "t_tlocl_cp932.dll"); |
272 _LIT(KTestLocale, "t_tlocl_cp932.dll"); |
273 _LIT(KTestUnicodeFileName, "\\\x65B0\x6587\x4EF6"); |
273 _LIT(KTestUnicodeFileName, "\\\x65B0\x6587\x4EF6"); |
293 RFile file; |
293 RFile file; |
294 TInt r; |
294 TInt r; |
295 TInt drvNum; |
295 TInt drvNum; |
296 |
296 |
297 r = TheFs.CharToDrive(gDriveToTest,drvNum); |
297 r = TheFs.CharToDrive(gDriveToTest,drvNum); |
298 test(r==KErrNone); |
298 test_KErrNone(r); |
299 |
299 |
300 // turn on FatUtilityFunctions |
300 // turn on FatUtilityFunctions |
301 r = TheFs.ControlIo(drvNum, KControlIoEnableFatUtilityFunctions); |
301 r = TheFs.ControlIo(drvNum, KControlIoEnableFatUtilityFunctions); |
302 test(r==KErrNone); |
302 test_KErrNone(r); |
303 |
303 |
304 // load cp932 codepage dll |
304 // load cp932 codepage dll |
305 r = UserSvr::ChangeLocale(KTestLocale); |
305 r = UserSvr::ChangeLocale(KTestLocale); |
306 test(r==KErrNone); |
306 test_KErrNone(r); |
307 |
307 |
308 // create file "\x65B0\x6587\x4EF6", check DOS entry & VFat entry |
308 // create file "\x65B0\x6587\x4EF6", check DOS entry & VFat entry |
309 r = file.Create(TheFs, KTestUnicodeFileName, EFileRead); |
309 r = file.Create(TheFs, KTestUnicodeFileName, EFileRead); |
310 test(r==KErrNone); |
310 test_KErrNone(r); |
311 file.Close(); |
311 file.Close(); |
312 |
312 |
313 r=TheDisk.Open(TheFs,CurrentDrive()); |
313 r=TheDisk.Open(TheFs,CurrentDrive()); |
314 test(r==KErrNone); |
314 test_KErrNone(r); |
315 |
315 |
316 //-- read 1st dir. it should be VFat |
316 //-- read 1st dir. it should be VFat |
317 // const TInt posEntry1=gRootDirStart; //-- dir entry1 position |
317 // const TInt posEntry1=gRootDirStart; //-- dir entry1 position |
318 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
318 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
319 TFatDirEntry fatEntry1; |
319 TFatDirEntry fatEntry1; |
337 test(fatEntry1.iData[13] == CalculateShortNameCheckSum(fatEntry2.Name())); |
337 test(fatEntry1.iData[13] == CalculateShortNameCheckSum(fatEntry2.Name())); |
338 |
338 |
339 // delete file |
339 // delete file |
340 TheDisk.Close(); |
340 TheDisk.Close(); |
341 r = TheFs.Delete(KTestUnicodeFileName); |
341 r = TheFs.Delete(KTestUnicodeFileName); |
342 test(r==KErrNone); |
342 test_KErrNone(r); |
343 |
343 |
344 // turn off FatUtilityFunctions |
344 // turn off FatUtilityFunctions |
345 r = TheFs.ControlIo(drvNum, KControlIoDisableFatUtilityFunctions); |
345 r = TheFs.ControlIo(drvNum, KControlIoDisableFatUtilityFunctions); |
346 test(r==KErrNone); |
346 test_KErrNone(r); |
347 |
347 |
348 #else |
348 #else |
349 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
349 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
350 #endif // _DEBUG) || _DEBUG_RELEASE |
350 #endif // _DEBUG) || _DEBUG_RELEASE |
351 } |
351 } |