Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Creating Directories on Windows for Synthetic Annotation #45

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions plugins/syntheticannotation/src/SyntheticAnnotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "SyntheticAnnotation.h"
#include "Visualizer.h"
#include <filesystem>
#include <iomanip>

using namespace std;
Expand Down Expand Up @@ -269,21 +270,24 @@ void SyntheticAnnotation::render( const char* outputdir ) {
}

//check that output directory exists, if not create it
std::string createdir = "mkdir -p ";
createdir += odir;
int dir = system(createdir.c_str());
if (dir < 0) {
std::string slash = "/";
#ifdef _WIN32
std::replace(odir.begin(), odir.end(), '/', '\\');
slash = "\\";
#endif
bool dir = std::filesystem::create_directory(odir);
if (!dir && !std::filesystem::exists(odir)) {
helios_runtime_error("ERROR (SyntheticAnnotation::render): output directory " + std::string(outputdir) + " could not be created. Exiting...");
}
//create sub-directory structure for each view
//std::string viewdir;
for( int d=0; d<camera_position.size(); d++ ){
std::stringstream viewdir;
viewdir << createdir << "view" << std::setfill('0') << std::setw(5) << d << "/";
viewdir << odir << "view" << std::setfill('0') << std::setw(5) << d << slash;
std::cout << "viewdir: " << viewdir.str() << std::endl;
//std::snprintf(viewdir,createdir.size()+24,"%sview%05d/",createdir.c_str(),d);
int dir = system( viewdir.str().c_str() );
if (dir < 0) {
dir = std::filesystem::create_directory(viewdir.str());
if (!dir && !std::filesystem::exists(viewdir.str())) {
helios_runtime_error("ERROR (SyntheticAnnotation::render): view sub-directory could not be created. Exiting...");
}
}
Expand Down
Loading