Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
73130e7e
Commit
73130e7e
authored
Apr 23, 2020
by
Gauthier Quesnel
Browse files
io: use c++ stream to fix Win32 FS API
parent
33871967
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
app/gui/node-editor.cpp
View file @
73130e7e
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "imnodes.hpp"
#include "imnodes.hpp"
#include <filesystem>
#include <filesystem>
#include <fstream>
#include <future>
#include <future>
#include <mutex>
#include <mutex>
#include <string>
#include <string>
...
@@ -733,12 +734,14 @@ struct editor
...
@@ -733,12 +734,14 @@ struct editor
if
(
!
path
.
empty
()
&&
ImGui
::
MenuItem
(
"Save"
))
{
if
(
!
path
.
empty
()
&&
ImGui
::
MenuItem
(
"Save"
))
{
log_w
.
log
(
3
,
"Write into file %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"
));
if
(
auto
os
=
std
::
ofstream
(
path
);
os
.
is_open
())
{
auto
ret
=
w
(
sim
);
writer
w
(
os
);
if
(
is_success
(
ret
))
auto
ret
=
w
(
sim
);
log_w
.
log
(
5
,
"success
\n
"
);
if
(
is_success
(
ret
))
else
log_w
.
log
(
5
,
"success
\n
"
);
log_w
.
log
(
4
,
"error writing
\n
"
);
else
log_w
.
log
(
4
,
"error writing
\n
"
);
}
}
}
if
(
ImGui
::
MenuItem
(
"Save as..."
))
if
(
ImGui
::
MenuItem
(
"Save as..."
))
...
@@ -788,12 +791,14 @@ struct editor
...
@@ -788,12 +791,14 @@ struct editor
if
(
load_file_dialog
(
path
))
{
if
(
load_file_dialog
(
path
))
{
show_load_file_dialog
=
false
;
show_load_file_dialog
=
false
;
log_w
.
log
(
5
,
"Load file from %s
\n
"
,
path
.
string
().
c_str
());
log_w
.
log
(
5
,
"Load file from %s
\n
"
,
path
.
string
().
c_str
());
reader
r
(
std
::
fopen
(
path
.
string
().
c_str
(),
"r"
));
if
(
auto
is
=
std
::
ifstream
(
path
);
is
.
is_open
())
{
auto
ret
=
r
(
sim
);
reader
r
(
is
);
if
(
is_success
(
ret
))
auto
ret
=
r
(
sim
);
log_w
.
log
(
5
,
"success
\n
"
);
if
(
is_success
(
ret
))
else
log_w
.
log
(
5
,
"success
\n
"
);
log_w
.
log
(
4
,
"error writing
\n
"
);
else
log_w
.
log
(
4
,
"error writing
\n
"
);
}
}
}
}
}
...
@@ -809,12 +814,14 @@ struct editor
...
@@ -809,12 +814,14 @@ struct editor
log_w
.
log
(
5
,
"Save file to %s
\n
"
,
path
.
string
().
c_str
());
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
());
log_w
.
log
(
3
,
"Write into file %s
\n
"
,
path
.
string
().
c_str
());
writer
w
(
std
::
fopen
(
path
.
string
().
c_str
(),
"w"
));
if
(
auto
os
=
std
::
ofstream
(
path
);
os
.
is_open
())
{
auto
ret
=
w
(
sim
);
writer
w
(
os
);
if
(
is_success
(
ret
))
auto
ret
=
w
(
sim
);
log_w
.
log
(
5
,
"success
\n
"
);
if
(
is_success
(
ret
))
else
log_w
.
log
(
5
,
"success
\n
"
);
log_w
.
log
(
4
,
"error writing
\n
"
);
else
log_w
.
log
(
4
,
"error writing
\n
"
);
}
}
}
}
}
...
...
lib/include/irritator/io.hpp
View file @
73130e7e
This diff is collapsed.
Click to expand it.
lib/test/public-api.cpp
View file @
73130e7e
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include <fmt/format.h>
#include <fmt/format.h>
#include <
cstdio
>
#include <
iostream
>
struct
file_output
struct
file_output
{
{
...
@@ -859,8 +859,7 @@ main()
...
@@ -859,8 +859,7 @@ main()
expect
(
sim
.
models
.
can_alloc
(
2
));
expect
(
sim
.
models
.
can_alloc
(
2
));
expect
(
expect
(
irt
::
is_success
(
sim
.
alloc
(
gen
,
sim
.
generator_models
.
get_id
(
gen
))));
irt
::
is_success
(
sim
.
alloc
(
gen
,
sim
.
generator_models
.
get_id
(
gen
))));
expect
(
expect
(
irt
::
is_success
(
sim
.
alloc
(
cnt
,
sim
.
counter_models
.
get_id
(
cnt
))));
irt
::
is_success
(
sim
.
alloc
(
cnt
,
sim
.
counter_models
.
get_id
(
cnt
))));
expect
(
sim
.
connect
(
gen
.
y
[
0
],
cnt
.
x
[
0
])
==
irt
::
status
::
success
);
expect
(
sim
.
connect
(
gen
.
y
[
0
],
cnt
.
x
[
0
])
==
irt
::
status
::
success
);
...
@@ -1013,7 +1012,7 @@ main()
...
@@ -1013,7 +1012,7 @@ main()
expect
(
sim
.
connect
(
integrator_b
.
y
[
0
],
quantifier_b
.
x
[
0
])
==
expect
(
sim
.
connect
(
integrator_b
.
y
[
0
],
quantifier_b
.
x
[
0
])
==
irt
::
status
::
success
);
irt
::
status
::
success
);
irt
::
dot_writer
dw
(
stdout
);
irt
::
dot_writer
dw
(
std
::
c
out
);
dw
(
sim
);
dw
(
sim
);
file_output
fo_a
(
"lotka-volterra_a.csv"
);
file_output
fo_a
(
"lotka-volterra_a.csv"
);
...
@@ -1193,7 +1192,7 @@ main()
...
@@ -1193,7 +1192,7 @@ main()
irt
::
status
::
success
);
irt
::
status
::
success
);
expect
(
sim
.
connect
(
constant
.
y
[
0
],
sum_d
.
x
[
1
])
==
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
::
c
out
);
dw
(
sim
);
dw
(
sim
);
file_output
fo_a
(
"izhikevitch_a.csv"
);
file_output
fo_a
(
"izhikevitch_a.csv"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment