Maintenance - Mise à jour mensuelle Lundi 7 Décembre 2021 entre 7h00 et 9h00

Commit 73130e7e authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

io: use c++ stream to fix Win32 FS API

parent 33871967
......@@ -6,6 +6,7 @@
#include "imnodes.hpp"
#include <filesystem>
#include <fstream>
#include <future>
#include <mutex>
#include <string>
......@@ -733,12 +734,14 @@ struct editor
if (!path.empty() && ImGui::MenuItem("Save")) {
log_w.log(3, "Write into file %s\n", path.string().c_str());
writer w(std::fopen(path.string().c_str(), "w"));
auto ret = w(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
if (auto os = std::ofstream(path); os.is_open()) {
writer w(os);
auto ret = w(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
}
}
if (ImGui::MenuItem("Save as..."))
......@@ -788,12 +791,14 @@ struct editor
if (load_file_dialog(path)) {
show_load_file_dialog = false;
log_w.log(5, "Load file from %s\n", path.string().c_str());
reader r(std::fopen(path.string().c_str(), "r"));
auto ret = r(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
if (auto is = std::ifstream(path); is.is_open()) {
reader r(is);
auto ret = r(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
}
}
}
......@@ -809,12 +814,14 @@ struct editor
log_w.log(5, "Save file to %s\n", path.string().c_str());
log_w.log(3, "Write into file %s\n", path.string().c_str());
writer w(std::fopen(path.string().c_str(), "w"));
auto ret = w(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
if (auto os = std::ofstream(path); os.is_open()) {
writer w(os);
auto ret = w(sim);
if (is_success(ret))
log_w.log(5, "success\n");
else
log_w.log(4, "error writing\n");
}
}
}
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
#include <fmt/format.h>
#include <cstdio>
#include <iostream>
struct file_output
{
......@@ -859,8 +859,7 @@ main()
expect(sim.models.can_alloc(2));
expect(
irt::is_success(sim.alloc(gen, sim.generator_models.get_id(gen))));
expect(
irt::is_success(sim.alloc(cnt, sim.counter_models.get_id(cnt))));
expect(irt::is_success(sim.alloc(cnt, sim.counter_models.get_id(cnt))));
expect(sim.connect(gen.y[0], cnt.x[0]) == irt::status::success);
......@@ -1013,7 +1012,7 @@ main()
expect(sim.connect(integrator_b.y[0], quantifier_b.x[0]) ==
irt::status::success);
irt::dot_writer dw(stdout);
irt::dot_writer dw(std::cout);
dw(sim);
file_output fo_a("lotka-volterra_a.csv");
......@@ -1193,7 +1192,7 @@ main()
irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
irt::dot_writer dw(stdout);
irt::dot_writer dw(std::cout);
dw(sim);
file_output fo_a("izhikevitch_a.csv");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment