File indexing completed on 2025-07-12 08:10:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_FILESYSTEM_FILE_STATUS_HPP
0017 #define BOOST_FILESYSTEM_FILE_STATUS_HPP
0018
0019 #include <boost/filesystem/config.hpp>
0020 #include <boost/detail/bitmask.hpp>
0021
0022 #include <boost/filesystem/detail/header.hpp> // must be the last #include
0023
0024
0025
0026 namespace boost {
0027 namespace filesystem {
0028
0029
0030
0031
0032
0033 enum file_type
0034 {
0035 status_error,
0036 file_not_found,
0037 regular_file,
0038 directory_file,
0039
0040 symlink_file,
0041 block_file,
0042 character_file,
0043 fifo_file,
0044 socket_file,
0045 reparse_file,
0046 type_unknown
0047
0048 };
0049
0050
0051
0052
0053
0054 enum perms
0055 {
0056 no_perms = 0,
0057
0058
0059
0060
0061
0062
0063 owner_read = 0400,
0064 owner_write = 0200,
0065 owner_exe = 0100,
0066 owner_all = 0700,
0067
0068 group_read = 040,
0069 group_write = 020,
0070 group_exe = 010,
0071 group_all = 070,
0072
0073 others_read = 04,
0074 others_write = 02,
0075 others_exe = 01,
0076 others_all = 07,
0077
0078 all_all = 0777,
0079
0080
0081
0082 set_uid_on_exe = 04000,
0083 set_gid_on_exe = 02000,
0084 sticky_bit = 01000,
0085
0086
0087
0088
0089
0090
0091 perms_mask = 07777,
0092
0093 perms_not_known = 0xFFFF,
0094
0095
0096
0097 add_perms = 0x1000,
0098 remove_perms = 0x2000,
0099
0100
0101
0102
0103 symlink_perms = 0x4000,
0104
0105
0106 _detail_extend_perms_32_1 = 0x7fffffff,
0107 _detail_extend_perms_32_2 = -0x7fffffff - 1
0108 };
0109
0110 BOOST_BITMASK(perms)
0111
0112
0113
0114
0115
0116 class file_status
0117 {
0118 public:
0119 BOOST_CONSTEXPR file_status() noexcept :
0120 m_value(status_error),
0121 m_perms(perms_not_known)
0122 {
0123 }
0124 explicit BOOST_CONSTEXPR file_status(file_type v) noexcept :
0125 m_value(v),
0126 m_perms(perms_not_known)
0127 {
0128 }
0129 BOOST_CONSTEXPR file_status(file_type v, perms prms) noexcept :
0130 m_value(v),
0131 m_perms(prms)
0132 {
0133 }
0134
0135 BOOST_CONSTEXPR file_status(file_status const& rhs) noexcept :
0136 m_value(rhs.m_value),
0137 m_perms(rhs.m_perms)
0138 {
0139 }
0140 BOOST_CXX14_CONSTEXPR file_status& operator=(file_status const& rhs) noexcept
0141 {
0142 m_value = rhs.m_value;
0143 m_perms = rhs.m_perms;
0144 return *this;
0145 }
0146
0147
0148 BOOST_CONSTEXPR file_status(file_status&& rhs) noexcept :
0149 m_value(static_cast< file_type&& >(rhs.m_value)),
0150 m_perms(static_cast< perms&& >(rhs.m_perms))
0151 {
0152 }
0153 BOOST_CXX14_CONSTEXPR file_status& operator=(file_status&& rhs) noexcept
0154 {
0155 m_value = static_cast< file_type&& >(rhs.m_value);
0156 m_perms = static_cast< perms&& >(rhs.m_perms);
0157 return *this;
0158 }
0159
0160
0161 BOOST_CONSTEXPR file_type type() const noexcept { return m_value; }
0162 BOOST_CONSTEXPR perms permissions() const noexcept { return m_perms; }
0163
0164
0165 BOOST_CXX14_CONSTEXPR void type(file_type v) noexcept { m_value = v; }
0166 BOOST_CXX14_CONSTEXPR void permissions(perms prms) noexcept { m_perms = prms; }
0167
0168 BOOST_CONSTEXPR bool operator==(file_status const& rhs) const noexcept
0169 {
0170 return type() == rhs.type() && permissions() == rhs.permissions();
0171 }
0172 BOOST_CONSTEXPR bool operator!=(file_status const& rhs) const noexcept
0173 {
0174 return !(*this == rhs);
0175 }
0176
0177 private:
0178 file_type m_value;
0179 perms m_perms;
0180 };
0181
0182 inline BOOST_CONSTEXPR bool type_present(file_status f) noexcept
0183 {
0184 return f.type() != filesystem::status_error;
0185 }
0186
0187 inline BOOST_CONSTEXPR bool permissions_present(file_status f) noexcept
0188 {
0189 return f.permissions() != filesystem::perms_not_known;
0190 }
0191
0192 inline BOOST_CONSTEXPR bool status_known(file_status f) noexcept
0193 {
0194 return filesystem::type_present(f) && filesystem::permissions_present(f);
0195 }
0196
0197 inline BOOST_CONSTEXPR bool exists(file_status f) noexcept
0198 {
0199 return f.type() != filesystem::status_error && f.type() != filesystem::file_not_found;
0200 }
0201
0202 inline BOOST_CONSTEXPR bool is_regular_file(file_status f) noexcept
0203 {
0204 return f.type() == filesystem::regular_file;
0205 }
0206
0207 inline BOOST_CONSTEXPR bool is_directory(file_status f) noexcept
0208 {
0209 return f.type() == filesystem::directory_file;
0210 }
0211
0212 inline BOOST_CONSTEXPR bool is_symlink(file_status f) noexcept
0213 {
0214 return f.type() == filesystem::symlink_file;
0215 }
0216
0217 inline BOOST_CONSTEXPR bool is_block_file(file_status f) noexcept
0218 {
0219 return f.type() == filesystem::block_file;
0220 }
0221
0222 inline BOOST_CONSTEXPR bool is_character_file(file_status f) noexcept
0223 {
0224 return f.type() == filesystem::character_file;
0225 }
0226
0227 inline BOOST_CONSTEXPR bool is_fifo(file_status f) noexcept
0228 {
0229 return f.type() == filesystem::fifo_file;
0230 }
0231
0232 inline BOOST_CONSTEXPR bool is_socket(file_status f) noexcept
0233 {
0234 return f.type() == filesystem::socket_file;
0235 }
0236
0237 inline BOOST_CONSTEXPR bool is_reparse_file(file_status f) noexcept
0238 {
0239 return f.type() == filesystem::reparse_file;
0240 }
0241
0242 inline BOOST_CONSTEXPR bool is_other(file_status f) noexcept
0243 {
0244 return filesystem::exists(f) && !filesystem::is_regular_file(f) && !filesystem::is_directory(f) && !filesystem::is_symlink(f);
0245 }
0246
0247 }
0248 }
0249
0250 #include <boost/filesystem/detail/footer.hpp> // pops abi_prefix.hpp pragmas
0251
0252 #endif