Skip to content

Commit

Permalink
Create the output directory if it doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
Orvid committed Apr 30, 2016
1 parent c69d781 commit 1b15a68
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Caprica/common/FSUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static Concurrency::concurrent_unordered_map<std::string, std::future<std::strin
static Concurrency::concurrent_unordered_map<std::string, std::string, CaselessStringHasher, CaselessStringEqual> readFilesMap{ };
std::string Cache::readFile(const std::string& filename) {
std::ifstream inFile{ filename, std::ifstream::binary };
inFile.exceptions(std::ifstream::badbit | std::ifstream::failbit);
std::stringstream strStream;
strStream << inFile.rdbuf();
auto str = strStream.str();
Expand Down Expand Up @@ -68,7 +69,11 @@ std::string Cache::cachedReadFull(const std::string& filename) {

static void writeFile(const std::string& filename, const std::string& value) {
if (!conf::Performance::performanceTestMode) {
auto containingDir = boost::filesystem::path(filename).parent_path();
if (!boost::filesystem::exists(containingDir))
boost::filesystem::create_directories(containingDir);
std::ofstream destFile{ filename, std::ifstream::binary };
destFile.exceptions(std::ifstream::badbit | std::ifstream::failbit);
destFile << value;
}
}
Expand Down

0 comments on commit 1b15a68

Please sign in to comment.