Path: blob/main/contrib/llvm-project/libcxx/include/__filesystem/filesystem_error.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H10#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H1112#include <__config>13#include <__filesystem/path.h>14#include <__memory/shared_ptr.h>15#include <__system_error/error_code.h>16#include <__system_error/system_error.h>17#include <__utility/forward.h>18#include <__verbose_abort>19#include <string>2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22# pragma GCC system_header23#endif2425#if _LIBCPP_STD_VER >= 172627_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM2829class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error {30public:31_LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec)32: system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) {33__create_what(0);34}3536_LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, error_code __ec)37: system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, path())) {38__create_what(1);39}4041_LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, const path& __p2, error_code __ec)42: system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, __p2)) {43__create_what(2);44}4546_LIBCPP_HIDE_FROM_ABI const path& path1() const noexcept { return __storage_->__p1_; }4748_LIBCPP_HIDE_FROM_ABI const path& path2() const noexcept { return __storage_->__p2_; }4950_LIBCPP_HIDE_FROM_ABI filesystem_error(const filesystem_error&) = default;51~filesystem_error() override; // key function5253_LIBCPP_HIDE_FROM_ABI_VIRTUAL54const char* what() const noexcept override { return __storage_->__what_.c_str(); }5556void __create_what(int __num_paths);5758private:59struct _LIBCPP_HIDDEN _Storage {60_LIBCPP_HIDE_FROM_ABI _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}6162path __p1_;63path __p2_;64string __what_;65};66shared_ptr<_Storage> __storage_;67};6869# ifndef _LIBCPP_HAS_NO_EXCEPTIONS70template <class... _Args>71_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void72__throw_filesystem_error(_Args&&... __args) {73throw filesystem_error(std::forward<_Args>(__args)...);74}75# else76template <class... _Args>77_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void78__throw_filesystem_error(_Args&&...) {79_LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");80}81# endif8283_LIBCPP_END_NAMESPACE_FILESYSTEM8485#endif // _LIBCPP_STD_VER >= 178687#endif // _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H888990