File indexing completed on 2025-01-18 09:30:51
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 #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
0037 status_unknown = status_error,
0038 #endif
0039 file_not_found,
0040 regular_file,
0041 directory_file,
0042
0043 symlink_file,
0044 block_file,
0045 character_file,
0046 fifo_file,
0047 socket_file,
0048 reparse_file,
0049 type_unknown
0050
0051 };
0052
0053
0054
0055
0056
0057 enum perms
0058 {
0059 no_perms = 0,
0060
0061
0062
0063
0064
0065
0066 owner_read = 0400,
0067 owner_write = 0200,
0068 owner_exe = 0100,
0069 owner_all = 0700,
0070
0071 group_read = 040,
0072 group_write = 020,
0073 group_exe = 010,
0074 group_all = 070,
0075
0076 others_read = 04,
0077 others_write = 02,
0078 others_exe = 01,
0079 others_all = 07,
0080
0081 all_all = 0777,
0082
0083
0084
0085 set_uid_on_exe = 04000,
0086 set_gid_on_exe = 02000,
0087 sticky_bit = 01000,
0088
0089
0090
0091
0092
0093
0094 perms_mask = 07777,
0095
0096 perms_not_known = 0xFFFF,
0097
0098
0099
0100 add_perms = 0x1000,
0101 remove_perms = 0x2000,
0102
0103
0104
0105
0106 symlink_perms = 0x4000,
0107
0108
0109 _detail_extend_perms_32_1 = 0x7fffffff,
0110 _detail_extend_perms_32_2 = -0x7fffffff - 1
0111 };
0112
0113 BOOST_BITMASK(perms)
0114
0115
0116
0117
0118
0119 class file_status
0120 {
0121 public:
0122 BOOST_CONSTEXPR file_status() BOOST_NOEXCEPT :
0123 m_value(status_error),
0124 m_perms(perms_not_known)
0125 {
0126 }
0127 explicit BOOST_CONSTEXPR file_status(file_type v) BOOST_NOEXCEPT :
0128 m_value(v),
0129 m_perms(perms_not_known)
0130 {
0131 }
0132 BOOST_CONSTEXPR file_status(file_type v, perms prms) BOOST_NOEXCEPT :
0133 m_value(v),
0134 m_perms(prms)
0135 {
0136 }
0137
0138
0139
0140
0141
0142 BOOST_CONSTEXPR file_status(file_status const& rhs) BOOST_NOEXCEPT :
0143 m_value(rhs.m_value),
0144 m_perms(rhs.m_perms)
0145 {
0146 }
0147 BOOST_CXX14_CONSTEXPR file_status& operator=(file_status const& rhs) BOOST_NOEXCEPT
0148 {
0149 m_value = rhs.m_value;
0150 m_perms = rhs.m_perms;
0151 return *this;
0152 }
0153
0154 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0155
0156 BOOST_CONSTEXPR file_status(file_status&& rhs) BOOST_NOEXCEPT :
0157 m_value(static_cast< file_type&& >(rhs.m_value)),
0158 m_perms(static_cast< perms&& >(rhs.m_perms))
0159 {
0160 }
0161 BOOST_CXX14_CONSTEXPR file_status& operator=(file_status&& rhs) BOOST_NOEXCEPT
0162 {
0163 m_value = static_cast< file_type&& >(rhs.m_value);
0164 m_perms = static_cast< perms&& >(rhs.m_perms);
0165 return *this;
0166 }
0167 #endif
0168
0169
0170 BOOST_CONSTEXPR file_type type() const BOOST_NOEXCEPT { return m_value; }
0171 BOOST_CONSTEXPR perms permissions() const BOOST_NOEXCEPT { return m_perms; }
0172
0173
0174 BOOST_CXX14_CONSTEXPR void type(file_type v) BOOST_NOEXCEPT { m_value = v; }
0175 BOOST_CXX14_CONSTEXPR void permissions(perms prms) BOOST_NOEXCEPT { m_perms = prms; }
0176
0177 BOOST_CONSTEXPR bool operator==(file_status const& rhs) const BOOST_NOEXCEPT
0178 {
0179 return type() == rhs.type() && permissions() == rhs.permissions();
0180 }
0181 BOOST_CONSTEXPR bool operator!=(file_status const& rhs) const BOOST_NOEXCEPT
0182 {
0183 return !(*this == rhs);
0184 }
0185
0186 private:
0187 file_type m_value;
0188 perms m_perms;
0189 };
0190
0191 inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT
0192 {
0193 return f.type() != filesystem::status_error;
0194 }
0195
0196 inline BOOST_CONSTEXPR bool permissions_present(file_status f) BOOST_NOEXCEPT
0197 {
0198 return f.permissions() != filesystem::perms_not_known;
0199 }
0200
0201 inline BOOST_CONSTEXPR bool status_known(file_status f) BOOST_NOEXCEPT
0202 {
0203 return filesystem::type_present(f) && filesystem::permissions_present(f);
0204 }
0205
0206 inline BOOST_CONSTEXPR bool exists(file_status f) BOOST_NOEXCEPT
0207 {
0208 return f.type() != filesystem::status_error && f.type() != filesystem::file_not_found;
0209 }
0210
0211 inline BOOST_CONSTEXPR bool is_regular_file(file_status f) BOOST_NOEXCEPT
0212 {
0213 return f.type() == filesystem::regular_file;
0214 }
0215
0216 inline BOOST_CONSTEXPR bool is_directory(file_status f) BOOST_NOEXCEPT
0217 {
0218 return f.type() == filesystem::directory_file;
0219 }
0220
0221 inline BOOST_CONSTEXPR bool is_symlink(file_status f) BOOST_NOEXCEPT
0222 {
0223 return f.type() == filesystem::symlink_file;
0224 }
0225
0226 inline BOOST_CONSTEXPR bool is_block_file(file_status f) BOOST_NOEXCEPT
0227 {
0228 return f.type() == filesystem::block_file;
0229 }
0230
0231 inline BOOST_CONSTEXPR bool is_character_file(file_status f) BOOST_NOEXCEPT
0232 {
0233 return f.type() == filesystem::character_file;
0234 }
0235
0236 inline BOOST_CONSTEXPR bool is_fifo(file_status f) BOOST_NOEXCEPT
0237 {
0238 return f.type() == filesystem::fifo_file;
0239 }
0240
0241 inline BOOST_CONSTEXPR bool is_socket(file_status f) BOOST_NOEXCEPT
0242 {
0243 return f.type() == filesystem::socket_file;
0244 }
0245
0246 inline BOOST_CONSTEXPR bool is_reparse_file(file_status f) BOOST_NOEXCEPT
0247 {
0248 return f.type() == filesystem::reparse_file;
0249 }
0250
0251 inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT
0252 {
0253 return filesystem::exists(f) && !filesystem::is_regular_file(f) && !filesystem::is_directory(f) && !filesystem::is_symlink(f);
0254 }
0255
0256 #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
0257 BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
0258 inline bool is_regular(file_status f) BOOST_NOEXCEPT
0259 {
0260 return filesystem::is_regular_file(f);
0261 }
0262 #endif
0263
0264 }
0265 }
0266
0267 #include <boost/filesystem/detail/footer.hpp> // pops abi_prefix.hpp pragmas
0268
0269 #endif