Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:27

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___FILESYSTEM_FILESYSTEM_ERROR_H
0011 #define _LIBCPP___CXX03___FILESYSTEM_FILESYSTEM_ERROR_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__filesystem/path.h>
0015 #include <__cxx03/__memory/shared_ptr.h>
0016 #include <__cxx03/__system_error/error_code.h>
0017 #include <__cxx03/__system_error/system_error.h>
0018 #include <__cxx03/__utility/forward.h>
0019 #include <__cxx03/__verbose_abort>
0020 #include <__cxx03/string>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 #if _LIBCPP_STD_VER >= 17
0027 
0028 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
0029 
0030 class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error {
0031 public:
0032   _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec)
0033       : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) {
0034     __create_what(0);
0035   }
0036 
0037   _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, error_code __ec)
0038       : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, path())) {
0039     __create_what(1);
0040   }
0041 
0042   _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, const path& __p2, error_code __ec)
0043       : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, __p2)) {
0044     __create_what(2);
0045   }
0046 
0047   _LIBCPP_HIDE_FROM_ABI const path& path1() const noexcept { return __storage_->__p1_; }
0048 
0049   _LIBCPP_HIDE_FROM_ABI const path& path2() const noexcept { return __storage_->__p2_; }
0050 
0051   _LIBCPP_HIDE_FROM_ABI filesystem_error(const filesystem_error&) = default;
0052   ~filesystem_error() override; // key function
0053 
0054   _LIBCPP_HIDE_FROM_ABI_VIRTUAL
0055   const char* what() const noexcept override { return __storage_->__what_.c_str(); }
0056 
0057   void __create_what(int __num_paths);
0058 
0059 private:
0060   struct _LIBCPP_HIDDEN _Storage {
0061     _LIBCPP_HIDE_FROM_ABI _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
0062 
0063     path __p1_;
0064     path __p2_;
0065     string __what_;
0066   };
0067   shared_ptr<_Storage> __storage_;
0068 };
0069 
0070 #  ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0071 template <class... _Args>
0072 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
0073 __throw_filesystem_error(_Args&&... __args) {
0074   throw filesystem_error(std::forward<_Args>(__args)...);
0075 }
0076 #  else
0077 template <class... _Args>
0078 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
0079 __throw_filesystem_error(_Args&&...) {
0080   _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");
0081 }
0082 #  endif
0083 
0084 _LIBCPP_END_NAMESPACE_FILESYSTEM
0085 
0086 #endif // _LIBCPP_STD_VER >= 17
0087 
0088 #endif // _LIBCPP___CXX03___FILESYSTEM_FILESYSTEM_ERROR_H