aboutsummaryrefslogtreecommitdiff
path: root/build/filesystem.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-25 14:48:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-25 14:48:36 +0200
commitcd75e06a87aa74aa6968113107afa53d401d20bc (patch)
tree1e104829d10f375a783d6efbbf7eef3e2c6d2ef5 /build/filesystem.cxx
parenta94dcda7f00b10cb22b5f2138b1c29bcfbe7de37 (diff)
Configure/disfigure src_root saving/removing support; fsdir{} injection
We can now build out-of-tree.
Diffstat (limited to 'build/filesystem.cxx')
-rw-r--r--build/filesystem.cxx20
1 files changed, 17 insertions, 3 deletions
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