Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Commit

Permalink
json dumps into folder
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWillard committed May 29, 2019
1 parent 85b8d8f commit 488ab21
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace nl = nlohmann;
namespace p = Poco;
namespace pn = Poco::Net;

namespace fs = std::filesystem;

using namespace intercept;
using namespace grad::replay;

Expand All @@ -40,6 +42,7 @@ using SQFPar = game_value_parameter;
std::string url = "";
std::string token = "";
std::chrono::system_clock::time_point missionStart;
fs::path basePath;

std::string timePointToString(std::chrono::system_clock::time_point timePoint) {
std::time_t missionStartInTimeT = std::chrono::system_clock::to_time_t(timePoint);
Expand Down Expand Up @@ -158,7 +161,7 @@ game_value sendReplay(game_state& gs, SQFPar right_arg) {
if (response.getStatus() != pn::HTTPResponse::HTTPStatus::HTTP_CREATED) {
auto path = std::string(timePointToString(now)).append(".json");
std::replace(path.begin(), path.end(), ':', '-');
std::ofstream o(path);
std::ofstream o(basePath / path);
o << std::setw(4) << obj << std::endl;
}

Expand All @@ -171,7 +174,7 @@ game_value sendReplay(game_state& gs, SQFPar right_arg) {
{
auto path = std::string(timePointToString(now)).append(".json");
std::replace(path.begin(), path.end(), ':', '-');
std::ofstream o(path);
std::ofstream o(basePath / path);
o << std::setw(4) << obj << std::endl;

std::stringstream exceptionLog;
Expand Down Expand Up @@ -215,6 +218,12 @@ void intercept::pre_start() {
pt.add<std::string>("Config.BearerToken", "InsertYourBearerTokenHere");
boost::property_tree::ini_parser::write_ini(path, pt);
}

basePath = "grad_replay_intercept";

if (!fs::exists(basePath)) {
fs::create_directories(basePath);
}

static auto grad_replay_intercept_replay_send =
client::host::register_sqf_command("gradReplayInterceptSendReplay", "Sends the replay", sendReplay, game_data_type::BOOL, game_data_type::ARRAY);
Expand Down

0 comments on commit 488ab21

Please sign in to comment.