From cd75e06a87aa74aa6968113107afa53d401d20bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Mar 2015 14:48:36 +0200 Subject: Configure/disfigure src_root saving/removing support; fsdir{} injection We can now build out-of-tree. --- build/filesystem.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'build/filesystem.cxx') diff --git a/build/filesystem.cxx b/build/filesystem.cxx index ee17fba..5494749 100644 --- a/build/filesystem.cxx +++ b/build/filesystem.cxx @@ -44,11 +44,25 @@ namespace build return S_ISREG (s.st_mode); } - void - mkdir (const path& p, mode_t m) + mkdir_status + try_mkdir (const path& p, mode_t m) { + mkdir_status r (mkdir_status::success); + if (::mkdir (p.string ().c_str (), m) != 0) - throw system_error (errno, system_category ()); + { + int e (errno); + + // EEXIST means the path already exists but not necessarily as + // a directory. + // + if (e == EEXIST && dir_exists (p)) + return mkdir_status::already_exists; + else + throw system_error (e, system_category ()); + } + + return r; } rmdir_status -- cgit v1.1