diff options
author | vng <viktor.govako@gmail.com> | 2012-07-03 09:20:08 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:40:32 +0300 |
commit | 8eb9f95264fb11e1bd6dcaef6e735b083def7a59 (patch) | |
tree | f700e713629097eff30802c69b0a679d5bfb6703 /platform/chunks_download_strategy.hpp | |
parent | cae1c655f994b27bde665d417e6581fba3a0eaa2 (diff) |
New extensions for resume/downloading logic to avoid mixing with old user's temporary files.
Diffstat (limited to 'platform/chunks_download_strategy.hpp')
-rw-r--r-- | platform/chunks_download_strategy.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/platform/chunks_download_strategy.hpp b/platform/chunks_download_strategy.hpp index c3ae0cd841..6b7e701e13 100644 --- a/platform/chunks_download_strategy.hpp +++ b/platform/chunks_download_strategy.hpp @@ -4,6 +4,7 @@ #include "../std/vector.hpp" #include "../std/utility.hpp" #include "../std/stdint.hpp" +#include "../std/static_assert.hpp" namespace downloader @@ -16,6 +17,7 @@ public: enum ChunkStatusT { CHUNK_FREE = 0, CHUNK_DOWNLOADING = 1, CHUNK_COMPLETE = 2, CHUNK_AUX = -1 }; private: +#pragma pack(push, 1) struct ChunkT { /// position of chunk in file @@ -23,9 +25,14 @@ private: /// @see ChunkStatusT int8_t m_status; - ChunkT() : m_pos(-1), m_status(-1) {} + ChunkT() : m_pos(-1), m_status(-1) + { + // Be sure to avoid overhead in writing to file. + STATIC_ASSERT(sizeof(ChunkT) == 9); + } ChunkT(int64_t pos, int8_t st) : m_pos(pos), m_status(st) {} }; +#pragma pack(pop) vector<ChunkT> m_chunks; @@ -61,7 +68,7 @@ public: /// Used in unit tests only! void AddChunk(RangeT const & range, ChunkStatusT status); - void SaveChunks(string const & fName); + void SaveChunks(int64_t fileSize, string const & fName); /// @return Already downloaded size. int64_t LoadOrInitChunks(string const & fName, int64_t fileSize, int64_t chunkSize); |