43 |
44 |
44 TBuf<32> goodName=_L("\\GOODNAME.TXT"); |
45 TBuf<32> goodName=_L("\\GOODNAME.TXT"); |
45 TBuf<32> badName=_L("\\< > : \" / |"); |
46 TBuf<32> badName=_L("\\< > : \" / |"); |
46 TParse parser; |
47 TParse parser; |
47 TInt r=parser.Set(aName,NULL,NULL); |
48 TInt r=parser.Set(aName,NULL,NULL); |
48 test(r==KErrNone || r==anError); |
49 test_Value(r, r == KErrNone || r==anError); |
49 goodName.Insert(0,parser.Drive()); |
50 goodName.Insert(0,parser.Drive()); |
50 badName.Insert(0,parser.Drive()); |
51 badName.Insert(0,parser.Drive()); |
51 |
52 |
52 |
53 |
53 TBuf<KMaxFileName> name; // We need an 8-bit name to test RFs::GetLongName() in |
54 TBuf<KMaxFileName> name; // We need an 8-bit name to test RFs::GetLongName() in |
165 TPtrC dirName(_L("c:\\mainTestDir\\test000\\1a34567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890\\")); |
166 TPtrC dirName(_L("c:\\mainTestDir\\test000\\1a34567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890\\")); |
166 |
167 |
167 //-- TParse shall work correctly |
168 //-- TParse shall work correctly |
168 TParse parse; |
169 TParse parse; |
169 TInt err = parse.Set(dirName,NULL,NULL); |
170 TInt err = parse.Set(dirName,NULL,NULL); |
170 test( err == KErrNone ); |
171 test_KErrNone(err); |
171 |
172 |
172 //-- try to access a directory with a long name. This just shall not panic. |
173 //-- try to access a directory with a long name. This just shall not panic. |
173 //-- The return code can be any, on the emulator it's very likely to be KErrBadname |
174 //-- The return code can be any, on the emulator it's very likely to be KErrBadname |
174 err = rDir.Open(rfs,dirName,EFileStream|EFileWrite|EFileShareExclusive); |
175 err = rDir.Open(rfs,dirName,EFileStream|EFileWrite|EFileShareExclusive); |
175 |
176 |
189 test(rfs.Connect() == KErrNone); |
190 test(rfs.Connect() == KErrNone); |
190 |
191 |
191 //-- create a dir c:\a |
192 //-- create a dir c:\a |
192 _LIT(dirName, "C:\\a\\"); |
193 _LIT(dirName, "C:\\a\\"); |
193 TInt err = rfs.MkDir(dirName); |
194 TInt err = rfs.MkDir(dirName); |
194 test(err == KErrNone || err == KErrAlreadyExists); |
195 test_Value(err, err == KErrNone || err == KErrAlreadyExists); |
195 |
196 |
196 if(err == KErrAlreadyExists) |
197 if(err == KErrAlreadyExists) |
197 bDirExisted = ETrue; |
198 bDirExisted = ETrue; |
198 |
199 |
199 //-- dir name longer than KMaxFileName |
200 //-- dir name longer than KMaxFileName |
200 _LIT(longDirName, "C:\\a\\longnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongname\\"); |
201 _LIT(longDirName, "C:\\a\\longnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongname\\"); |
201 //TInt nLen = dirName().Length(); |
202 //TInt nLen = dirName().Length(); |
202 |
203 |
203 //-- try to create a directory with a very long name, checking that it doesn't get truncated to the "c:\a" |
204 //-- try to create a directory with a very long name, checking that it doesn't get truncated to the "c:\a" |
204 err = rfs.MkDir(longDirName); |
205 err = rfs.MkDir(longDirName); |
205 test(err == KErrBadName); |
206 test_Value(err, err == KErrBadName); |
206 |
207 |
207 //-- clean up, remove created directory, otherwise some ill-designed tests can fail |
208 //-- clean up, remove created directory, otherwise some ill-designed tests can fail |
208 if(!bDirExisted) |
209 if(!bDirExisted) |
209 rfs.RmDir(dirName); |
210 rfs.RmDir(dirName); |
210 |
211 |