@@ -13,13 +13,8 @@ Date: June 2006
1313
1414#include " compile.h"
1515
16- #include < cstring>
17- #include < fstream>
18- #include < iostream>
19-
2016#include < util/cmdline.h>
2117#include < util/config.h>
22- #include < util/file_util.h>
2318#include < util/get_base_name.h>
2419#include < util/prefix.h>
2520#include < util/run.h>
@@ -28,6 +23,11 @@ Date: June 2006
2823#include < util/tempfile.h>
2924#include < util/version.h>
3025
26+ #include < cstring>
27+ #include < filesystem>
28+ #include < fstream>
29+ #include < iostream>
30+
3131#ifdef _MSC_VER
3232# include < util/unicode.h>
3333#endif
@@ -222,11 +222,14 @@ bool compilet::add_files_from_archive(
222222 tstr = get_temporary_directory (" goto-cc.XXXXXX" );
223223
224224 tmp_dirs.push_back (tstr);
225- set_current_path (tmp_dirs.back ());
225+ std::filesystem::current_path (tmp_dirs.back ());
226226
227227 // unpack now
228- int ret =
229- run (" ar" , {" ar" , " x" , concat_dir_file (working_directory, file_name)});
228+ int ret = run (
229+ " ar" ,
230+ {" ar" ,
231+ " x" ,
232+ std::filesystem::path (working_directory).append (file_name).string ()});
230233 if (ret != 0 )
231234 {
232235 log.error () << " Failed to extract archive " << file_name << messaget::eom;
@@ -238,7 +241,9 @@ bool compilet::add_files_from_archive(
238241 temporary_filet tmp_file_out (" " , " " );
239242 int ret = run (
240243 " ar" ,
241- {" ar" , " t" , concat_dir_file (working_directory, file_name)},
244+ {" ar" ,
245+ " t" ,
246+ std::filesystem::path (working_directory).append (file_name).string ()},
242247 " " ,
243248 tmp_file_out (),
244249 " " );
@@ -253,7 +258,7 @@ bool compilet::add_files_from_archive(
253258
254259 while (!in.fail () && std::getline (in, line))
255260 {
256- std::string t = concat_dir_file (tstr, line);
261+ std::string t = std::filesystem::path (tstr). append ( line). string ( );
257262
258263 if (is_goto_binary (t, log.get_message_handler ()))
259264 object_files.push_back (t);
@@ -263,7 +268,7 @@ bool compilet::add_files_from_archive(
263268 }
264269
265270 if (!thin_archive)
266- set_current_path (working_directory);
271+ std::filesystem::current_path (working_directory);
267272
268273 return false ;
269274}
@@ -277,15 +282,18 @@ bool compilet::find_library(const std::string &name)
277282
278283 for (const auto &library_path : library_paths)
279284 {
280- library_file_name = concat_dir_file (library_path, " lib" + name + " .a" );
285+ library_file_name =
286+ std::filesystem::path (library_path).append (" lib" + name + " .a" ).string ();
281287
282288 std::ifstream in (library_file_name);
283289
284290 if (in.is_open ())
285291 return !add_input_file (library_file_name);
286292 else
287293 {
288- library_file_name = concat_dir_file (library_path, " lib" + name + " .so" );
294+ library_file_name = std::filesystem::path (library_path)
295+ .append (" lib" + name + " .so" )
296+ .string ();
289297
290298 switch (detect_file_type (library_file_name, log.get_message_handler ()))
291299 {
@@ -414,7 +422,11 @@ optionalt<symbol_tablet> compilet::compile()
414422 get_base_name (file_name, true ) + " ." + object_file_extension;
415423
416424 if (!output_directory_object.empty ())
417- cfn = concat_dir_file (output_directory_object, file_name_with_obj_ext);
425+ {
426+ cfn = std::filesystem::path (output_directory_object)
427+ .append (file_name_with_obj_ext)
428+ .string ();
429+ }
418430 else
419431 cfn = file_name_with_obj_ext;
420432 }
@@ -657,7 +669,7 @@ compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
657669 mode=COMPILE_LINK_EXECUTABLE;
658670 echo_file_name=false ;
659671 wrote_object=false ;
660- working_directory= get_current_working_directory ();
672+ working_directory = std::filesystem::current_path (). string ();
661673
662674 if (cmdline.isset (" export-function-local-symbols" ))
663675 {
@@ -674,7 +686,7 @@ compilet::~compilet()
674686 // clean up temp dirs
675687
676688 for (const auto &dir : tmp_dirs)
677- delete_directory (dir);
689+ std::filesystem::remove_all (dir);
678690}
679691
680692std::size_t compilet::function_body_count (const goto_functionst &functions)
0 commit comments