35
35
#include " hphp/util/rds-local.h"
36
36
#include " hphp/util/timer.h"
37
37
38
- #include < boost/filesystem/string_file.hpp>
39
38
#include < boost/program_options/options_description.hpp>
40
39
#include < boost/program_options/positional_options.hpp>
41
40
#include < boost/program_options/variables_map.hpp>
42
41
#include < boost/program_options/parsers.hpp>
43
42
44
43
45
44
#include < filesystem>
45
+ #include < fstream>
46
46
#include < iostream>
47
47
48
48
using namespace boost ::program_options;
@@ -151,9 +151,23 @@ int prepareOptions(CompilerOptions &po, int argc, char **argv) {
151
151
return 0 ;
152
152
}
153
153
154
+ void load_string_file (const std::filesystem::path& path, std::string& content) {
155
+ std::ifstream file (path, std::ios_base::binary);
156
+ auto file_size = std::filesystem::file_size (path);
157
+
158
+ content.resize (static_cast <std::size_t >(file_size), ' \0 ' );
159
+ file.read (&content[0 ], static_cast <std::streamsize>(file_size));
160
+ }
161
+
162
+ void save_string_file (const std::filesystem::path& path, const std::string& content) {
163
+ std::ofstream file (path, std::ios_base::binary);
164
+ file.write (content.data (), static_cast <std::streamsize>(content.size ()));
165
+ }
166
+
154
167
bool compile_systemlib (const std::filesystem::path& path, std::string output_dir, const Extension* extension) {
155
168
std::string content;
156
- boost::filesystem::load_string_file (path.string (), content);
169
+
170
+ load_string_file (path, content);
157
171
158
172
// Create Unit Emitter
159
173
std::string fname = " /:" +path.filename ().string ();
@@ -178,7 +192,7 @@ bool compile_systemlib(const std::filesystem::path& path, std::string output_dir
178
192
BlobEncoder uew_encoder;
179
193
uew.serde (uew_encoder);
180
194
181
- boost::filesystem:: save_string_file (output_dir + " /" + path.filename ().string () + " .ue" , std::string (static_cast <const char *>(uew_encoder.data ()), uew_encoder.size ()));
195
+ save_string_file (output_dir + " /" + path.filename ().string () + " .ue" , std::string (static_cast <const char *>(uew_encoder.data ()), uew_encoder.size ()));
182
196
183
197
// Create Decls
184
198
auto const & defaults = RepoOptions::defaultsForSystemlib ();
@@ -200,7 +214,7 @@ bool compile_systemlib(const std::filesystem::path& path, std::string output_dir
200
214
}
201
215
202
216
auto serialized = hackc::decls_holder_to_binary (*decls.decls );
203
- boost::filesystem:: save_string_file (output_dir + " /" + path.filename ().string () + " .decls" , std::string (serialized.begin (), serialized.end ()));
217
+ save_string_file (output_dir + " /" + path.filename ().string () + " .decls" , std::string (serialized.begin (), serialized.end ()));
204
218
205
219
return true ;
206
220
}
0 commit comments