Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/coding
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2018-12-19 15:38:36 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2018-12-20 13:29:47 +0300
commita724c0e417e7ef553f464f04a94db60cb68fa751 (patch)
tree9cba8e9ea1b0f3071ec055940324df80a332bf33 /coding
parentc26045f4ca6363f9d55e3b33414ffe6c93acb6bc (diff)
[generator] A fix for applying corrupted diffs.
It looks like sometimes diff files cannot be unarchived. The result of inflate() should at least contain the diff header even for diffs created from two identical files but for some reason it appears to be empty. This commit stops assuming that the downloaded diff file can be read without errors.
Diffstat (limited to 'coding')
-rw-r--r--coding/reader.cpp9
-rw-r--r--coding/reader.hpp6
2 files changed, 14 insertions, 1 deletions
diff --git a/coding/reader.cpp b/coding/reader.cpp
index 6b94af3bc7..b7f4a1c59d 100644
--- a/coding/reader.cpp
+++ b/coding/reader.cpp
@@ -2,7 +2,6 @@
#include "base/string_utils.hpp"
-
void Reader::ReadAsString(string & s) const
{
s.clear();
@@ -11,6 +10,14 @@ void Reader::ReadAsString(string & s) const
Read(0, &s[0], sz);
}
+vector<uint8_t> Reader::Contents() const
+{
+ vector<uint8_t> contents;
+ contents.resize(Size());
+ Read(0 /* pos */, contents.data(), contents.size());
+ return contents;
+}
+
bool Reader::IsEqual(string const & name1, string const & name2)
{
#if defined(OMIM_OS_WINDOWS)
diff --git a/coding/reader.hpp b/coding/reader.hpp
index fb3546a717..5ff276ccc1 100644
--- a/coding/reader.hpp
+++ b/coding/reader.hpp
@@ -1,9 +1,11 @@
#pragma once
+
#include "coding/endianness.hpp"
#include "base/assert.hpp"
#include "base/exception.hpp"
+#include "std/cstdint.hpp"
#include "std/cstring.hpp"
#include "std/shared_array.hpp"
#include "std/shared_ptr.hpp"
@@ -28,6 +30,10 @@ public:
void ReadAsString(string & s) const;
+ // Reads the contents of this Reader to a vector of 8-bit bytes.
+ // Similar to ReadAsString but makes no assumptions about the char type.
+ vector<uint8_t> Contents() const;
+
static bool IsEqual(string const & name1, string const & name2);
};