1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H
11#define _LIBCPP___FILESYSTEM_FILE_STATUS_H
12
13#include <__config>
14#include <__filesystem/file_type.h>
15#include <__filesystem/perms.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER >= 17
22
23_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
24
25class file_status {
26public:
27 // constructors
28 file_status() noexcept : file_status(file_type::none) {}
29 explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept : __ft_(__ft), __prms_(__prms) {}
30
31 file_status(const file_status&) noexcept = default;
32 file_status(file_status&&) noexcept = default;
33
34 ~file_status() {}
35
36 file_status& operator=(const file_status&) noexcept = default;
37 file_status& operator=(file_status&&) noexcept = default;
38
39 // observers
40 [[nodiscard]] file_type type() const noexcept { return __ft_; }
41
42 [[nodiscard]] perms permissions() const noexcept { return __prms_; }
43
44 // modifiers
45 void type(file_type __ft) noexcept { __ft_ = __ft; }
46
47 void permissions(perms __p) noexcept { __prms_ = __p; }
48
49# if _LIBCPP_STD_VER >= 20
50
51 friend bool operator==(const file_status& __lhs, const file_status& __rhs) noexcept {
52 return __lhs.type() == __rhs.type() && __lhs.permissions() == __rhs.permissions();
53 }
54
55# endif
56
57private:
58 file_type __ft_;
59 perms __prms_;
60};
61
62_LIBCPP_END_NAMESPACE_FILESYSTEM
63
64#endif // _LIBCPP_STD_VER >= 17
65
66#endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H
67