@@ -15,7 +15,6 @@ Date: June 2006
1515
1616#include < util/cmdline.h>
1717#include < util/config.h>
18- #include < util/file_util.h>
1918#include < util/get_base_name.h>
2019#include < util/prefix.h>
2120#include < util/run.h>
@@ -39,6 +38,7 @@ Date: June 2006
3938#include < linking/static_lifetime_init.h>
4039
4140#include < cstring>
41+ #include < filesystem>
4242#include < fstream>
4343#include < iostream>
4444
@@ -217,11 +217,14 @@ bool compilet::add_files_from_archive(
217217 tstr = get_temporary_directory (" goto-cc.XXXXXX" );
218218
219219 tmp_dirs.push_back (tstr);
220- set_current_path (tmp_dirs.back ());
220+ std::filesystem::current_path (tmp_dirs.back ());
221221
222222 // unpack now
223- int ret =
224- run (" ar" , {" ar" , " x" , concat_dir_file (working_directory, file_name)});
223+ int ret = run (
224+ " ar" ,
225+ {" ar" ,
226+ " x" ,
227+ std::filesystem::path (working_directory).append (file_name).string ()});
225228 if (ret != 0 )
226229 {
227230 log.error () << " Failed to extract archive " << file_name << messaget::eom;
@@ -233,7 +236,9 @@ bool compilet::add_files_from_archive(
233236 temporary_filet tmp_file_out (" " , " " );
234237 int ret = run (
235238 " ar" ,
236- {" ar" , " t" , concat_dir_file (working_directory, file_name)},
239+ {" ar" ,
240+ " t" ,
241+ std::filesystem::path (working_directory).append (file_name).string ()},
237242 " " ,
238243 tmp_file_out (),
239244 " " );
@@ -248,7 +253,7 @@ bool compilet::add_files_from_archive(
248253
249254 while (!in.fail () && std::getline (in, line))
250255 {
251- std::string t = concat_dir_file (tstr, line);
256+ std::string t = std::filesystem::path (tstr). append ( line). string ( );
252257
253258 if (is_goto_binary (t, log.get_message_handler ()))
254259 object_files.push_back (t);
@@ -258,7 +263,7 @@ bool compilet::add_files_from_archive(
258263 }
259264
260265 if (!thin_archive)
261- set_current_path (working_directory);
266+ std::filesystem::current_path (working_directory);
262267
263268 return false ;
264269}
@@ -272,15 +277,18 @@ bool compilet::find_library(const std::string &name)
272277
273278 for (const auto &library_path : library_paths)
274279 {
275- library_file_name = concat_dir_file (library_path, " lib" + name + " .a" );
280+ library_file_name =
281+ std::filesystem::path (library_path).append (" lib" + name + " .a" ).string ();
276282
277283 std::ifstream in (library_file_name);
278284
279285 if (in.is_open ())
280286 return !add_input_file (library_file_name);
281287 else
282288 {
283- library_file_name = concat_dir_file (library_path, " lib" + name + " .so" );
289+ library_file_name = std::filesystem::path (library_path)
290+ .append (" lib" + name + " .so" )
291+ .string ();
284292
285293 switch (detect_file_type (library_file_name, log.get_message_handler ()))
286294 {
@@ -409,7 +417,11 @@ std::optional<symbol_tablet> compilet::compile()
409417 get_base_name (file_name, true ) + " ." + object_file_extension;
410418
411419 if (!output_directory_object.empty ())
412- cfn = concat_dir_file (output_directory_object, file_name_with_obj_ext);
420+ {
421+ cfn = std::filesystem::path (output_directory_object)
422+ .append (file_name_with_obj_ext)
423+ .string ();
424+ }
413425 else
414426 cfn = file_name_with_obj_ext;
415427 }
@@ -647,7 +659,7 @@ compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
647659 mode=COMPILE_LINK_EXECUTABLE;
648660 echo_file_name=false ;
649661 wrote_object=false ;
650- working_directory= get_current_working_directory ();
662+ working_directory = std::filesystem::current_path (). string ();
651663
652664 if (cmdline.isset (" export-function-local-symbols" ))
653665 {
@@ -664,7 +676,7 @@ compilet::~compilet()
664676 // clean up temp dirs
665677
666678 for (const auto &dir : tmp_dirs)
667- delete_directory (dir);
679+ std::filesystem::remove_all (dir);
668680}
669681
670682std::size_t compilet::function_body_count (const goto_functionst &functions)
0 commit comments