diff options
Diffstat (limited to 'xdelta3/testing/file.h')
-rw-r--r-- | xdelta3/testing/file.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/xdelta3/testing/file.h b/xdelta3/testing/file.h index 2e25824..c281de9 100644 --- a/xdelta3/testing/file.h +++ b/xdelta3/testing/file.h | |||
@@ -158,6 +158,10 @@ public: | |||
158 | blkno_++; | 158 | blkno_++; |
159 | } | 159 | } |
160 | 160 | ||
161 | xoff_t Blkno() const { | ||
162 | return blkno_; | ||
163 | } | ||
164 | |||
161 | void SetBlock(xoff_t blkno) { | 165 | void SetBlock(xoff_t blkno) { |
162 | blkno_ = blkno; | 166 | blkno_ = blkno; |
163 | } | 167 | } |
@@ -165,11 +169,19 @@ public: | |||
165 | void Get(Block *block) const; | 169 | void Get(Block *block) const; |
166 | 170 | ||
167 | size_t BytesOnBlock() const { | 171 | size_t BytesOnBlock() const { |
168 | // Blocks() is unsigned, don't subtract | 172 | xoff_t blocks = spec_.Blocks(blksize_); |
169 | if (blkno_ + 1 < spec_.Blocks(blksize_)) { | 173 | xoff_t size = spec_.Size(); |
170 | return blksize_; | 174 | |
175 | CHECK((blkno_ < blocks) || | ||
176 | (blkno_ == blocks && size % blksize_ == 0)); | ||
177 | |||
178 | if (blkno_ == blocks) { | ||
179 | return 0; | ||
180 | } | ||
181 | if (blkno_ + 1 == blocks) { | ||
182 | return ((size - 1) % blksize_) + 1; | ||
171 | } | 183 | } |
172 | return spec_.Size() % blksize_; | 184 | return blksize_; |
173 | } | 185 | } |
174 | 186 | ||
175 | size_t BlockSize() const { | 187 | size_t BlockSize() const { |