Skip to content

Commit 66d42ce

Browse files
authored
Revert fstream read (#58)
1 parent 060c915 commit 66d42ce

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/proxyfmu/client/proxy_slave.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include <thrift/transport/TTransportUtils.h>
1111

1212
#include <chrono>
13+
#include <cstdio>
1314
#include <utility>
1415
#include <vector>
15-
#include <fstream>
1616

1717
using namespace ::apache::thrift;
1818
using namespace ::apache::thrift::protocol;
@@ -25,8 +25,16 @@ namespace
2525

2626
void read_data(std::string const& fileName, std::string& data)
2727
{
28-
std::fstream file(fileName);
29-
file << data;
28+
FILE* file = fopen(fileName.c_str(), "rb");
29+
if (file == nullptr) return;
30+
fseek(file, 0, SEEK_END);
31+
long int size = ftell(file);
32+
fclose(file);
33+
file = fopen(fileName.c_str(), "rb");
34+
35+
data.resize(size);
36+
[[maybe_unused]] size_t bytes_read = fread(data.data(), sizeof(unsigned char), size, file);
37+
fclose(file);
3038
}
3139

3240
} // namespace

0 commit comments

Comments
 (0)