Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-11 12:02:48 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-11 12:02:48 +0300
commit05898aaf0f2287e47ec26d075dd39c98c330700f (patch)
treee932c6aa342e6a56e573e64b28775388b6b93c0b
parent43aa8aa466979088a863fcdb09597f11e472a722 (diff)
Refactored path_view now links on all platforms in all C++ standards.
-rw-r--r--cmake/headers.cmake2
-rw-r--r--include/llfio/revision.hpp6
-rw-r--r--include/llfio/v2.0/detail/impl/path_view.ipp54
-rw-r--r--include/llfio/v2.0/path_view.hpp26
4 files changed, 76 insertions, 12 deletions
diff --git a/cmake/headers.cmake b/cmake/headers.cmake
index 2952317d..f176c49c 100644
--- a/cmake/headers.cmake
+++ b/cmake/headers.cmake
@@ -24,6 +24,7 @@ set(llfio_HEADERS
"include/llfio/v2.0/detail/impl/cached_parent_handle_adapter.ipp"
"include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp"
"include/llfio/v2.0/detail/impl/path_discovery.ipp"
+ "include/llfio/v2.0/detail/impl/path_view.ipp"
"include/llfio/v2.0/detail/impl/posix/async_file_handle.ipp"
"include/llfio/v2.0/detail/impl/posix/directory_handle.ipp"
"include/llfio/v2.0/detail/impl/posix/file_handle.ipp"
@@ -55,7 +56,6 @@ set(llfio_HEADERS
"include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp"
"include/llfio/v2.0/detail/impl/windows/path_discovery.ipp"
"include/llfio/v2.0/detail/impl/windows/path_handle.ipp"
- "include/llfio/v2.0/detail/impl/windows/path_view.ipp"
"include/llfio/v2.0/detail/impl/windows/stat.ipp"
"include/llfio/v2.0/detail/impl/windows/statfs.ipp"
"include/llfio/v2.0/detail/impl/windows/storage_profile.ipp"
diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index 4d43beeb..3a653965 100644
--- a/include/llfio/revision.hpp
+++ b/include/llfio/revision.hpp
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
-#define LLFIO_PREVIOUS_COMMIT_REF aad9e4b0a0aa3826c78400664c250e3aa3fab696
-#define LLFIO_PREVIOUS_COMMIT_DATE "2019-10-10 09:38:46 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE aad9e4b0
+#define LLFIO_PREVIOUS_COMMIT_REF 43aa8aa466979088a863fcdb09597f11e472a722
+#define LLFIO_PREVIOUS_COMMIT_DATE "2019-10-11 08:28:21 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE 43aa8aa4
diff --git a/include/llfio/v2.0/detail/impl/path_view.ipp b/include/llfio/v2.0/detail/impl/path_view.ipp
index cd4d614b..e2c5a464 100644
--- a/include/llfio/v2.0/detail/impl/path_view.ipp
+++ b/include/llfio/v2.0/detail/impl/path_view.ipp
@@ -44,7 +44,7 @@ namespace detail
}
~_codecvt() {}
};
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
inline const char *cast_char8_t_ptr(const char8_t *v) { return (const char *) v; }
inline char *cast_char8_t_ptr(char8_t *v) { return (char *) v; }
template <> struct _codecvt<char8_t, char> : std::codecvt<char, char, std::mbstate_t>
@@ -311,6 +311,22 @@ namespace detail
toallocate = 0;
state.buffer.Buffer[(state.buffer.Length / sizeof(wchar_t))] = 0;
return state.buffer.Buffer + (state.buffer.Length / sizeof(wchar_t)) + 1;
+#elif defined(_LIBCPP_VERSION)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char to wchar_t conversion on libc++.");
+ abort();
+#elif defined(__GLIBCXX__)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char to wchar_t conversion on libstdc++.");
+ abort();
#else
return _reencode_path_to(toallocate, dest_buffer, dest_buffer_length, src_buffer, src_buffer_length);
#endif
@@ -322,8 +338,26 @@ namespace detail
}
wchar_t *reencode_path_to(size_t &toallocate, wchar_t *dest_buffer, size_t dest_buffer_length, const char8_t *src_buffer, size_t src_buffer_length)
{
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
+#if defined(_LIBCPP_VERSION)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char8_t to wchar_t conversion on libc++.");
+ abort();
+#elif defined(__GLIBCXX__)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char8_t to wchar_t conversion on libstdc++.");
+ abort();
+#else
return _reencode_path_to(toallocate, dest_buffer, dest_buffer_length, (const char *) src_buffer, src_buffer_length);
+#endif
#else
return _reencode_path_to(toallocate, dest_buffer, dest_buffer_length, src_buffer, src_buffer_length);
#endif
@@ -338,6 +372,22 @@ namespace detail
(void) src_buffer_length;
LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function should never see identity.");
abort();
+#elif defined(_LIBCPP_VERSION)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char16_t to wchar_t conversion on libc++.");
+ abort();
+#elif defined(__GLIBCXX__)
+ (void) toallocate;
+ (void) dest_buffer;
+ (void) dest_buffer_length;
+ (void) src_buffer;
+ (void) src_buffer_length;
+ LLFIO_LOG_FATAL(nullptr, "path_view_component::c_str reencoding function does not support char16_t to wchar_t conversion on libstdc++.");
+ abort();
#else
return _reencode_path_to(toallocate, dest_buffer, dest_buffer_length, src_buffer, src_buffer_length);
#endif
diff --git a/include/llfio/v2.0/path_view.hpp b/include/llfio/v2.0/path_view.hpp
index e4a661e0..946205c0 100644
--- a/include/llfio/v2.0/path_view.hpp
+++ b/include/llfio/v2.0/path_view.hpp
@@ -44,6 +44,14 @@ Distributed under the Boost Software License, Version 1.0.
#define LLFIO_PATH_VIEW_GCC_CONSTEXPR constexpr
#endif
+#ifndef LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
+#if !defined(__CHAR8_TYPE__) && (__cplusplus <= 201703L && !_HAS_CXX20)
+#define LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED 1
+#else
+#define LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED 0
+#endif
+#endif
+
LLFIO_V2_NAMESPACE_EXPORT_BEGIN
namespace detail
@@ -57,7 +65,7 @@ namespace detail
return e - s;
}
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
struct char8_t
{
char v;
@@ -145,7 +153,7 @@ public:
//! Character type for passthrough input
using byte = LLFIO_V2_NAMESPACE::byte;
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
using char8_t = detail::char8_t;
#endif
#if !defined(__CHAR16_TYPE__) && !defined(_MSC_VER) // VS2015 onwards has built in char16_t
@@ -367,7 +375,7 @@ private:
template <class CharT> static int _do_compare(const CharT *a, const CharT *b, size_t length) noexcept { return memcmp(a, b, length * sizeof(CharT)); }
static int _do_compare(const char8_t *_a, const char8_t *_b, size_t length) noexcept
{
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
basic_string_view<char> a((const char *) _a, length);
basic_string_view<char> b((const char *) _b, length);
#else
@@ -757,12 +765,18 @@ namespace detail
// Cheat by going via filesystem::path
s << filesystem::path(_v.begin(), _v.end());
}
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED || 1 // std::filesystem::path support for char8_t input is currently lacking :(
void operator()(basic_string_view<char8_t> _v)
{
basic_string_view<char> v((char *) _v.data(), _v.size());
s << v;
}
+#else
+ void operator()(basic_string_view<char8_t> _v)
+ {
+ // Cheat by going via filesystem::path
+ s << filesystem::path(_v.begin(), _v.end());
+ }
#endif
};
} // namespace detail
@@ -891,7 +905,7 @@ public:
//! Character type for passthrough input
using byte = LLFIO_V2_NAMESPACE::byte;
-#if !defined(__CHAR8_TYPE__) && __cplusplus < 20200000
+#if LLFIO_PATH_VIEW_CHAR8_TYPE_EMULATED
using char8_t = detail::char8_t;
#endif
#if !defined(__CHAR16_TYPE__) && !defined(_MSC_VER) // VS2015 onwards has built in char16_t
@@ -1278,7 +1292,7 @@ public:
#elif defined(_MSC_VER)
template <class T, class Deleter, size_t _internal_buffer_size, class>
#else
- template <class T, class Deleter, size_t _internal_buffer_size, typename std::enable_if<(is_source_acceptable<T>), bool>::type>
+template <class T, class Deleter, size_t _internal_buffer_size, typename std::enable_if<(is_source_acceptable<T>), bool>::type>
#endif
friend struct c_str;
};