Skip to content

Commit 1c89485

Browse files
committed
Use set_current_path wrapper
This is a first step to remove the OS-specific code from compile.cpp.
1 parent 1642850 commit 1c89485

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/goto-cc/compile.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ Date: June 2006
4747
"size=\"30,40\";"\
4848
"ratio=compress;"
4949

50-
// the following are for chdir
51-
52-
#if defined(__linux__) || \
53-
defined(__FreeBSD_kernel__) || \
54-
defined(__GNU__) || \
55-
defined(__unix__) || \
56-
defined(__CYGWIN__) || \
57-
defined(__MACH__)
58-
#include <unistd.h>
59-
#endif
60-
6150
#ifdef _WIN32
6251
#include <util/pragma_push.def>
6352
#ifdef _MSC_VER
@@ -66,7 +55,6 @@ Date: June 2006
6655
#endif
6756
#include <direct.h>
6857
#include <windows.h>
69-
#define chdir _chdir
7058
#define popen _popen
7159
#define pclose _pclose
7260
#include <util/pragma_pop.def>
@@ -247,11 +235,7 @@ bool compilet::add_files_from_archive(
247235
}
248236

249237
tmp_dirs.push_back(tstr);
250-
if(chdir(tmp_dirs.back().c_str())!=0)
251-
{
252-
error() << "Cannot switch to temporary directory" << eom;
253-
return true;
254-
}
238+
set_current_path(tmp_dirs.back());
255239

256240
// unpack now
257241
cmd << "ar x " << concat_dir_file(working_directory, file_name);
@@ -294,8 +278,8 @@ bool compilet::add_files_from_archive(
294278
pclose(stream);
295279
}
296280

297-
if(!thin_archive && chdir(working_directory.c_str()) != 0)
298-
error() << "Could not change back to working directory" << eom;
281+
if(!thin_archive)
282+
set_current_path(working_directory);
299283

300284
return false;
301285
}

0 commit comments

Comments
 (0)