3535#include " hphp/util/rds-local.h"
3636#include " hphp/util/timer.h"
3737
38- #include < boost/filesystem/string_file.hpp>
3938#include < boost/program_options/options_description.hpp>
4039#include < boost/program_options/positional_options.hpp>
4140#include < boost/program_options/variables_map.hpp>
4241#include < boost/program_options/parsers.hpp>
4342
4443
4544#include < filesystem>
45+ #include < fstream>
4646#include < iostream>
4747
4848using namespace boost ::program_options;
@@ -151,9 +151,23 @@ int prepareOptions(CompilerOptions &po, int argc, char **argv) {
151151 return 0 ;
152152}
153153
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+
154167bool compile_systemlib (const std::filesystem::path& path, std::string output_dir, const Extension* extension) {
155168 std::string content;
156- boost::filesystem::load_string_file (path.string (), content);
169+
170+ load_string_file (path, content);
157171
158172 // Create Unit Emitter
159173 std::string fname = " /:" +path.filename ().string ();
@@ -178,7 +192,7 @@ bool compile_systemlib(const std::filesystem::path& path, std::string output_dir
178192 BlobEncoder uew_encoder;
179193 uew.serde (uew_encoder);
180194
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 ()));
182196
183197 // Create Decls
184198 auto const & defaults = RepoOptions::defaultsForSystemlib ();
@@ -200,7 +214,7 @@ bool compile_systemlib(const std::filesystem::path& path, std::string output_dir
200214 }
201215
202216 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 ()));
204218
205219 return true ;
206220}
0 commit comments