| 87 | } |
| 88 | |
| 89 | void ChunksDownloadStrategy::SaveChunks(int64_t fileSize, std::string const & fName) |
| 90 | { |
| 91 | if (!m_chunks.empty()) |
| 92 | { |
| 93 | try |
| 94 | { |
| 95 | FileWriter w(fName); |
| 96 | WriteVarInt(w, fileSize); |
| 97 | |
| 98 | w.Write(&m_chunks[0], sizeof(ChunkT) * m_chunks.size()); |
| 99 | return; |
| 100 | } |
| 101 | catch (FileWriter::Exception const & e) |
| 102 | { |
| 103 | LOG(LWARNING, ("Can't save chunks statuses to file", e.Msg())); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Delete if no chunks or some error occured. |
| 108 | UNUSED_VALUE(Platform::RemoveFileIfExists(fName)); |
| 109 | } |
| 110 | |
| 111 | int64_t ChunksDownloadStrategy::LoadOrInitChunks(std::string const & fName, int64_t fileSize, int64_t chunkSize) |
| 112 | { |