Permalink
Browse files

hcanSWD Option --mkdir

  • Loading branch information...
RealMerlin committed Dec 20, 2017
1 parent edc15e5 commit 323709de79d50db487df6e0bad0de9df2e8e2565
Showing with 11 additions and 2 deletions.
  1. +11 −2 hcanswd/main.cc
View
@@ -65,13 +65,22 @@ string generate_filename()
return string(s) + ".hdump";
}
void run_archive_mode(const string &dir)
void run_archive_mode(const string &dir, bool mkdir)
{
while (! signal_quit)
{
transport_connection tp(inet_addr("127.0.0.1"));
const string filename = generate_filename();
if(mkdir)
{
int exitcode = system(("mkdir -p " + dir).c_str());
if(exitcode != 0)
{
throw traceable_error("Failed to create directory");
}
}
data_file_writer dfw(dir + "/" + filename);
while (! (signal_quit || signal_reload))
@@ -127,7 +136,7 @@ void handle_given_options (const po::parsed_options &options,
bool mkdir = false;
if(map.count("mkdir"))
mkdir = true;
run_archive_mode(map["dir"].as<string>());
run_archive_mode(map["dir"].as<string>(), mkdir);
}
else
throw traceable_error("--dir missing");

0 comments on commit 323709d

Please sign in to comment.