From 3eda72b82b6a9c544470ef23af6de44e106925a8 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Fri, 23 May 2014 18:38:31 -0500 Subject: [PATCH] Fix breaking embedded resources with getCanonicalPath. --- src/Util.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Util.cpp b/src/Util.cpp index 888ffbbb5..a6540fd76 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,5 +1,6 @@ #include "Util.h" #include +#include "resources/ResourceManager.h" std::string strToUpper(const char* from) { @@ -63,8 +64,14 @@ Eigen::Vector2f roundVector(const Eigen::Vector2f& vec) std::string getCanonicalPath(const std::string& path) { - if(boost::filesystem::exists(path)) - return boost::filesystem::canonical(path).generic_string(); - else - return ""; + // embedded resources, e.g. ":/font.ttf", need to be properly handled too + try + { + const std::string canonical = boost::filesystem::canonical(path).generic_string(); + return canonical.empty() ? path : canonical; + } + catch (boost::filesystem::filesystem_error& e) + { + return path; + } }