196 |
196 |
197 // ************************************************************************* |
197 // ************************************************************************* |
198 // First test with a non DOS compatible name renamed to a DOS compatible name |
198 // First test with a non DOS compatible name renamed to a DOS compatible name |
199 test.Next(_L("Rename test to TEST and replace temp with TEST")); |
199 test.Next(_L("Rename test to TEST and replace temp with TEST")); |
200 r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite); |
200 r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite); |
201 test(r==KErrNone); |
201 test_KErrNone(r); |
202 r=file.Write(BeckPtr); |
202 r=file.Write(BeckPtr); |
203 test(r==KErrNone); |
203 test_KErrNone(r); |
204 file.Close(); |
204 file.Close(); |
205 |
205 |
206 r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST")); |
206 r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST")); |
207 test(r==KErrNone); |
207 test_KErrNone(r); |
208 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
208 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
209 test(r==KErrNone); |
209 test_KErrNone(r); |
210 r=file.Write(alphaPtr); |
210 r=file.Write(alphaPtr); |
211 test(r==KErrNone); |
211 test_KErrNone(r); |
212 file.Close(); |
212 file.Close(); |
213 |
213 |
214 // Replace(oldName, newName) |
214 // Replace(oldName, newName) |
215 // Copy oldName to newName (ie temp to TEST) |
215 // Copy oldName to newName (ie temp to TEST) |
216 // If TEST does not exist, it is created and then temp's attributes etc are copied into it |
216 // If TEST does not exist, it is created and then temp's attributes etc are copied into it |
217 // then temp is deleted. If it does exist, it must be closed |
217 // then temp is deleted. If it does exist, it must be closed |
218 // The bug created a second file of the same name |
218 // The bug created a second file of the same name |
219 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST")); |
219 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST")); |
220 test(r==KErrNone); |
220 test_KErrNone(r); |
221 |
221 |
222 // Check that there's only one file named TEST |
222 // Check that there's only one file named TEST |
223 TInt fileCount=0; |
223 TInt fileCount=0; |
224 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
224 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
225 test(fileCount==1); |
225 test(fileCount==1); |
226 r=TheFs.Delete(_L("\\F32-TST\\TEST")); |
226 r=TheFs.Delete(_L("\\F32-TST\\TEST")); |
227 test(r==KErrNone); |
227 test_KErrNone(r); |
228 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
228 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
229 test(fileCount==0); |
229 test(fileCount==0); |
230 test(r==KErrNone); |
230 test_KErrNone(r); |
231 |
231 |
232 |
232 |
233 //***************************************************** |
233 //***************************************************** |
234 // The same test but with different source directories |
234 // The same test but with different source directories |
235 test.Next(_L("Rename test to and replace \\SYSTEM\\temp with TEST")); |
235 test.Next(_L("Rename test to and replace \\SYSTEM\\temp with TEST")); |
236 r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite); |
236 r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite); |
237 test(r==KErrNone); |
237 test_KErrNone(r); |
238 r=file.Write(BeckPtr); |
238 r=file.Write(BeckPtr); |
239 test(r==KErrNone); |
239 test_KErrNone(r); |
240 file.Close(); |
240 file.Close(); |
241 |
241 |
242 r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST")); |
242 r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST")); |
243 test(r==KErrNone); |
243 test_KErrNone(r); |
244 r=file.Replace(TheFs,_L("\\F32-TST\\SYSTEM\\temp"),EFileWrite); |
244 r=file.Replace(TheFs,_L("\\F32-TST\\SYSTEM\\temp"),EFileWrite); |
245 test(r==KErrNone); |
245 test_KErrNone(r); |
246 r=file.Write(alphaPtr); |
246 r=file.Write(alphaPtr); |
247 test(r==KErrNone); |
247 test_KErrNone(r); |
248 file.Close(); |
248 file.Close(); |
249 |
249 |
250 // The bug created a second file of the same name |
250 // The bug created a second file of the same name |
251 r=TheFs.Replace(_L("\\F32-TST\\SYSTEM\\temp"),_L("\\F32-TST\\TEST")); |
251 r=TheFs.Replace(_L("\\F32-TST\\SYSTEM\\temp"),_L("\\F32-TST\\TEST")); |
252 test(r==KErrNone); |
252 test_KErrNone(r); |
253 |
253 |
254 fileCount=0; |
254 fileCount=0; |
255 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
255 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
256 test(fileCount==1); |
256 test(fileCount==1); |
257 r=TheFs.Delete(_L("\\F32-TST\\TEST")); |
257 r=TheFs.Delete(_L("\\F32-TST\\TEST")); |
258 test(r==KErrNone); |
258 test_KErrNone(r); |
259 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
259 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST")); |
260 test(fileCount==0); |
260 test(fileCount==0); |
261 // Test that system directory is now empty |
261 // Test that system directory is now empty |
262 fileCount=0; |
262 fileCount=0; |
263 fileCount=CountFiles(_L("\\F32-TST\\SYSTEM\\"),_L("temp")); |
263 fileCount=CountFiles(_L("\\F32-TST\\SYSTEM\\"),_L("temp")); |
264 test(fileCount==0); |
264 test(fileCount==0); |
265 test(r==KErrNone); |
265 test_KErrNone(r); |
266 |
266 |
267 // ************************************************************************* |
267 // ************************************************************************* |
268 // Test with a DOS compatible name renamed to a different DOS compatible name |
268 // Test with a DOS compatible name renamed to a different DOS compatible name |
269 test.Next(_L("Rename little to BIG and replace temp with BIG")); |
269 test.Next(_L("Rename little to BIG and replace temp with BIG")); |
270 r=file.Replace(TheFs,_L("\\F32-TST\\little"),EFileWrite); |
270 r=file.Replace(TheFs,_L("\\F32-TST\\little"),EFileWrite); |
271 test(r==KErrNone); |
271 test_KErrNone(r); |
272 r=file.Write(BeckPtr); |
272 r=file.Write(BeckPtr); |
273 test(r==KErrNone); |
273 test_KErrNone(r); |
274 file.Close(); |
274 file.Close(); |
275 |
275 |
276 // Test a long path (>250 chrs) |
276 // Test a long path (>250 chrs) |
277 r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\0495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\middle.gif")); |
277 r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\0495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\middle.gif")); |
278 test(r==KErrBadName); |
278 test_Value(r, r == KErrBadName); |
279 |
279 |
280 r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\BIG")); |
280 r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\BIG")); |
281 test(r==KErrNone); |
281 test_KErrNone(r); |
282 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
282 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
283 test(r==KErrNone); |
283 test_KErrNone(r); |
284 r=file.Write(alphaPtr); |
284 r=file.Write(alphaPtr); |
285 test(r==KErrNone); |
285 test_KErrNone(r); |
286 file.Close(); |
286 file.Close(); |
287 |
287 |
288 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\BIG")); |
288 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\BIG")); |
289 test(r==KErrNone); |
289 test_KErrNone(r); |
290 |
290 |
291 fileCount=0; |
291 fileCount=0; |
292 fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG")); |
292 fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG")); |
293 test(fileCount==1); |
293 test(fileCount==1); |
294 r=TheFs.Delete(_L("\\F32-TST\\BIG")); |
294 r=TheFs.Delete(_L("\\F32-TST\\BIG")); |
295 test(r==KErrNone); |
295 test_KErrNone(r); |
296 fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG")); |
296 fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG")); |
297 test(fileCount==0); |
297 test(fileCount==0); |
298 test(r==KErrNone); |
298 test_KErrNone(r); |
299 |
299 |
300 // *********************************** |
300 // *********************************** |
301 // Test with a non-DOS compatible name |
301 // Test with a non-DOS compatible name |
302 test.Next(_L("Rename veryLongFileName to VERYLONGFILENAME")); |
302 test.Next(_L("Rename veryLongFileName to VERYLONGFILENAME")); |
303 r=file.Replace(TheFs,_L("\\F32-TST\\veryLongFileName"),EFileWrite); |
303 r=file.Replace(TheFs,_L("\\F32-TST\\veryLongFileName"),EFileWrite); |
304 test(r==KErrNone); |
304 test_KErrNone(r); |
305 r=file.Write(BeckPtr); |
305 r=file.Write(BeckPtr); |
306 test(r==KErrNone); |
306 test_KErrNone(r); |
307 file.Close(); |
307 file.Close(); |
308 |
308 |
309 r=TheFs.Rename(_L("\\F32-TST\\veryLongFileName"),_L("\\F32-TST\\VERYLONGFILENAME")); |
309 r=TheFs.Rename(_L("\\F32-TST\\veryLongFileName"),_L("\\F32-TST\\VERYLONGFILENAME")); |
310 test(r==KErrNone); |
310 test_KErrNone(r); |
311 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
311 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
312 test(r==KErrNone); |
312 test_KErrNone(r); |
313 r=file.Write(alphaPtr); |
313 r=file.Write(alphaPtr); |
314 test(r==KErrNone); |
314 test_KErrNone(r); |
315 file.Close(); |
315 file.Close(); |
316 |
316 |
317 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\VERYLONGFILENAME")); |
317 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\VERYLONGFILENAME")); |
318 test(r==KErrNone); |
318 test_KErrNone(r); |
319 |
319 |
320 fileCount=0; |
320 fileCount=0; |
321 fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME")); |
321 fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME")); |
322 test(fileCount==1); |
322 test(fileCount==1); |
323 r=TheFs.Delete(_L("\\F32-TST\\VERYLONGFILENAME")); |
323 r=TheFs.Delete(_L("\\F32-TST\\VERYLONGFILENAME")); |
324 test(r==KErrNone); |
324 test_KErrNone(r); |
325 fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME")); |
325 fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME")); |
326 test(fileCount==0); |
326 test(fileCount==0); |
327 test(r==KErrNone); |
327 test_KErrNone(r); |
328 |
328 |
329 // ******************************* |
329 // ******************************* |
330 // Test with a DOS compatible name |
330 // Test with a DOS compatible name |
331 test.Next(_L("Rename FILE to FILE and replace temp with FILE")); |
331 test.Next(_L("Rename FILE to FILE and replace temp with FILE")); |
332 r=file.Replace(TheFs,_L("\\F32-TST\\FILE"),EFileWrite); |
332 r=file.Replace(TheFs,_L("\\F32-TST\\FILE"),EFileWrite); |
333 test(r==KErrNone); |
333 test_KErrNone(r); |
334 r=file.Write(BeckPtr); |
334 r=file.Write(BeckPtr); |
335 test(r==KErrNone); |
335 test_KErrNone(r); |
336 file.Close(); |
336 file.Close(); |
337 |
337 |
338 r=TheFs.Rename(_L("\\F32-TST\\FILE"),_L("\\F32-TST\\FILE")); |
338 r=TheFs.Rename(_L("\\F32-TST\\FILE"),_L("\\F32-TST\\FILE")); |
339 test(r==KErrNone); |
339 test_KErrNone(r); |
340 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
340 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
341 test(r==KErrNone); |
341 test_KErrNone(r); |
342 r=file.Write(alphaPtr); |
342 r=file.Write(alphaPtr); |
343 test(r==KErrNone); |
343 test_KErrNone(r); |
344 file.Close(); |
344 file.Close(); |
345 |
345 |
346 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\FILE")); |
346 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\FILE")); |
347 test(r==KErrNone); |
347 test_KErrNone(r); |
348 |
348 |
349 fileCount=0; |
349 fileCount=0; |
350 fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE")); |
350 fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE")); |
351 test(fileCount==1); |
351 test(fileCount==1); |
352 r=TheFs.Delete(_L("\\F32-TST\\FILE")); |
352 r=TheFs.Delete(_L("\\F32-TST\\FILE")); |
353 test(r==KErrNone); |
353 test_KErrNone(r); |
354 fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE")); |
354 fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE")); |
355 test(fileCount==0); |
355 test(fileCount==0); |
356 test(r==KErrNone); |
356 test_KErrNone(r); |
357 |
357 |
358 // ************************************************** |
358 // ************************************************** |
359 // Test with a DOS compatible name which is kept open |
359 // Test with a DOS compatible name which is kept open |
360 test.Next(_L("Rename test1 to TEST1 and replace temp1 with TEST1 while it's open")); |
360 test.Next(_L("Rename test1 to TEST1 and replace temp1 with TEST1 while it's open")); |
361 r=file.Replace(TheFs,_L("\\F32-TST\\test1"),EFileWrite); |
361 r=file.Replace(TheFs,_L("\\F32-TST\\test1"),EFileWrite); |
362 test(r==KErrNone); |
362 test_KErrNone(r); |
363 r=file.Write(BeckPtr); |
363 r=file.Write(BeckPtr); |
364 test(r==KErrNone); |
364 test_KErrNone(r); |
365 file.Close(); |
365 file.Close(); |
366 |
366 |
367 r=TheFs.Rename(_L("\\F32-TST\\test1"),_L("\\F32-TST\\TEST1")); |
367 r=TheFs.Rename(_L("\\F32-TST\\test1"),_L("\\F32-TST\\TEST1")); |
368 test(r==KErrNone); |
368 test_KErrNone(r); |
369 |
369 |
370 // Try with the file open |
370 // Try with the file open |
371 RFile openFile; |
371 RFile openFile; |
372 r=openFile.Open(TheFs,_L("\\F32-TST\\TEST1"),EFileRead|EFileWrite); |
372 r=openFile.Open(TheFs,_L("\\F32-TST\\TEST1"),EFileRead|EFileWrite); |
373 test(r==KErrNone); |
373 test_KErrNone(r); |
374 |
374 |
375 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
375 r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite); |
376 test(r==KErrNone); |
376 test_KErrNone(r); |
377 r=file.Write(alphaPtr); |
377 r=file.Write(alphaPtr); |
378 test(r==KErrNone); |
378 test_KErrNone(r); |
379 file.Close(); |
379 file.Close(); |
380 |
380 |
381 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1")); |
381 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1")); |
382 test(r==KErrInUse); // Fails as it should! But not intuitive bearing in mind the other bug... |
382 test_Value(r, r == KErrInUse); // Fails as it should! But not intuitive bearing in mind the other bug... |
383 |
383 |
384 openFile.Close(); |
384 openFile.Close(); |
385 |
385 |
386 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1")); |
386 r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1")); |
387 test(r==KErrNone); |
387 test_KErrNone(r); |
388 |
388 |
389 fileCount=0; |
389 fileCount=0; |
390 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
390 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
391 test(fileCount==1); |
391 test(fileCount==1); |
392 r=TheFs.Delete(_L("\\F32-TST\\TEST1")); |
392 r=TheFs.Delete(_L("\\F32-TST\\TEST1")); |
393 test(r==KErrNone); |
393 test_KErrNone(r); |
394 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
394 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
395 test(fileCount==0); |
395 test(fileCount==0); |
396 test(r==KErrNone); |
396 test_KErrNone(r); |
397 |
397 |
398 } |
398 } |
399 |
399 |
400 |
400 |
401 //------------------------------------------------------------------- |
401 //------------------------------------------------------------------- |