create new cache file
| 8623 | |
| 8624 | /// create new cache file |
| 8625 | LVStreamRef createNew( lString16 filename, lUInt32 crc, lUInt32 docFlags, lUInt32 fileSize ) |
| 8626 | { |
| 8627 | lString16 fn = makeFileName( filename, crc, docFlags ); |
| 8628 | LVStreamRef res; |
| 8629 | lString16 pathname( _cacheDir+fn ); |
| 8630 | if ( findFileIndex( pathname ) >= 0 ) |
| 8631 | LVDeleteFile( pathname ); |
| 8632 | reserve( fileSize/10 ); |
| 8633 | //res = LVMapFileStream( (_cacheDir+fn).c_str(), LVOM_APPEND, fileSize ); |
| 8634 | LVDeleteFile( pathname ); // try to delete, ignore errors |
| 8635 | res = LVOpenFileStream( pathname.c_str(), LVOM_APPEND|LVOM_FLAG_SYNC ); |
| 8636 | if ( !res ) { |
| 8637 | CRLog::error( "ldomDocCache::createNew - file %s is cannot be created", UnicodeToUtf8(fn).c_str() ); |
| 8638 | return res; |
| 8639 | } |
| 8640 | #if ENABLED_BLOCK_WRITE_CACHE |
| 8641 | res = LVCreateBlockWriteStream( res, WRITE_CACHE_BLOCK_SIZE, WRITE_CACHE_BLOCK_COUNT ); |
| 8642 | #if TEST_BLOCK_STREAM |
| 8643 | LVStreamRef stream2 = LVOpenFileStream( (pathname+L"_c").c_str(), LVOM_APPEND ); |
| 8644 | if ( !stream2 ) { |
| 8645 | CRLog::error( "ldomDocCache::createNew - file %s is cannot be created", UnicodeToUtf8(fn).c_str() ); |
| 8646 | return stream2; |
| 8647 | } |
| 8648 | res = LVCreateCompareTestStream(res, stream2); |
| 8649 | #endif |
| 8650 | #endif |
| 8651 | moveFileToTop( fn, fileSize ); |
| 8652 | return res; |
| 8653 | } |
| 8654 | |
| 8655 | virtual ~ldomDocCacheImpl() |
| 8656 | { |
nothing calls this directly
no test coverage detected