diff options
Diffstat (limited to 'src/uscxml/interpreter/InterpreterImpl.cpp')
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp index 4d98609..00fbf41 100644 --- a/src/uscxml/interpreter/InterpreterImpl.cpp +++ b/src/uscxml/interpreter/InterpreterImpl.cpp @@ -38,6 +38,7 @@ #include <algorithm> #include <memory> #include <mutex> +#include <cstdio> // remove #include "uscxml/interpreter/FastMicroStep.h" #include "uscxml/interpreter/LargeMicroStep.h" @@ -337,11 +338,15 @@ void InterpreterImpl::init() { // try to open chached data from resource directory std::string sharedTemp = URL::getTempDir(true); std::ifstream dataFS(sharedTemp + PATH_SEPERATOR + md5(_baseURL) + ".uscxml.cache"); - if (dataFS.is_open()) { - std::string cacheStr((std::istreambuf_iterator<char>(dataFS)), - std::istreambuf_iterator<char>()); - _cache = Data::fromJSON(cacheStr); - } + try { + if (dataFS.is_open()) { + std::string cacheStr((std::istreambuf_iterator<char>(dataFS)), + std::istreambuf_iterator<char>()); + _cache = Data::fromJSON(cacheStr); + } + } catch (...) { + remove(std::string(sharedTemp + PATH_SEPERATOR + md5(_baseURL) + ".uscxml.cache").c_str()); + } // get md5 of current document std::stringstream ss; |