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>2018-06-25 11:42:40 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-06-25 11:42:40 +0300
commit6321c6aa08472a02862f0aa1b66cdc4bbf0a891b (patch)
treef7590bc95f8952a2bc2f8dd0caea56c933b1c180
parent4547cc6a15ddb63e0dbe337d166ed9a817c65a92 (diff)
Finally got to implementing and using the status code mixins, and thus bringing AFIO to match the P1031 Low level file i/o draft TS wording.
-rw-r--r--include/afio/revision.hpp6
-rw-r--r--include/afio/v2.0/logging.hpp41
m---------include/afio/v2.0/outcome0
-rw-r--r--include/afio/v2.0/status_code.hpp105
m---------test/kerneltest0
5 files changed, 103 insertions, 49 deletions
diff --git a/include/afio/revision.hpp b/include/afio/revision.hpp
index 215c0b0c..bac272df 100644
--- a/include/afio/revision.hpp
+++ b/include/afio/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 AFIO_PREVIOUS_COMMIT_REF 7b50437109eab2007b6e3cd2b41bb6b0cdd49488
-#define AFIO_PREVIOUS_COMMIT_DATE "2018-06-23 23:19:32 +00:00"
-#define AFIO_PREVIOUS_COMMIT_UNIQUE 7b504371
+#define AFIO_PREVIOUS_COMMIT_REF 4547cc6a15ddb63e0dbe337d166ed9a817c65a92
+#define AFIO_PREVIOUS_COMMIT_DATE "2018-06-24 16:29:15 +00:00"
+#define AFIO_PREVIOUS_COMMIT_UNIQUE 4547cc6a
diff --git a/include/afio/v2.0/logging.hpp b/include/afio/v2.0/logging.hpp
index 851678b7..cd638563 100644
--- a/include/afio/v2.0/logging.hpp
+++ b/include/afio/v2.0/logging.hpp
@@ -290,45 +290,4 @@ AFIO_V2_NAMESPACE_END
#define AFIO_LOG_ALL(inst, message)
#endif
-AFIO_V2_NAMESPACE_BEGIN
-
-#ifndef AFIO_DISABLE_PATHS_IN_FAILURE_INFO
-namespace detail
-{
- template <class Src> inline void append_path_info(Src &src, std::string &ret)
- {
- if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == src._thread_id)
- {
- auto &tls = detail::tls_errored_results();
- const char *path1 = tls.get(src._tls_path_id1), *path2 = tls.get(src._tls_path_id2);
- if(path1 != nullptr)
- {
- ret.append(" [path1 = ");
- ret.append(path1);
- if(path2 != nullptr)
- {
- ret.append(", path2 = ");
- ret.append(path2);
- }
- ret.append("]");
- }
- }
-#if AFIO_LOGGING_LEVEL >= 2
- if(src._log_id != static_cast<uint32_t>(-1))
- {
- if(log().valid(src._log_id))
- {
- ret.append(" [location = ");
- ret.append(location(log()[src._log_id]));
- ret.append("]");
- }
- }
-#endif
- }
-}
-#endif
-
-AFIO_V2_NAMESPACE_END
-
-
#endif
diff --git a/include/afio/v2.0/outcome b/include/afio/v2.0/outcome
-Subproject 3f755a0534a3294a7c396f733a82b48a8715861
+Subproject ef970dccd05d3cff4eb8a6783e8ff2d0f207b19
diff --git a/include/afio/v2.0/status_code.hpp b/include/afio/v2.0/status_code.hpp
index 93185c77..3b86db31 100644
--- a/include/afio/v2.0/status_code.hpp
+++ b/include/afio/v2.0/status_code.hpp
@@ -90,6 +90,64 @@ namespace detail
};
}
+template <class BaseStatusCodeDomain> class error_domain;
+
+AFIO_V2_NAMESPACE_END
+
+// Inject a mixin for our custom status codes
+SYSTEM_ERROR2_NAMESPACE_BEGIN
+namespace mixins
+{
+ template <class Base, class BaseStatusCodeDomain> struct mixin<Base, ::AFIO_V2_NAMESPACE::error_domain<BaseStatusCodeDomain>> : public Base
+ {
+ using Base::Base;
+
+ //! Retrieve the paths associated with this failure
+ std::pair<const char *, const char *> _paths() const noexcept
+ {
+ if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == this->value()._thread_id)
+ {
+ auto &tls = ::AFIO_V2_NAMESPACE::detail::tls_errored_results();
+ const char *path1 = tls.get(this->value()._tls_path_id1);
+ const char *path2 = tls.get(this->value()._tls_path_id2);
+ return {path1, path2};
+ }
+ return {};
+ }
+ //! Retrieve the first path associated with this failure
+ ::AFIO_V2_NAMESPACE::filesystem::path path1() const
+ {
+ if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == this->value()._thread_id)
+ {
+ auto &tls = ::AFIO_V2_NAMESPACE::detail::tls_errored_results();
+ const char *path1 = tls.get(this->value()._tls_path_id1);
+ if(path1 != nullptr)
+ {
+ return ::AFIO_V2_NAMESPACE::filesystem::path(path1);
+ }
+ }
+ return {};
+ }
+ //! Retrieve the second path associated with this failure
+ ::AFIO_V2_NAMESPACE::filesystem::path path2() const
+ {
+ if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == this->value()._thread_id)
+ {
+ auto &tls = ::AFIO_V2_NAMESPACE::detail::tls_errored_results();
+ const char *path2 = tls.get(this->value()._tls_path_id2);
+ if(path2 != nullptr)
+ {
+ return ::AFIO_V2_NAMESPACE::filesystem::path(path2);
+ }
+ }
+ return {};
+ }
+ };
+}
+SYSTEM_ERROR2_NAMESPACE_END
+
+AFIO_V2_NAMESPACE_BEGIN
+
/*! \class error_domain
\brief The SG14 status code domain for errors in AFIO.
*/
@@ -117,8 +175,45 @@ protected:
{
assert(code.domain() == *this);
const auto &v = static_cast<const SYSTEM_ERROR2_NAMESPACE::status_code<error_domain> &>(code); // NOLINT
- std::string ret = _base::_do_message(code).c_str();
- detail::append_path_info(v.value(), ret);
+ // Get the paths for this failure, if any, using the mixins from above
+ auto paths = v._paths();
+ // Get the base message for this failure
+ auto msg = _base::_do_message(code);
+ if(paths.first == nullptr && paths.second == nullptr)
+ {
+ return msg;
+ }
+ std::string ret;
+ try
+ {
+ ret = msg.c_str();
+ if(paths.first != nullptr)
+ {
+ ret.append(" [path1 = ");
+ ret.append(paths.first);
+ if(paths.second != nullptr)
+ {
+ ret.append(", path2 = ");
+ ret.append(paths.second);
+ }
+ ret.append("]");
+ }
+#if AFIO_LOGGING_LEVEL >= 2
+ if(v.value()._log_id != static_cast<uint32_t>(-1))
+ {
+ if(log().valid(v.value()._log_id))
+ {
+ ret.append(" [location = ");
+ ret.append(location(log()[v.value()._log_id]));
+ ret.append("]");
+ }
+ }
+#endif
+ }
+ catch(...)
+ {
+ return string_ref("Failed to retrieve message for status code");
+ }
char *p = (char *) malloc(ret.size() + 1);
if(p == nullptr)
{
@@ -129,9 +224,9 @@ protected:
}
};
-#else
+#else // AFIO_DISABLE_PATHS_IN_FAILURE_INFO
template <class BaseStatusCodeDomain> using error_domain = BaseStatusCodeDomain;
-#endif
+#endif // AFIO_DISABLE_PATHS_IN_FAILURE_INFO
namespace detail
{
@@ -139,7 +234,7 @@ namespace detail
}
//! An erased status code
-using error_code = SYSTEM_ERROR2_NAMESPACE::status_code<SYSTEM_ERROR2_NAMESPACE::erased<detail::error_domain_value_system_code>>;
+using error_code = SYSTEM_ERROR2_NAMESPACE::errored_status_code<SYSTEM_ERROR2_NAMESPACE::erased<detail::error_domain_value_system_code>>;
template <class T> using result = OUTCOME_V2_NAMESPACE::experimental::erased_result<T, error_code>;
diff --git a/test/kerneltest b/test/kerneltest
-Subproject 969cf9a060caf10b918619de1189e17a8670fa1
+Subproject 9aa8bc04b73b5408997c6d9488809cecbe20d7a