summaryrefslogtreecommitdiff
path: root/src/mbgl/util
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-15 18:43:58 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-03-22 15:59:10 +0100
commit3c91b6b7de487993e75de552ba44249740644e42 (patch)
tree69b8b2642b3d8496657db92459b0a23e130b501d /src/mbgl/util
parentd20327844cac88b6bf42b201eac35e816a189a8a (diff)
downloadqtlocation-mapboxgl-3c91b6b7de487993e75de552ba44249740644e42.tar.gz
[core] cache binary shaders on Android
Diffstat (limited to 'src/mbgl/util')
-rw-r--r--src/mbgl/util/io.cpp10
-rw-r--r--src/mbgl/util/io.hpp3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/mbgl/util/io.cpp b/src/mbgl/util/io.cpp
index f37ce09cff..9adc3b8988 100644
--- a/src/mbgl/util/io.cpp
+++ b/src/mbgl/util/io.cpp
@@ -32,6 +32,16 @@ std::string read_file(const std::string &filename) {
}
}
+optional<std::string> readFile(const std::string &filename) {
+ std::ifstream file(filename);
+ if (file.good()) {
+ std::stringstream data;
+ data << file.rdbuf();
+ return data.str();
+ }
+ return {};
+}
+
void deleteFile(const std::string& filename) {
const int ret = unlink(filename.c_str());
if (ret == -1) {
diff --git a/src/mbgl/util/io.hpp b/src/mbgl/util/io.hpp
index 795a465328..847271acf0 100644
--- a/src/mbgl/util/io.hpp
+++ b/src/mbgl/util/io.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <mbgl/util/optional.hpp>
+
#include <string>
#include <stdexcept>
@@ -15,6 +17,7 @@ struct IOException : std::runtime_error {
void write_file(const std::string &filename, const std::string &data);
std::string read_file(const std::string &filename);
+optional<std::string> readFile(const std::string &filename);
void deleteFile(const std::string& filename);
} // namespace util