Fix breaking embedded resources with getCanonicalPath.

This commit is contained in:
Aloshi 2014-05-23 18:38:31 -05:00
parent b15f3aeec0
commit 3eda72b82b

View file

@ -1,5 +1,6 @@
#include "Util.h" #include "Util.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include "resources/ResourceManager.h"
std::string strToUpper(const char* from) std::string strToUpper(const char* from)
{ {
@ -63,8 +64,14 @@ Eigen::Vector2f roundVector(const Eigen::Vector2f& vec)
std::string getCanonicalPath(const std::string& path) std::string getCanonicalPath(const std::string& path)
{ {
if(boost::filesystem::exists(path)) // embedded resources, e.g. ":/font.ttf", need to be properly handled too
return boost::filesystem::canonical(path).generic_string(); try
else {
return ""; const std::string canonical = boost::filesystem::canonical(path).generic_string();
return canonical.empty() ? path : canonical;
}
catch (boost::filesystem::filesystem_error& e)
{
return path;
}
} }