open existing cache file stream
| 8589 | |
| 8590 | /// open existing cache file stream |
| 8591 | LVStreamRef openExisting( lString16 filename, lUInt32 crc, lUInt32 docFlags ) |
| 8592 | { |
| 8593 | lString16 fn = makeFileName( filename, crc, docFlags ); |
| 8594 | CRLog::debug("ldomDocCache::openExisting(%s)", LCSTR(fn)); |
| 8595 | LVStreamRef res; |
| 8596 | if ( findFileIndex( fn ) < 0 ) { |
| 8597 | CRLog::error( "ldomDocCache::openExisting - File %s is not found in cache index", UnicodeToUtf8(fn).c_str() ); |
| 8598 | return res; |
| 8599 | } |
| 8600 | res = LVOpenFileStream( (_cacheDir+fn).c_str(), LVOM_APPEND|LVOM_FLAG_SYNC ); |
| 8601 | if ( !res ) { |
| 8602 | CRLog::error( "ldomDocCache::openExisting - File %s is listed in cache index, but cannot be opened", UnicodeToUtf8(fn).c_str() ); |
| 8603 | return res; |
| 8604 | } |
| 8605 | |
| 8606 | #if ENABLED_BLOCK_WRITE_CACHE |
| 8607 | res = LVCreateBlockWriteStream( res, WRITE_CACHE_BLOCK_SIZE, WRITE_CACHE_BLOCK_COUNT ); |
| 8608 | #if TEST_BLOCK_STREAM |
| 8609 | |
| 8610 | LVStreamRef stream2 = LVOpenFileStream( (_cacheDir+fn+L"_c").c_str(), LVOM_APPEND ); |
| 8611 | if ( !stream2 ) { |
| 8612 | CRLog::error( "ldomDocCache::createNew - file %s is cannot be created", UnicodeToUtf8(fn).c_str() ); |
| 8613 | return stream2; |
| 8614 | } |
| 8615 | res = LVCreateCompareTestStream(res, stream2); |
| 8616 | #endif |
| 8617 | #endif |
| 8618 | |
| 8619 | lUInt32 fileSize = (lUInt32) res->GetSize(); |
| 8620 | moveFileToTop( fn, fileSize ); |
| 8621 | return res; |
| 8622 | } |
| 8623 | |
| 8624 | /// create new cache file |
| 8625 | LVStreamRef createNew( lString16 filename, lUInt32 crc, lUInt32 docFlags, lUInt32 fileSize ) |
nothing calls this directly
no test coverage detected