36 // |
35 // |
37 { |
36 { |
38 // Create \\gSessionPath\\UIDCHKNO.SHT - no uid, zero length |
37 // Create \\gSessionPath\\UIDCHKNO.SHT - no uid, zero length |
39 RFile file; |
38 RFile file; |
40 TInt r=file.Replace(TheFs,_L("UIDCHKNO.SHT"),EFileRead|EFileWrite); |
39 TInt r=file.Replace(TheFs,_L("UIDCHKNO.SHT"),EFileRead|EFileWrite); |
41 test_KErrNone(r); |
40 test(r==KErrNone); |
42 file.Close(); |
41 file.Close(); |
43 |
42 |
44 // Create \\gSessionPath\\UIDCHKNO.LNG - no uid, long length |
43 // Create \\gSessionPath\\UIDCHKNO.LNG - no uid, long length |
45 r=file.Replace(TheFs,_L("UIDCHKNO.LNG"),EFileRead|EFileWrite); |
44 r=file.Replace(TheFs,_L("UIDCHKNO.LNG"),EFileRead|EFileWrite); |
46 test_KErrNone(r); |
45 test(r==KErrNone); |
47 r=file.Write(_L8("Hello World needs to be over 16 bytes")); |
46 r=file.Write(_L8("Hello World needs to be over 16 bytes")); |
48 file.Close(); |
47 file.Close(); |
49 |
48 |
50 // Create \\gSessionPath\\UIDCHK.BLG - with uid no data |
49 // Create \\gSessionPath\\UIDCHK.BLG - with uid no data |
51 r=file.Replace(TheFs,_L("UIDCHK.BLG"),EFileRead|EFileWrite); |
50 r=file.Replace(TheFs,_L("UIDCHK.BLG"),EFileRead|EFileWrite); |
52 test_KErrNone(r); |
51 test(r==KErrNone); |
53 TUidType uidType(TUid::Uid('U'),TUid::Uid('I'),TUid::Uid('D')); |
52 TUidType uidType(TUid::Uid('U'),TUid::Uid('I'),TUid::Uid('D')); |
54 TCheckedUid checkedUid(uidType); |
53 TCheckedUid checkedUid(uidType); |
55 TPtrC8 buf((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
54 TPtrC8 buf((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
56 r=file.Write(buf); |
55 r=file.Write(buf); |
57 test_KErrNone(r); |
56 test(r==KErrNone); |
58 file.Close(); |
57 file.Close(); |
59 |
58 |
60 // Create \\gSessionPath\\UIDCHK.MSG - with uid and data |
59 // Create \\gSessionPath\\UIDCHK.MSG - with uid and data |
61 r=file.Replace(TheFs,_L("UIDCHK.MSG"),EFileRead|EFileWrite); |
60 r=file.Replace(TheFs,_L("UIDCHK.MSG"),EFileRead|EFileWrite); |
62 test_KErrNone(r); |
61 test(r==KErrNone); |
63 TUidType uidType2(TUid::Uid('X'),TUid::Uid('Y'),TUid::Uid('Z')); |
62 TUidType uidType2(TUid::Uid('X'),TUid::Uid('Y'),TUid::Uid('Z')); |
64 checkedUid.Set(uidType2); |
63 checkedUid.Set(uidType2); |
65 buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
64 buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
66 r=file.Write(buf); |
65 r=file.Write(buf); |
67 test_KErrNone(r); |
66 test(r==KErrNone); |
68 r=file.Write(_L8("More file data")); |
67 r=file.Write(_L8("More file data")); |
69 test_KErrNone(r); |
68 test(r==KErrNone); |
70 file.Close(); |
69 file.Close(); |
71 |
70 |
72 // Create \\gSessionPath\\UIDCHK.DAT - uid stored only in the file |
71 // Create \\gSessionPath\\UIDCHK.DAT - uid stored only in the file |
73 r=file.Replace(TheFs,_L("UIDCHK.DAT"),EFileRead|EFileWrite); |
72 r=file.Replace(TheFs,_L("UIDCHK.DAT"),EFileRead|EFileWrite); |
74 test_KErrNone(r); |
73 test(r==KErrNone); |
75 TUidType uidType3(TUid::Uid('D'),TUid::Uid('A'),TUid::Uid('T')); |
74 TUidType uidType3(TUid::Uid('D'),TUid::Uid('A'),TUid::Uid('T')); |
76 checkedUid.Set(uidType3); |
75 checkedUid.Set(uidType3); |
77 buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
76 buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
78 r=file.Write(buf); |
77 r=file.Write(buf); |
79 test_KErrNone(r); |
78 test(r==KErrNone); |
80 r=file.Write(_L8("More file data")); |
79 r=file.Write(_L8("More file data")); |
81 test_KErrNone(r); |
80 test(r==KErrNone); |
82 file.Close(); |
81 file.Close(); |
83 |
82 |
84 // Create \\gSessionPath\\UIDCHK.PE - uid stored in WINS PE file header |
83 // Create \\gSessionPath\\UIDCHK.PE - uid stored in WINS PE file header |
85 r=file.Replace(TheFs,_L("UIDWINS.PE"),EFileRead|EFileWrite); |
84 r=file.Replace(TheFs,_L("UIDWINS.PE"),EFileRead|EFileWrite); |
86 test_KErrNone(r); |
85 test(r==KErrNone); |
87 |
86 |
88 #if defined(__WINS__) |
87 #if defined(__WINS__) |
89 if (!IsTestingLFFS()) |
88 if (!IsTestingLFFS()) |
90 { |
89 { |
91 RFile fileSource; |
90 RFile fileSource; |
92 r=fileSource.Open(TheFs,_L("Z:\\TEST\\T_CHKUID.EXE"),EFileShareReadersOnly|EFileRead); |
91 r=fileSource.Open(TheFs,_L("Z:\\TEST\\T_CHKUID.EXE"),EFileShareReadersOnly|EFileRead); |
93 test_KErrNone(r); |
92 test(r==KErrNone); |
94 |
93 |
95 TBuf8<0x100> buffer; |
94 TBuf8<0x100> buffer; |
96 do |
95 do |
97 { |
96 { |
98 r=fileSource.Read(buffer); |
97 r=fileSource.Read(buffer); |
99 test_KErrNone(r); |
98 test(r==KErrNone); |
100 r=file.Write(buffer); |
99 r=file.Write(buffer); |
101 test_KErrNone(r); |
100 test(r==KErrNone); |
102 } |
101 } |
103 while (buffer.Length()==buffer.MaxLength()); |
102 while (buffer.Length()==buffer.MaxLength()); |
104 |
103 |
105 fileSource.Close(); |
104 fileSource.Close(); |
106 } |
105 } |
107 else |
106 else |
108 { |
107 { |
109 r=file.Write(_L8("Some zany stuff here!")); |
108 r=file.Write(_L8("Some zany stuff here!")); |
110 test_KErrNone(r); |
109 test(r==KErrNone); |
111 } |
110 } |
112 #else |
111 #else |
113 r=file.Write(_L8("Some zany stuff here!")); |
112 r=file.Write(_L8("Some zany stuff here!")); |
114 test_KErrNone(r); |
113 test(r==KErrNone); |
115 #endif |
114 #endif |
116 file.Close(); |
115 file.Close(); |
117 } |
116 } |
118 |
117 |
119 LOCAL_C void Test1() |
118 LOCAL_C void Test1() |
218 { |
217 { |
219 |
218 |
220 test.Next(_L("Use RFs::EntryL() to check files")); |
219 test.Next(_L("Use RFs::EntryL() to check files")); |
221 TEntry entry; |
220 TEntry entry; |
222 TInt r=TheFs.Entry(_L("UIDCHKNO.SHT"),entry); |
221 TInt r=TheFs.Entry(_L("UIDCHKNO.SHT"),entry); |
223 test_KErrNone(r); |
222 test(r==KErrNone); |
224 test(entry.iName==_L("UIDCHKNO.SHT")); |
223 test(entry.iName==_L("UIDCHKNO.SHT")); |
225 test(entry.IsTypeValid()==EFalse); |
224 test(entry.IsTypeValid()==EFalse); |
226 |
225 |
227 r=TheFs.Entry(_L("UIDCHKNO.LNG"),entry); |
226 r=TheFs.Entry(_L("UIDCHKNO.LNG"),entry); |
228 test_KErrNone(r); |
227 test(r==KErrNone); |
229 test(entry.iName==_L("UIDCHKNO.LNG")); |
228 test(entry.iName==_L("UIDCHKNO.LNG")); |
230 test(entry.IsTypeValid()==EFalse); |
229 test(entry.IsTypeValid()==EFalse); |
231 |
230 |
232 r=TheFs.Entry(_L("UIDCHK.MSG"),entry); |
231 r=TheFs.Entry(_L("UIDCHK.MSG"),entry); |
233 test_KErrNone(r); |
232 test(r==KErrNone); |
234 test(entry.iName==_L("UIDCHK.MSG")); |
233 test(entry.iName==_L("UIDCHK.MSG")); |
235 test(entry.IsTypeValid()); |
234 test(entry.IsTypeValid()); |
236 test(entry.iType[0]==TUid::Uid('X') && entry.iType[1]==TUid::Uid('Y') && entry.iType[2]==TUid::Uid('Z')); |
235 test(entry.iType[0]==TUid::Uid('X') && entry.iType[1]==TUid::Uid('Y') && entry.iType[2]==TUid::Uid('Z')); |
237 |
236 |
238 r=TheFs.Entry(_L("UIDCHK.BLG"),entry); |
237 r=TheFs.Entry(_L("UIDCHK.BLG"),entry); |
239 test_KErrNone(r); |
238 test(r==KErrNone); |
240 test(entry.iName==_L("UIDCHK.BLG")); |
239 test(entry.iName==_L("UIDCHK.BLG")); |
241 test(entry.IsTypeValid()); |
240 test(entry.IsTypeValid()); |
242 test(entry.iType[0]==TUid::Uid('U') && entry.iType[1]==TUid::Uid('I') && entry.iType[2]==TUid::Uid('D')); |
241 test(entry.iType[0]==TUid::Uid('U') && entry.iType[1]==TUid::Uid('I') && entry.iType[2]==TUid::Uid('D')); |
243 |
242 |
244 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
243 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
245 test_KErrNone(r); |
244 test(r==KErrNone); |
246 test(entry.iName==_L("UIDCHK.DAT")); |
245 test(entry.iName==_L("UIDCHK.DAT")); |
247 test(entry.IsTypeValid()); |
246 test(entry.IsTypeValid()); |
248 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
247 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
249 |
248 |
250 r=TheFs.Entry(_L("UIDWINS.PE"),entry); |
249 r=TheFs.Entry(_L("UIDWINS.PE"),entry); |
251 test_KErrNone(r); |
250 test(r==KErrNone); |
252 test(entry.iName==_L("UIDWINS.PE")); |
251 test(entry.iName==_L("UIDWINS.PE")); |
253 #if defined(__WINS__) |
252 #if defined(__WINS__) |
254 TFileName sessionPath; |
253 TFileName sessionPath; |
255 TheFs.SessionPath(sessionPath); |
254 TheFs.SessionPath(sessionPath); |
256 if (sessionPath[0]!='C') |
255 if (sessionPath[0]!='C') |
277 |
276 |
278 test.Next(_L("Uids can be read if the file is open")); |
277 test.Next(_L("Uids can be read if the file is open")); |
279 RFile f; |
278 RFile f; |
280 TEntry entry; |
279 TEntry entry; |
281 TInt r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareExclusive|EFileRead); |
280 TInt r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareExclusive|EFileRead); |
282 test_KErrNone(r); |
281 test(r==KErrNone); |
283 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
282 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
284 test_KErrNone(r); |
283 test(r==KErrNone); |
285 test(entry.iName==_L("UIDCHK.DAT")); |
284 test(entry.iName==_L("UIDCHK.DAT")); |
286 test(entry.IsTypeValid()); |
285 test(entry.IsTypeValid()); |
287 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
286 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
288 f.Close(); |
287 f.Close(); |
289 |
288 |
290 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareExclusive|EFileWrite); |
289 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareExclusive|EFileWrite); |
291 test_KErrNone(r); |
290 test(r==KErrNone); |
292 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
291 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
293 test_KErrNone(r); |
292 test(r==KErrNone); |
294 test(entry.iName==_L("UIDCHK.DAT")); |
293 test(entry.iName==_L("UIDCHK.DAT")); |
295 test(entry.IsTypeValid()); |
294 test(entry.IsTypeValid()); |
296 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
295 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
297 |
296 |
298 r=f.SetSize(256); |
297 r=f.SetSize(256); |
299 test_KErrNone(r); |
298 test(r==KErrNone); |
300 TBuf8<16> des; |
299 TBuf8<16> des; |
301 r=TheFs.ReadFileSection(_L("UIDCHK.DAT"),0,des,16); |
300 r=TheFs.ReadFileSection(_L("UIDCHK.DAT"),0,des,16); |
302 test_KErrNone(r); |
301 test(r==KErrNone); |
303 |
302 |
304 f.Close(); |
303 f.Close(); |
305 |
304 |
306 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareReadersOnly|EFileRead); |
305 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareReadersOnly|EFileRead); |
307 test_KErrNone(r); |
306 test(r==KErrNone); |
308 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
307 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
309 test_KErrNone(r); |
308 test(r==KErrNone); |
310 test(entry.iName==_L("UIDCHK.DAT")); |
309 test(entry.iName==_L("UIDCHK.DAT")); |
311 test(entry.IsTypeValid()); |
310 test(entry.IsTypeValid()); |
312 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
311 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
313 f.Close(); |
312 f.Close(); |
314 |
313 |
315 // EFileShareReadersOnly|EFileWrite is illegal |
314 // EFileShareReadersOnly|EFileWrite is illegal |
316 |
315 |
317 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileRead); |
316 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileRead); |
318 test_KErrNone(r); |
317 test(r==KErrNone); |
319 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
318 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
320 test_KErrNone(r); |
319 test(r==KErrNone); |
321 test(entry.iName==_L("UIDCHK.DAT")); |
320 test(entry.iName==_L("UIDCHK.DAT")); |
322 test(entry.IsTypeValid()); |
321 test(entry.IsTypeValid()); |
323 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
322 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
324 f.Close(); |
323 f.Close(); |
325 |
324 |
326 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileWrite); |
325 r=f.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileWrite); |
327 test_KErrNone(r); |
326 test(r==KErrNone); |
328 |
327 |
329 RFile secondFile; |
328 RFile secondFile; |
330 r=secondFile.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileWrite); |
329 r=secondFile.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileWrite); |
331 test_KErrNone(r); |
330 test(r==KErrNone); |
332 |
331 |
333 RFile thirdFile; |
332 RFile thirdFile; |
334 r=thirdFile.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileRead); |
333 r=thirdFile.Open(TheFs,_L("UIDCHK.DAT"),EFileShareAny|EFileRead); |
335 test_KErrNone(r); |
334 test(r==KErrNone); |
336 |
335 |
337 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
336 r=TheFs.Entry(_L("UIDCHK.DAT"),entry); |
338 test_KErrNone(r); |
337 test(r==KErrNone); |
339 test(entry.iName==_L("UIDCHK.DAT")); |
338 test(entry.iName==_L("UIDCHK.DAT")); |
340 test(entry.IsTypeValid()); |
339 test(entry.IsTypeValid()); |
341 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
340 test(entry.iType[0]==TUid::Uid('D') && entry.iType[1]==TUid::Uid('A') && entry.iType[2]==TUid::Uid('T')); |
342 f.Close(); |
341 f.Close(); |
343 secondFile.Close(); |
342 secondFile.Close(); |
344 thirdFile.Close(); |
343 thirdFile.Close(); |
345 |
344 |
346 r=f.Open(TheFs,_L("UIDWINS.PE"),EFileShareAny|EFileWrite); |
345 r=f.Open(TheFs,_L("UIDWINS.PE"),EFileShareAny|EFileWrite); |
347 test_KErrNone(r); |
346 test(r==KErrNone); |
348 |
347 |
349 r=TheFs.Entry(_L("UIDWINS.PE"),entry); |
348 r=TheFs.Entry(_L("UIDWINS.PE"),entry); |
350 test_KErrNone(r); |
349 test(r==KErrNone); |
351 test(entry.iName==_L("UIDWINS.PE")); |
350 test(entry.iName==_L("UIDWINS.PE")); |
352 #if defined(__WINS__) |
351 #if defined(__WINS__) |
353 TFileName sessionPath; |
352 TFileName sessionPath; |
354 TheFs.SessionPath(sessionPath); |
353 TheFs.SessionPath(sessionPath); |
355 if (sessionPath[0]!='C') |
354 if (sessionPath[0]!='C') |