diff --git a/doc/reference.html b/doc/reference.html
index 9fed19f..1cd5564 100644
--- a/doc/reference.html
+++ b/doc/reference.html
@@ -131,14 +131,20 @@
exists
equivalent
file_size
- hard_link_count
- initial_path
- is_directory
- is_empty
+ hard_link_count
- is_other
+
+ initial_path
+ is_block_file
+ is_character_file
+ is_directory
+ is_empty
+ is_fifo
+ is_other
is_regular_file
+ is_reparse_file
+ is_socket
is_symlink
last_write_time
permissions
@@ -893,6 +899,16 @@ nothing else."
system::error_code& ec
);
+ bool is_block_file(file_status s) noexcept;
+ bool is_block_file(const path& p);
+ bool is_block_file(const path& p,
+ system::error_code& ec) noexcept;
+
+ bool is_character_file(file_status s) noexcept;
+ bool is_character_file(const path& p);
+ bool is_character_file(const path& p,
+ system::error_code& ec) noexcept;
+
bool is_directory(file_status s) noexcept;
bool is_directory(const path& p);
bool is_directory(const path& p,
@@ -901,6 +917,11 @@ nothing else."
bool is_empty(const path& p);
bool is_empty(const path& p, system::error_code& ec);
+ bool is_fifo(file_status s) noexcept;
+ bool is_fifo(const path& p);
+ bool is_fifo(const path& p,
+ system::error_code& ec) noexcept;
+
bool is_other(file_status s) noexcept;
bool is_other(const path& p,);
bool is_other(const path& p, system::error_code& ec) noexcept;
@@ -910,6 +931,16 @@ nothing else."
bool is_regular_file(const path& p,
system::error_code& ec) noexcept;
+ bool is_reparse_file(file_status s) noexcept;
+ bool is_reparse_file(const path& p);
+ bool is_reparse_file(const path& p,
+ system::error_code& ec) noexcept;
+
+ bool is_socket(file_status s) noexcept;
+ bool is_socket(const path& p);
+ bool is_socket(const path& p,
+ system::error_code& ec) noexcept;
+
bool is_symlink(file_status s noexcept);
bool is_symlink(const path& p);
bool is_symlink(const path& p, system::error_code& ec) noexcept;
@@ -2583,6 +2614,16 @@ and permissions of a file.
bool is_directory(system::error_code& ec) const;
bool is_symlink() const;
bool is_symlink(system::error_code& ec) const;
+ bool is_block_file() const;
+ bool is_block_file(system::error_code& ec) const;
+ bool is_character_file() const;
+ bool is_character_file(system::error_code& ec) const;
+ bool is_fifo() const;
+ bool is_fifo(system::error_code& ec) const;
+ bool is_socket() const;
+ bool is_socket(system::error_code& ec) const;
+ bool is_reparse_file() const;
+ bool is_reparse_file(system::error_code& ec) const;
bool is_other() const;
bool is_other(system::error_code& ec) const;
@@ -2785,6 +2826,31 @@ bool is_symlink(system::error_code& ec) const;
+Effects: Equivalent to
is_symlink(symlink_status())
oris_symlink(symlink_status(ec))
, respectively.
bool is_block_file() const; +bool is_block_file(system::error_code& ec) const;+
++Effects: Equivalent to
+is_block_file(status())
oris_block_file(status(ec))
, respectively.
bool is_character_file() const; +bool is_character_file(system::error_code& ec) const;+
++Effects: Equivalent to
+is_character_file(status())
oris_character_file(status(ec))
, respectively.
bool is_fifo() const; +bool is_fifo(system::error_code& ec) const;+
++Effects: Equivalent to
+is_fifo(status())
oris_fifo(status(ec))
, respectively.
bool is_socket() const; +bool is_socket(system::error_code& ec) const;+
++Effects: Equivalent to
+is_socket(status())
oris_socket(status(ec))
, respectively.
bool is_reparse_file() const; +bool is_reparse_file(system::error_code& ec) const;+
+Effects: Equivalent to
+is_reparse_file(symlink_status())
oris_reparse_file(symlink_status(ec))
, respectively.
bool is_other() const; bool is_other(system::error_code& ec) const;
@@ -3496,6 +3562,30 @@ const path& initial_path(system::error_cod
main(). —end note]
Throws: For the first call, as specified in Error reporting. Subsequent calls throw nothing.
+bool is_block_file
(file_status s) noexcept;
+++Returns:
+s.type() == block_file
bool is_block_file(const path& p);
+bool is_block_file(const path& p, system::error_code& ec) noexcept;
+++Returns:
+is_block_file(status(p))
oris_block_file(status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
+filesystem_error
; the overload with argumentec
throws +nothing.
bool is_character_file
(file_status s) noexcept;
+++Returns:
+s.type() == character_file
bool is_character_file(const path& p);
+bool is_character_file(const path& p, system::error_code& ec) noexcept;
++Returns:
+is_character_file(status(p))
oris_character_file(status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
+filesystem_error
; the overload with argumentec
throws +nothing.
bool is_directory
(file_status s) noexcept;
-Returns:
@@ -3504,8 +3594,8 @@ const path& initial_path(s.type() == directory_file
system::error_cod bool is_directory(const path& p, system::error_code& ec) noexcept;
Returns:
-is_directory(status(p))
oris_directory(status(p, ec))
, - respectively.Throws:
+filesystem_error
; overload witherror_code&
throws + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
filesystem_error
; the overload with argumentec
throws nothing.bool is_empty(const path& p); @@ -3516,20 +3606,17 @@ bool is_empty(const path& p, system::error_code& ? directory_iterator(p) == directory_iterator()
: file_size(p) == 0;
bool is_regular_file
(file_status s) noexcept;
+bool is_fifo
(file_status s) noexcept;
--Returns:
+s.type() == regular_file
Returns:
s.type() == fifo_file
bool is_regular_file(const path& p);
+bool is_fifo(const path& p);
+bool is_fifo(const path& p, system::error_code& ec) noexcept;
--Returns:
-is_regular_file(status(p))
.Throws:
-filesystem_error
ifstatus(p)
would throwfilesystem_error.
bool is_regular_file(const path& p, system::error_code& ec) noexcept;
--Effects: Sets
-ec
as if bystatus(p, ec)
. [Note:status_error
,file_not_found
andtype_unknown
cases setec
to error values. To distinguish between cases, call thestatus
function directly. —end - note]Returns:
+is_regular_file(status(p, ec))
.Returns:
+is_fifo(status(p))
oris_fifo(status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
filesystem_error
; the overload with argumentec
throws +nothing.
bool is_other(file_status s) noexcept;
@@ -3539,8 +3626,44 @@ bool is_empty(const path& p, system::error_code& bool is_other(const path& p, system::error_code& ec) noexcept;+Returns:
-is_other(status(p))
oris_other(status(p, ec))
, - respectively.Throws:
+filesystem_error
; overload witherror_code&
throws + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
+filesystem_error
; the overload with argumentec
throws + nothing.bool+is_regular_file
(file_status s) noexcept;++Returns:
+s.type() == regular_file
+bool is_regular_file(const path& p); +bool is_regular_file(const path& p, system::error_code& ec) noexcept;
++Returns:
+is_regular_file(status(p))
oris_regular_file(status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
+filesystem_error
; the overload with argumentec
throws + nothing.bool is_reparse_file(file_status s) noexcept;+++Returns:
+s.type() == reparse_file
+bool is_reparse_file(const path& p); +bool is_reparse_file(const path& p, system::error_code& ec) noexcept;
++Returns:
+is_reparse_file(symlink_status(p))
oris_reparse_file(symlink_status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
+filesystem_error
; the overload with argumentec
throws + nothing.bool is_socket(file_status s) noexcept;+++Returns:
+s.type() == socket_file
+bool is_socket(const path& p); +bool is_socket(const path& p, system::error_code& ec) noexcept;
+Returns:
+is_socket(status(p))
oris_socket(status(p, ec))
, + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
filesystem_error
; the overload with argumentec
throws nothing.bool is_symlink(file_status s) noexcept;@@ -3551,8 +3674,8 @@ bool is_other(const path& p, system::error_code& bool is_symlink(const path& p, system::error_code& ec) noexcept;Returns:
-is_symlink(symlink_status(p))
oris_symlink(symlink_status(p, ec))
, - respectively.Throws:
+filesystem_error
; overload witherror_code&
throws + respectively. The overload with argumentec
returnsfalse
if an error occurs.Throws:
filesystem_error
; the overload with argumentec
throws nothing.std::time_t creation_time(const path& p); diff --git a/doc/release_history.html b/doc/release_history.html index 734fc8e..e792b70 100644 --- a/doc/release_history.html +++ b/doc/release_history.html @@ -45,6 +45,7 @@
v4: directory_entry
constructors and modifiers that initialize or modify the path now automatically callrefresh
. This may result in errors that were not indicated before and in v3, if querying the filesystem for file statuses fails (e.g. if the file does not exist). This new behavior is similar to std::filesystem.v4: directory_entry
constructors and methods takingfile_status
parameters are removed. Users are recommended to remove these arguments and rely ondirectory_entry
callingrefresh
internally.Added +directory_entry
member methods for checking the file type of the file, similar to std::filesystem.Added more methods for testing file status: is_block_file
,is_character_file
,is_fifo
,is_socket
andis_reparse_file
.recursive_directory_iterator
is now more likely to reuse information about the file type that is obtained during filesystem iteration. This may improve performance. (#288)File streams defined in boost/filesystem/fstream.hpp
are now movable, if the standard library file streams are. (#280)Generic diff --git a/include/boost/filesystem/directory.hpp b/include/boost/filesystem/directory.hpp index 6687f2a..2afcfb6 100644 --- a/include/boost/filesystem/directory.hpp +++ b/include/boost/filesystem/directory.hpp @@ -278,6 +278,56 @@ public: return this->symlink_file_type(ec) == filesystem::symlink_file; } + bool is_block_file() const + { + return this->file_type() == filesystem::block_file; + } + + bool is_block_file(system::error_code& ec) const BOOST_NOEXCEPT + { + return this->file_type(ec) == filesystem::block_file; + } + + bool is_character_file() const + { + return this->file_type() == filesystem::character_file; + } + + bool is_character_file(system::error_code& ec) const BOOST_NOEXCEPT + { + return this->file_type(ec) == filesystem::character_file; + } + + bool is_fifo() const + { + return this->file_type() == filesystem::fifo_file; + } + + bool is_fifo(system::error_code& ec) const BOOST_NOEXCEPT + { + return this->file_type(ec) == filesystem::fifo_file; + } + + bool is_socket() const + { + return this->file_type() == filesystem::socket_file; + } + + bool is_socket(system::error_code& ec) const BOOST_NOEXCEPT + { + return this->file_type(ec) == filesystem::socket_file; + } + + bool is_reparse_file() const + { + return this->symlink_file_type() == filesystem::reparse_file; + } + + bool is_reparse_file(system::error_code& ec) const BOOST_NOEXCEPT + { + return this->symlink_file_type(ec) == filesystem::reparse_file; + } + bool is_other() const { filesystem::file_type ft = this->file_type(); @@ -418,66 +468,142 @@ inline file_status status(directory_entry const& e) { return e.status(); } + inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { return e.status(ec); } + +inline file_status symlink_status(directory_entry const& e) +{ + return e.symlink_status(); +} + +inline file_status symlink_status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.symlink_status(ec); +} + inline bool type_present(directory_entry const& e) { - return filesystem::type_present(e.status()); + return e.file_type() != filesystem::status_error; } + inline bool type_present(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::type_present(e.status(ec)); + return e.file_type(ec) != filesystem::status_error; } + inline bool status_known(directory_entry const& e) { return filesystem::status_known(e.status()); } + inline bool status_known(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::status_known(e.status(ec)); } + inline bool exists(directory_entry const& e) { - return filesystem::exists(e.status()); + return e.exists(); } + inline bool exists(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::exists(e.status(ec)); + return e.exists(ec); } + inline bool is_regular_file(directory_entry const& e) { - return filesystem::is_regular_file(e.status()); + return e.is_regular_file(); } + inline bool is_regular_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::is_regular_file(e.status(ec)); + return e.is_regular_file(ec); } + inline bool is_directory(directory_entry const& e) { - return filesystem::is_directory(e.status()); + return e.is_directory(); } + inline bool is_directory(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::is_directory(e.status(ec)); + return e.is_directory(ec); } + inline bool is_symlink(directory_entry const& e) { - return filesystem::is_symlink(e.symlink_status()); + return e.is_symlink(); } + inline bool is_symlink(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::is_symlink(e.symlink_status(ec)); + return e.is_symlink(ec); } + +inline bool is_block_file(directory_entry const& e) +{ + return e.is_block_file(); +} + +inline bool is_block_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.is_block_file(ec); +} + +inline bool is_character_file(directory_entry const& e) +{ + return e.is_character_file(); +} + +inline bool is_character_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.is_character_file(ec); +} + +inline bool is_fifo(directory_entry const& e) +{ + return e.is_fifo(); +} + +inline bool is_fifo(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.is_fifo(ec); +} + +inline bool is_socket(directory_entry const& e) +{ + return e.is_socket(); +} + +inline bool is_socket(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.is_socket(ec); +} + +inline bool is_reparse_file(directory_entry const& e) +{ + return e.is_reparse_file(); +} + +inline bool is_reparse_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT +{ + return e.is_reparse_file(ec); +} + inline bool is_other(directory_entry const& e) { - return filesystem::is_other(e.status()); + return e.is_other(); } + inline bool is_other(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT { - return filesystem::is_other(e.status(ec)); + return e.is_other(ec); } + #ifndef BOOST_FILESYSTEM_NO_DEPRECATED BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead") inline bool is_regular(directory_entry const& e) diff --git a/include/boost/filesystem/file_status.hpp b/include/boost/filesystem/file_status.hpp index c4f944c..fb36240 100644 --- a/include/boost/filesystem/file_status.hpp +++ b/include/boost/filesystem/file_status.hpp @@ -155,13 +155,13 @@ public: // Note: std::move is not constexpr in C++11, that's why we're not using it here BOOST_CONSTEXPR file_status(file_status&& rhs) BOOST_NOEXCEPT : m_value(static_cast< file_type&& >(rhs.m_value)), - m_perms(static_cast< enum perms&& >(rhs.m_perms)) + m_perms(static_cast< perms&& >(rhs.m_perms)) { } BOOST_CXX14_CONSTEXPR file_status& operator=(file_status&& rhs) BOOST_NOEXCEPT { m_value = static_cast< file_type&& >(rhs.m_value); - m_perms = static_cast< enum perms&& >(rhs.m_perms); + m_perms = static_cast< perms&& >(rhs.m_perms); return *this; } #endif @@ -174,28 +174,28 @@ public: BOOST_CXX14_CONSTEXPR void type(file_type v) BOOST_NOEXCEPT { m_value = v; } BOOST_CXX14_CONSTEXPR void permissions(perms prms) BOOST_NOEXCEPT { m_perms = prms; } - BOOST_CONSTEXPR bool operator==(const file_status& rhs) const BOOST_NOEXCEPT + BOOST_CONSTEXPR bool operator==(file_status const& rhs) const BOOST_NOEXCEPT { return type() == rhs.type() && permissions() == rhs.permissions(); } - BOOST_CONSTEXPR bool operator!=(const file_status& rhs) const BOOST_NOEXCEPT + BOOST_CONSTEXPR bool operator!=(file_status const& rhs) const BOOST_NOEXCEPT { return !(*this == rhs); } private: file_type m_value; - enum perms m_perms; + perms m_perms; }; inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT { - return f.type() != status_error; + return f.type() != filesystem::status_error; } inline BOOST_CONSTEXPR bool permissions_present(file_status f) BOOST_NOEXCEPT { - return f.permissions() != perms_not_known; + return f.permissions() != filesystem::perms_not_known; } inline BOOST_CONSTEXPR bool status_known(file_status f) BOOST_NOEXCEPT @@ -205,22 +205,47 @@ inline BOOST_CONSTEXPR bool status_known(file_status f) BOOST_NOEXCEPT inline BOOST_CONSTEXPR bool exists(file_status f) BOOST_NOEXCEPT { - return f.type() != status_error && f.type() != file_not_found; + return f.type() != filesystem::status_error && f.type() != filesystem::file_not_found; } inline BOOST_CONSTEXPR bool is_regular_file(file_status f) BOOST_NOEXCEPT { - return f.type() == regular_file; + return f.type() == filesystem::regular_file; } inline BOOST_CONSTEXPR bool is_directory(file_status f) BOOST_NOEXCEPT { - return f.type() == directory_file; + return f.type() == filesystem::directory_file; } inline BOOST_CONSTEXPR bool is_symlink(file_status f) BOOST_NOEXCEPT { - return f.type() == symlink_file; + return f.type() == filesystem::symlink_file; +} + +inline BOOST_CONSTEXPR bool is_block_file(file_status f) BOOST_NOEXCEPT +{ + return f.type() == filesystem::block_file; +} + +inline BOOST_CONSTEXPR bool is_character_file(file_status f) BOOST_NOEXCEPT +{ + return f.type() == filesystem::character_file; +} + +inline BOOST_CONSTEXPR bool is_fifo(file_status f) BOOST_NOEXCEPT +{ + return f.type() == filesystem::fifo_file; +} + +inline BOOST_CONSTEXPR bool is_socket(file_status f) BOOST_NOEXCEPT +{ + return f.type() == filesystem::socket_file; +} + +inline BOOST_CONSTEXPR bool is_reparse_file(file_status f) BOOST_NOEXCEPT +{ + return f.type() == filesystem::reparse_file; } inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT diff --git a/include/boost/filesystem/operations.hpp b/include/boost/filesystem/operations.hpp index 112dba2..4f72dcb 100644 --- a/include/boost/filesystem/operations.hpp +++ b/include/boost/filesystem/operations.hpp @@ -193,52 +193,102 @@ inline file_status symlink_status(path const& p, system::error_code& ec) inline bool exists(path const& p) { - return exists(detail::status(p)); + return filesystem::exists(detail::status(p)); } inline bool exists(path const& p, system::error_code& ec) { - return exists(detail::status(p, &ec)); -} - -inline bool is_directory(path const& p) -{ - return is_directory(detail::status(p)); -} - -inline bool is_directory(path const& p, system::error_code& ec) -{ - return is_directory(detail::status(p, &ec)); + return filesystem::exists(detail::status(p, &ec)); } inline bool is_regular_file(path const& p) { - return is_regular_file(detail::status(p)); + return filesystem::is_regular_file(detail::status(p)); } inline bool is_regular_file(path const& p, system::error_code& ec) { - return is_regular_file(detail::status(p, &ec)); + return filesystem::is_regular_file(detail::status(p, &ec)); } -inline bool is_other(path const& p) +inline bool is_directory(path const& p) { - return is_other(detail::status(p)); + return filesystem::is_directory(detail::status(p)); } -inline bool is_other(path const& p, system::error_code& ec) +inline bool is_directory(path const& p, system::error_code& ec) { - return is_other(detail::status(p, &ec)); + return filesystem::is_directory(detail::status(p, &ec)); } inline bool is_symlink(path const& p) { - return is_symlink(detail::symlink_status(p)); + return filesystem::is_symlink(detail::symlink_status(p)); } inline bool is_symlink(path const& p, system::error_code& ec) { - return is_symlink(detail::symlink_status(p, &ec)); + return filesystem::is_symlink(detail::symlink_status(p, &ec)); +} + +inline bool is_block_file(path const& p) +{ + return filesystem::is_block_file(detail::status(p)); +} + +inline bool is_block_file(path const& p, system::error_code& ec) +{ + return filesystem::is_block_file(detail::status(p, &ec)); +} + +inline bool is_character_file(path const& p) +{ + return filesystem::is_character_file(detail::status(p)); +} + +inline bool is_character_file(path const& p, system::error_code& ec) +{ + return filesystem::is_character_file(detail::status(p, &ec)); +} + +inline bool is_fifo(path const& p) +{ + return filesystem::is_fifo(detail::status(p)); +} + +inline bool is_fifo(path const& p, system::error_code& ec) +{ + return filesystem::is_fifo(detail::status(p, &ec)); +} + +inline bool is_socket(path const& p) +{ + return filesystem::is_socket(detail::status(p)); +} + +inline bool is_socket(path const& p, system::error_code& ec) +{ + return filesystem::is_socket(detail::status(p, &ec)); +} + +inline bool is_reparse_file(path const& p) +{ + return filesystem::is_reparse_file(detail::symlink_status(p)); +} + +inline bool is_reparse_file(path const& p, system::error_code& ec) +{ + return filesystem::is_reparse_file(detail::symlink_status(p, &ec)); +} + +inline bool is_other(path const& p) +{ + return filesystem::is_other(detail::status(p)); +} + +inline bool is_other(path const& p, system::error_code& ec) +{ + return filesystem::is_other(detail::status(p, &ec)); } #ifndef BOOST_FILESYSTEM_NO_DEPRECATEDpath
comparison operators are now more restricted to avoid potential ambiguities when user's code contains ausing namespace boost::filesystem;
directive. (#285)