253 TInt64 memoryCriticalSpace(0); |
253 TInt64 memoryCriticalSpace(0); |
254 TRAP(err, memoryCriticalSpace = FindCriticalLevelTresholdL()); |
254 TRAP(err, memoryCriticalSpace = FindCriticalLevelTresholdL()); |
255 if (!err) |
255 if (!err) |
256 return err; |
256 return err; |
257 TInt64 memoryWarningSpace(0); |
257 TInt64 memoryWarningSpace(0); |
258 TRAP(err, memoryWarningSpace = FindWarningLevelTresholdL( aNumber )); |
258 TRAP(err, memoryWarningSpace = FindWarningLevelTresholdL()); |
259 if (!err) |
259 if (!err) |
260 return err; |
260 return err; |
261 |
261 |
262 DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryCriticalSpace = %d", (TInt) memoryCriticalSpace ); |
262 DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryCriticalSpace = %d", (TInt) memoryCriticalSpace ); |
263 DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryWarningSpace = %d", (TInt) memoryWarningSpace ); |
263 DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryWarningSpace = %d", (TInt) memoryWarningSpace ); |
264 |
264 |
265 //create the number of files needed to fill the mmc or phone memory free space |
265 //create the number of files needed to fill the mmc free space |
266 while( freeSpace ) |
266 while( freeSpace ) |
267 { |
267 { |
268 TInt64 newMemoryWarningSpace(0); |
268 /* The real warning space is a percentage of the free space */ |
269 if( aNumber == EDriveC ) |
269 TInt64 newMemoryWarningSpace = ( TInt64 ) ( volumeInfo.iSize*( 100 - memoryWarningSpace ) ) / 100; |
270 { |
|
271 // The real warning space is a percentage of the free space. This applies only on drive C. |
|
272 newMemoryWarningSpace = ( TInt64 ) ( volumeInfo.iSize*( 100 - memoryWarningSpace ) ) / 100; |
|
273 } |
|
274 |
|
275 DFLOG2( "CDevEncDiskUtils::DiskFinalize => newMemoryWarningSpace = %d", (TInt) newMemoryWarningSpace ); |
270 DFLOG2( "CDevEncDiskUtils::DiskFinalize => newMemoryWarningSpace = %d", (TInt) newMemoryWarningSpace ); |
276 |
271 |
277 if( TInt64( volumeInfo.iFree ) > TInt64( KMaxInt ) ) |
272 if( TInt64( volumeInfo.iFree ) > TInt64( KMaxInt ) ) |
278 { |
273 { |
279 size = KMaxInt; |
274 size = KMaxInt; |
280 } |
275 } |
281 else |
276 else |
282 { |
277 { |
283 if( aNumber == EDriveC ) |
278 size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - newMemoryWarningSpace ); |
284 { |
|
285 size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - newMemoryWarningSpace ); |
|
286 } |
|
287 else |
|
288 { |
|
289 size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - memoryWarningSpace ); |
|
290 } |
|
291 } |
279 } |
292 |
280 |
293 TFileName temp; |
281 TFileName temp; |
294 RFile file; |
282 RFile file; |
295 |
283 |
312 |
300 |
313 err = fs.Volume( volumeInfo, aNumber ); |
301 err = fs.Volume( volumeInfo, aNumber ); |
314 if( err ) |
302 if( err ) |
315 DFLOG2( "..fs.Volume fail %d", err ); |
303 DFLOG2( "..fs.Volume fail %d", err ); |
316 |
304 |
317 if( aNumber == EDriveC ) |
305 if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + newMemoryWarningSpace ) |
318 { |
306 { |
319 if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + newMemoryWarningSpace ) |
307 freeSpace = EFalse; |
320 { |
|
321 freeSpace = EFalse; |
|
322 } |
|
323 } |
|
324 else |
|
325 { |
|
326 if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + memoryWarningSpace ) |
|
327 { |
|
328 freeSpace = EFalse; |
|
329 } |
|
330 } |
308 } |
331 } |
309 } |
332 |
310 |
333 //delete the created files |
311 //delete the created files |
334 for( TInt i=0;i < files.Count();i++ ) |
312 for( TInt i=0;i < files.Count();i++ ) |
368 |
346 |
369 // -------------------------------------------------------------------------- |
347 // -------------------------------------------------------------------------- |
370 // CDevEncDiskUtils::FindWarningLevelTresholdL() |
348 // CDevEncDiskUtils::FindWarningLevelTresholdL() |
371 // |
349 // |
372 // -------------------------------------------------------------------------- |
350 // -------------------------------------------------------------------------- |
373 TInt64 CDevEncDiskUtils::FindWarningLevelTresholdL( const TDriveNumber aNumber ) |
351 TInt64 CDevEncDiskUtils::FindWarningLevelTresholdL() |
374 { |
352 { |
375 if( aNumber == EDriveC ) |
353 return (TInt64) FindValueL( KCRUidUiklaf, /*KUikOODDiskWarningThreshold*/KUikOODDiskFreeSpaceWarningNoteLevel ); |
376 { |
|
377 return (TInt64) FindValueL( KCRUidUiklaf, KUikOODDiskFreeSpaceWarningNoteLevel ); |
|
378 } |
|
379 else |
|
380 { |
|
381 return (TInt64) FindValueL( KCRUidUiklaf, KUikOODDiskFreeSpaceWarningNoteLevelMassMemory ); |
|
382 } |
|
383 } |
354 } |
384 |
355 |
385 // End of file |
356 // End of file |