File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,22 @@ double RandomDouble(double lo, double hi)
31
31
32
32
std::string ReadFile (std::string filename)
33
33
{
34
- std::ifstream t (filename);
35
- std::stringstream buffer;
36
- buffer << t.rdbuf ();
37
- return buffer.str ();
34
+ std::ifstream file (filename, std::ios::binary);
35
+ if (!file) {
36
+ throw std::runtime_error (" Could not open file" );
37
+ }
38
+
39
+ file.seekg (0 , std::ios::end);
40
+ std::streamsize size = file.tellg ();
41
+ file.seekg (0 , std::ios::beg);
42
+
43
+ std::string buffer (size, ' \0 ' );
44
+
45
+ if (!file.read (buffer.data (), size)) {
46
+ throw std::runtime_error (" Error reading file" );
47
+ }
48
+
49
+ return buffer;
38
50
}
39
51
40
52
void SpecificLoadTest (webifc::parsing::IfcLoader &loader, webifc::geometry::IfcGeometryProcessor &geometryLoader, uint64_t num)
You can’t perform that action at this time.
0 commit comments