319 pos-= KSegmentSize; |
319 pos-= KSegmentSize; |
320 writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen)); |
320 writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen)); |
321 |
321 |
322 test.Printf(_L("Writing to file...")); |
322 test.Printf(_L("Writing to file...")); |
323 |
323 |
324 r = f.Write(pos, writePtr); |
324 // now we have gobbled all or most of memory, the next write can fail |
325 test_KErrNone(r); |
325 // if it does keep decommitting memory until it succeeds and then test that the file size is correct |
|
326 commitEnd = 0; |
|
327 do { |
|
328 |
|
329 r = f.Write(pos, writePtr); |
|
330 test_Value(r, r == KErrNoMemory || r == KErrNone); |
|
331 if (r == KErrNoMemory) |
|
332 { |
|
333 chunk.Decommit(commitEnd,KPageSize); |
|
334 commitEnd += KPageSize; |
|
335 } |
|
336 } |
|
337 while (r == KErrNoMemory); |
|
338 |
326 pos+= writePtr.Length(); |
339 pos+= writePtr.Length(); |
327 |
340 |
328 test.Printf(_L("Setting size of file ...")); |
341 test.Printf(_L("Gsetting size of file ...")); |
329 r = f.Size(fileSize); |
342 r = f.Size(fileSize); |
330 test_KErrNone(r); |
343 test_KErrNone(r); |
331 test_Equal(fileSize,pos); |
344 test_Equal(fileSize,pos); |
332 |
345 |
333 test.Printf(_L("Closing file ...")); |
346 test.Printf(_L("Closing file ...")); |
545 test.Printf(_L("Flushing close queue to empty cache...\n")); |
558 test.Printf(_L("Flushing close queue to empty cache...\n")); |
546 r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles); |
559 r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles); |
547 test_KErrNone(r); |
560 test_KErrNone(r); |
548 |
561 |
549 r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered); |
562 r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered); |
|
563 test_KErrNone(r); |
|
564 |
|
565 r = f.SetSize(gFileCacheConfig.iCacheSize); |
550 test_KErrNone(r); |
566 test_KErrNone(r); |
551 |
567 |
552 RTimer timer; |
568 RTimer timer; |
553 timer.CreateLocal(); |
569 timer.CreateLocal(); |
554 TRequestStatus reqStat; |
570 TRequestStatus reqStat; |