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:
-rw-r--r--include/llfio/v2.0/config.hpp5
-rw-r--r--include/llfio/v2.0/path_view.hpp28
-rw-r--r--test/tests/pipe_handle.cpp4
3 files changed, 34 insertions, 3 deletions
diff --git a/include/llfio/v2.0/config.hpp b/include/llfio/v2.0/config.hpp
index 21f806cf..46bec2a0 100644
--- a/include/llfio/v2.0/config.hpp
+++ b/include/llfio/v2.0/config.hpp
@@ -220,6 +220,7 @@ LLFIO_V2_NAMESPACE_END
#if defined(__has_include)
// clang-format off
#if !LLFIO_FORCE_EXPERIMENTAL_FILESYSTEM && __has_include(<filesystem>) && (__cplusplus >= 201700 || _HAS_CXX17)
+#define LLFIO_USING_STD_FILESYSTEM 1
#include <filesystem>
LLFIO_V2_NAMESPACE_BEGIN
namespace filesystem = std::filesystem;
@@ -227,6 +228,7 @@ LLFIO_V2_NAMESPACE_END
// C++ 14 filesystem support was dropped in VS2019 16.3
// C++ 14 filesystem support was dropped in LLVM 11
#elif __has_include(<experimental/filesystem>) && (!defined(_MSC_VER) || _MSC_VER < 1923) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 11000)
+#define LLFIO_USING_EXPERIMENTAL_FILESYSTEM 1
#include <experimental/filesystem>
LLFIO_V2_NAMESPACE_BEGIN
namespace filesystem = std::experimental::filesystem;
@@ -238,18 +240,21 @@ LLFIO_V2_NAMESPACE_END
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 11000
#error libc++ dropped support for C++ 14 <filesystem> from LLVM 11 onwards. Please enable C++ 17 or later.
#endif
+#define LLFIO_USING_STD_FILESYSTEM 1
#include <filesystem>
LLFIO_V2_NAMESPACE_BEGIN
namespace filesystem = std::filesystem;
LLFIO_V2_NAMESPACE_END
#endif
#elif __PCPP_ALWAYS_TRUE__
+#define LLFIO_USING_EXPERIMENTAL_FILESYSTEM 1
#include <experimental/filesystem>
LLFIO_V2_NAMESPACE_BEGIN
namespace filesystem = std::experimental::filesystem;
LLFIO_V2_NAMESPACE_END
// clang-format on
#elif defined(_MSC_VER)
+#define LLFIO_USING_STD_FILESYSTEM 1
#include <filesystem>
LLFIO_V2_NAMESPACE_BEGIN
namespace filesystem = std::experimental::filesystem;
diff --git a/include/llfio/v2.0/path_view.hpp b/include/llfio/v2.0/path_view.hpp
index dd0f958c..cf02919c 100644
--- a/include/llfio/v2.0/path_view.hpp
+++ b/include/llfio/v2.0/path_view.hpp
@@ -617,6 +617,7 @@ public:
}
private:
+#ifdef LLFIO_USING_STD_FILESYSTEM
template <class CharT> static filesystem::path _path_from_char_array(basic_string_view<CharT> v, filesystem::path::format f)
{
return {v.data(), v.data() + v.size(), f};
@@ -626,9 +627,25 @@ private:
#if(__cplusplus >= 202000 || _HAS_CXX20) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION > 10000 /* approx start of 2020 */)
return filesystem::path(v, f);
#else
- return filesystem::u8path((const char *) v.data(), (const char *) v.data() + v.size(), f);
+ if(f != filesystem::path::format::auto_format)
+ {
+ throw std::runtime_error("UTF-8 path conversion pre-C++20 cannot handle non-auto_format formatting.");
+ }
+ return filesystem::u8path((const char *) v.data(), (const char *) v.data() + v.size());
#endif
}
+#endif
+#ifdef LLFIO_USING_EXPERIMENTAL_FILESYSTEM
+ template <class CharT> static filesystem::path _path_from_char_array(basic_string_view<CharT> v) { return {v.data(), v.data() + v.size()}; }
+ static filesystem::path _path_from_char_array(basic_string_view<char8_t> v)
+ {
+#if(__cplusplus >= 202000 || _HAS_CXX20) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION > 10000 /* approx start of 2020 */)
+ return filesystem::path(v);
+#else
+ return filesystem::u8path((const char *) v.data(), (const char *) v.data() + v.size());
+#endif
+ }
+#endif
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
@@ -680,6 +697,7 @@ public:
filesystem::path path() const
{
return _invoke([&](const auto &v) {
+#ifdef LLFIO_USING_STD_FILESYSTEM
return _path_from_char_array(v, [](format f) -> filesystem::path::format {
switch(f)
{
@@ -691,6 +709,14 @@ public:
return filesystem::path::format::auto_format;
}
}(formatting()));
+#endif
+#ifdef LLFIO_USING_EXPERIMENTAL_FILESYSTEM
+ if(formatting() == generic_format || formatting() == native_format)
+ {
+ throw std::runtime_error("Path conversion with <experimental/filesystem> cannot handle generic_format or native_format formatting.");
+ }
+ return _path_from_char_array(v);
+#endif
});
}
diff --git a/test/tests/pipe_handle.cpp b/test/tests/pipe_handle.cpp
index ff623c90..31bf8172 100644
--- a/test/tests/pipe_handle.cpp
+++ b/test/tests/pipe_handle.cpp
@@ -1,5 +1,5 @@
/* Integration test kernel for whether pipe handles work
-(C) 2019 Niall Douglas <http://www.nedproductions.biz/> (2 commits)
+(C) 2019-2020 Niall Douglas <http://www.nedproductions.biz/> (2 commits)
File Created: Nov 2019
@@ -319,7 +319,7 @@ static inline void TestCoroutinedPipeHandle()
{
// Have the kernel tell me when an i/o completion is ready
auto r = multiplexer->check_for_any_completed_io();
- if(r.value().initiated_ios_completed == 0)
+ if(r.value().initiated_ios_completed == 0 && r.value().initiated_ios_finished == 0)
{
break;
}