diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-10-10 12:24:45 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-10-10 12:24:45 -0400 |
commit | 2d1219fa5154c489cd856bedd04b84573d45ac04 (patch) | |
tree | a8e42e6acd79f73aac228e0fe6876917067db8c4 /src/util/filesource.cpp | |
parent | 8f6e8eead12c6b2c2de0ce76fa7df39ca2445006 (diff) | |
parent | f390dab0ea7d449bdd89855c84e47f4a07606fe4 (diff) | |
download | qtlocation-mapboxgl-2d1219fa5154c489cd856bedd04b84573d45ac04.tar.gz |
Merge branch 'master' into libuv-0.10-headless-display
Conflicts:
common/curl_request.cpp
common/glfw_view.cpp
common/glfw_view.hpp
include/mbgl/platform/request.hpp
ios/mapbox-gl-cocoa
setup-libraries.sh
src/map/map.cpp
src/platform/request.cpp
test/fixtures/fixture_request.cpp
Diffstat (limited to 'src/util/filesource.cpp')
-rw-r--r-- | src/util/filesource.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/util/filesource.cpp b/src/util/filesource.cpp deleted file mode 100644 index 503d4dfb1d..0000000000 --- a/src/util/filesource.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include <mbgl/util/filesource.hpp> -#include <mbgl/platform/platform.hpp> - -#include <fstream> -#include <sstream> - -namespace mbgl { - -FileSource::FileSource() {} - - -void FileSource::setBase(const std::string &value) { - base = value; -} - -const std::string &FileSource::getBase() const { - return base; -} - -void FileSource::load(ResourceType /*type*/, const std::string &url, std::function<void(platform::Response *)> callback, const std::shared_ptr<uv::loop> loop) { - // convert relative URLs to absolute URLs - - const std::string absoluteURL = [&]() -> std::string { - const size_t separator = url.find("://"); - if (separator == std::string::npos) { - // Relative URL. - return base + url; - } else { - return url; - } - }(); - - const size_t separator = absoluteURL.find("://"); - const std::string protocol = separator != std::string::npos ? absoluteURL.substr(0, separator) : ""; - - if (protocol == "file") { - // load from disk - const std::string path = absoluteURL.substr(separator + 3); - std::ifstream file(path); - - platform::Response response(callback); - if (!file.good()) { - response.error_message = "file not found (" + path + ")"; - } else { - std::stringstream data; - data << file.rdbuf(); - response.code = 200; - response.body = data.str(); - } - - callback(&response); - } else { - // load from the internet - platform::request_http(absoluteURL, callback, loop); - } -} - -}
\ No newline at end of file |