@@ -13,8 +13,13 @@ Date: June 2006
13
13
14
14
#include " compile.h"
15
15
16
+ #include < cstring>
17
+ #include < fstream>
18
+ #include < iostream>
19
+
16
20
#include < util/cmdline.h>
17
21
#include < util/config.h>
22
+ #include < util/file_util.h>
18
23
#include < util/get_base_name.h>
19
24
#include < util/prefix.h>
20
25
#include < util/run.h>
@@ -23,11 +28,6 @@ Date: June 2006
23
28
#include < util/tempfile.h>
24
29
#include < util/version.h>
25
30
26
- #include < cstring>
27
- #include < filesystem>
28
- #include < fstream>
29
- #include < iostream>
30
-
31
31
#ifdef _MSC_VER
32
32
# include < util/unicode.h>
33
33
#endif
@@ -222,14 +222,11 @@ bool compilet::add_files_from_archive(
222
222
tstr = get_temporary_directory (" goto-cc.XXXXXX" );
223
223
224
224
tmp_dirs.push_back (tstr);
225
- std::filesystem::current_path (tmp_dirs.back ());
225
+ set_current_path (tmp_dirs.back ());
226
226
227
227
// unpack now
228
- int ret = run (
229
- " ar" ,
230
- {" ar" ,
231
- " x" ,
232
- std::filesystem::path (working_directory).append (file_name).string ()});
228
+ int ret =
229
+ run (" ar" , {" ar" , " x" , concat_dir_file (working_directory, file_name)});
233
230
if (ret != 0 )
234
231
{
235
232
log .error () << " Failed to extract archive " << file_name << messaget::eom;
@@ -241,9 +238,7 @@ bool compilet::add_files_from_archive(
241
238
temporary_filet tmp_file_out (" " , " " );
242
239
int ret = run (
243
240
" ar" ,
244
- {" ar" ,
245
- " t" ,
246
- std::filesystem::path (working_directory).append (file_name).string ()},
241
+ {" ar" , " t" , concat_dir_file (working_directory, file_name)},
247
242
" " ,
248
243
tmp_file_out (),
249
244
" " );
@@ -258,7 +253,7 @@ bool compilet::add_files_from_archive(
258
253
259
254
while (!in.fail () && std::getline (in, line))
260
255
{
261
- std::string t = std::filesystem::path (tstr). append ( line). string ( );
256
+ std::string t = concat_dir_file (tstr, line);
262
257
263
258
if (is_goto_binary (t, log .get_message_handler ()))
264
259
object_files.push_back (t);
@@ -268,7 +263,7 @@ bool compilet::add_files_from_archive(
268
263
}
269
264
270
265
if (!thin_archive)
271
- std::filesystem::current_path (working_directory);
266
+ set_current_path (working_directory);
272
267
273
268
return false ;
274
269
}
@@ -282,18 +277,15 @@ bool compilet::find_library(const std::string &name)
282
277
283
278
for (const auto &library_path : library_paths)
284
279
{
285
- library_file_name =
286
- std::filesystem::path (library_path).append (" lib" + name + " .a" ).string ();
280
+ library_file_name = concat_dir_file (library_path, " lib" + name + " .a" );
287
281
288
282
std::ifstream in (library_file_name);
289
283
290
284
if (in.is_open ())
291
285
return !add_input_file (library_file_name);
292
286
else
293
287
{
294
- library_file_name = std::filesystem::path (library_path)
295
- .append (" lib" + name + " .so" )
296
- .string ();
288
+ library_file_name = concat_dir_file (library_path, " lib" + name + " .so" );
297
289
298
290
switch (detect_file_type (library_file_name, log .get_message_handler ()))
299
291
{
@@ -422,11 +414,7 @@ optionalt<symbol_tablet> compilet::compile()
422
414
get_base_name (file_name, true ) + " ." + object_file_extension;
423
415
424
416
if (!output_directory_object.empty ())
425
- {
426
- cfn = std::filesystem::path (output_directory_object)
427
- .append (file_name_with_obj_ext)
428
- .string ();
429
- }
417
+ cfn = concat_dir_file (output_directory_object, file_name_with_obj_ext);
430
418
else
431
419
cfn = file_name_with_obj_ext;
432
420
}
@@ -669,7 +657,7 @@ compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
669
657
mode=COMPILE_LINK_EXECUTABLE;
670
658
echo_file_name=false ;
671
659
wrote_object=false ;
672
- working_directory = std::filesystem::current_path (). string ();
660
+ working_directory= get_current_working_directory ();
673
661
674
662
if (cmdline.isset (" export-function-local-symbols" ))
675
663
{
@@ -686,7 +674,7 @@ compilet::~compilet()
686
674
// clean up temp dirs
687
675
688
676
for (const auto &dir : tmp_dirs)
689
- std::filesystem::remove_all (dir);
677
+ delete_directory (dir);
690
678
}
691
679
692
680
std::size_t compilet::function_body_count (const goto_functionst &functions)
0 commit comments