aboutsummaryrefslogtreecommitdiff
path: root/libbutl/path.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-09-22 23:32:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-09-22 23:32:28 +0200
commitc09cd7512491cee1e82c1ad8128ce9fd4bc3f79b (patch)
treea659ed768d849130ab5780a11b7f791a463a1a91 /libbutl/path.cxx
parent2a00871f07067f8f9e2de08bb9c8f50e1bf6a650 (diff)
Initial modularization with both Clang and VC hacks
Note: gave up on VC about half way though.
Diffstat (limited to 'libbutl/path.cxx')
-rw-r--r--libbutl/path.cxx45
1 files changed, 34 insertions, 11 deletions
diff --git a/libbutl/path.cxx b/libbutl/path.cxx
index c1ede40..bbc4754 100644
--- a/libbutl/path.cxx
+++ b/libbutl/path.cxx
@@ -2,7 +2,9 @@
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
-#include <libbutl/path.hxx>
+#ifndef __cpp_modules
+#include <libbutl/path.mxx>
+#endif
#ifdef _WIN32
# include <libbutl/win32-utility.hxx>
@@ -21,18 +23,37 @@
# include <string.h> // strlen(), strcpy()
# include <sys/stat.h> // stat(), S_IS*
# include <sys/types.h> // stat
-
-# include <vector>
#endif
-#include <atomic>
#include <cassert>
+
+#ifndef __cpp_lib_modules
+#include <string>
+#include <cstddef>
+#include <utility>
+
+#include <atomic>
#include <cstring> // strcpy()
+#endif
-#include <libbutl/export.hxx>
+#ifdef __cpp_modules
+module butl.path;
-#include <libbutl/utility.hxx> // throw_*_error()
-#include <libbutl/process.hxx>
+// Only imports additional to interface.
+#ifdef __clang__
+#ifdef __cpp_lib_modules
+import std.core;
+#endif
+#endif
+
+import butl.utility; // throw_*_error()
+import butl.process; // process::current_id()
+#else
+#include <libbutl/utility.mxx>
+#include <libbutl/process.mxx>
+#endif
+
+#include <libbutl/export.hxx>
#ifndef _WIN32
# ifndef PATH_MAX
@@ -88,9 +109,11 @@ namespace butl
// one of the drive requires the trailing directory separator to be
// present.
//
- string_type const& d (!root (s)
- ? s
- : string_type (s + directory_separator));
+ string_type const& d (
+ !root (s)
+ ? s
+ //@@ MOD VC ADL does not seem to kick in for some reason...
+ : string_type (std::operator+ (s, directory_separator)));
if (_chdir (d.c_str ()) != 0)
throw_generic_error (errno);
@@ -168,7 +191,7 @@ namespace butl
#endif
}
- static atomic<size_t> temp_name_count;
+ static atomic<size_t> temp_name_count (0);
template <>
LIBBUTL_SYMEXPORT path_traits<char>::string_type path_traits<char>::