Added more file type testing functions.

Also, make namespace-scope file testing functions for directory_entry
forward to member functions for better efficiency.
This commit is contained in:
Andrey Semashev 2023-06-11 20:56:20 +03:00
parent d508d4950f
commit b1bf547a55
5 changed files with 390 additions and 65 deletions

View File

@ -131,14 +131,20 @@
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#exists">exists</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#exists">exists</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#equivalent">equivalent</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#equivalent">equivalent</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#file_size">file_size</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#file_size">file_size</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#hard_link_count">hard_link_count</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#hard_link_count">hard_link_count</a></code></td>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#initial_path">initial_path</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_directory">is_directory</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_empty">is_empty</a></code></td>
<td width="34%" valign="top"> <td width="34%" valign="top">
<p> <p>
<code>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_other">is_other</a><br> <code>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#initial_path">initial_path</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_block_file">is_block_file</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_character_file">is_character_file</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_directory">is_directory</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_empty">is_empty</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_fifo">is_fifo</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_other">is_other</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_regular_file">is_regular_file</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_regular_file">is_regular_file</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_reparse_file">is_reparse_file</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_socket">is_socket</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_symlink">is_symlink</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_symlink">is_symlink</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#last_write_time">last_write_time</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#last_write_time">last_write_time</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="#permissions">permissions</a><br> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#permissions">permissions</a><br>
@ -893,6 +899,16 @@ nothing else.&quot;</p>
const path&amp; <a href="#initial_path">initial_path</a>(); const path&amp; <a href="#initial_path">initial_path</a>();
const path&amp; <a href="#initial_path">initial_path</a>(<code>system::error_code&amp; ec</code>); const path&amp; <a href="#initial_path">initial_path</a>(<code>system::error_code&amp; ec</code>);
bool <a href="#is_block_file">is_block_file</a>(file_status s) noexcept;
bool <a href="#is_block_file2">is_block_file</a>(const path&amp; p);
bool <a href="#is_block_file2">is_block_file</a>(const path&amp; p,
system::error_code&amp; ec) noexcept;
bool <a href="#is_character_file">is_character_file</a>(file_status s) noexcept;
bool <a href="#is_character_file2">is_character_file</a>(const path&amp; p);
bool <a href="#is_character_file2">is_character_file</a>(const path&amp; p,
system::error_code&amp; ec) noexcept;
bool <a href="#is_directory">is_directory</a>(file_status s) noexcept; bool <a href="#is_directory">is_directory</a>(file_status s) noexcept;
bool <a href="#is_directory2">is_directory</a>(const path&amp; p); bool <a href="#is_directory2">is_directory</a>(const path&amp; p);
bool <a href="#is_directory2">is_directory</a>(const path&amp; p, bool <a href="#is_directory2">is_directory</a>(const path&amp; p,
@ -901,6 +917,11 @@ nothing else.&quot;</p>
bool <a href="#is_empty">is_empty</a>(const path&amp; p); bool <a href="#is_empty">is_empty</a>(const path&amp; p);
bool <a href="#is_empty">is_empty</a>(const path&amp; p, system::error_code&amp; ec); bool <a href="#is_empty">is_empty</a>(const path&amp; p, system::error_code&amp; ec);
bool <a href="#is_fifo">is_fifo</a>(file_status s) noexcept;
bool <a href="#is_fifo2">is_fifo</a>(const path&amp; p);
bool <a href="#is_fifo2">is_fifo</a>(const path&amp; p,
system::error_code&amp; ec) noexcept;
bool <a href="#is_other">is_other</a>(file_status s) noexcept; bool <a href="#is_other">is_other</a>(file_status s) noexcept;
bool <a href="#is_other2">is_other</a>(const path&amp; p,); bool <a href="#is_other2">is_other</a>(const path&amp; p,);
bool <a href="#is_other2">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept; bool <a href="#is_other2">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
@ -910,6 +931,16 @@ nothing else.&quot;</p>
bool <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p, bool <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p,
system::error_code&amp; ec) noexcept; system::error_code&amp; ec) noexcept;
bool <a href="#is_reparse_file">is_reparse_file</a>(file_status s) noexcept;
bool <a href="#is_reparse_file2">is_reparse_file</a>(const path&amp; p);
bool <a href="#is_reparse_file2">is_reparse_file</a>(const path&amp; p,
system::error_code&amp; ec) noexcept;
bool <a href="#is_socket">is_socket</a>(file_status s) noexcept;
bool <a href="#is_socket2">is_socket</a>(const path&amp; p);
bool <a href="#is_socket2">is_socket</a>(const path&amp; p,
system::error_code&amp; ec) noexcept;
bool <a href="#is_symlink">is_symlink</a>(file_status s noexcept); bool <a href="#is_symlink">is_symlink</a>(file_status s noexcept);
bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p); bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p);
bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept; bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
@ -2583,6 +2614,16 @@ and permissions of a file.</p>
bool is_directory(system::error_code&amp; ec) const; bool is_directory(system::error_code&amp; ec) const;
bool is_symlink() const; bool is_symlink() const;
bool is_symlink(system::error_code&amp; ec) const; bool is_symlink(system::error_code&amp; ec) const;
bool is_block_file() const;
bool is_block_file(system::error_code&amp; ec) const;
bool is_character_file() const;
bool is_character_file(system::error_code&amp; ec) const;
bool is_fifo() const;
bool is_fifo(system::error_code&amp; ec) const;
bool is_socket() const;
bool is_socket(system::error_code&amp; ec) const;
bool is_reparse_file() const;
bool is_reparse_file(system::error_code&amp; ec) const;
bool is_other() const; bool is_other() const;
bool is_other(system::error_code&amp; ec) const; bool is_other(system::error_code&amp; ec) const;
@ -2785,6 +2826,31 @@ bool is_symlink(system::error_code&amp; ec) const;</pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Equivalent to <code>is_symlink(symlink_status())</code> or <code>is_symlink(symlink_status(ec))</code>, respectively.</p> <p><i>Effects:</i> Equivalent to <code>is_symlink(symlink_status())</code> or <code>is_symlink(symlink_status(ec))</code>, respectively.</p>
</blockquote> </blockquote>
<pre>bool is_block_file() const;
bool is_block_file(system::error_code&amp; ec) const;</pre>
<blockquote>
<p><i>Effects:</i> Equivalent to <code>is_block_file(status())</code> or <code>is_block_file(status(ec))</code>, respectively.</p>
</blockquote>
<pre>bool is_character_file() const;
bool is_character_file(system::error_code&amp; ec) const;</pre>
<blockquote>
<p><i>Effects:</i> Equivalent to <code>is_character_file(status())</code> or <code>is_character_file(status(ec))</code>, respectively.</p>
</blockquote>
<pre>bool is_fifo() const;
bool is_fifo(system::error_code&amp; ec) const;</pre>
<blockquote>
<p><i>Effects:</i> Equivalent to <code>is_fifo(status())</code> or <code>is_fifo(status(ec))</code>, respectively.</p>
</blockquote>
<pre>bool is_socket() const;
bool is_socket(system::error_code&amp; ec) const;</pre>
<blockquote>
<p><i>Effects:</i> Equivalent to <code>is_socket(status())</code> or <code>is_socket(status(ec))</code>, respectively.</p>
</blockquote>
<pre>bool is_reparse_file() const;
bool is_reparse_file(system::error_code&amp; ec) const;</pre>
<blockquote>
<p><i>Effects:</i> Equivalent to <code>is_reparse_file(symlink_status())</code> or <code>is_reparse_file(symlink_status(ec))</code>, respectively.</p>
</blockquote>
<pre>bool is_other() const; <pre>bool is_other() const;
bool is_other(system::error_code&amp; ec) const;</pre> bool is_other(system::error_code&amp; ec) const;</pre>
<blockquote> <blockquote>
@ -3496,6 +3562,30 @@ const path&amp; <a name="initial_path2">initial_path</a>(<code>system::error_cod
main().&nbsp; <i>—end note</i>]</p> main().&nbsp; <i>—end note</i>]</p>
<p><i>Throws:</i> For the first call, as specified in <a href="#Error-reporting">Error reporting</a>. Subsequent calls throw nothing.</p> <p><i>Throws:</i> For the first call, as specified in <a href="#Error-reporting">Error reporting</a>. Subsequent calls throw nothing.</p>
</blockquote> </blockquote>
<pre>bool <code><a name="is_block_file">is_block_file</a></code>(file_status s) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>s.type() == block_file</code></p>
</blockquote>
<pre><code>bool <a name="is_block_file2">is_block_file</a>(const path&amp; p);
bool <a name="is_block_file3">is_block_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>is_block_file(status(p))</code> or <code>is_block_file(status(p, ec))</code>,
respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p>
</blockquote>
<pre>bool <code><a name="is_character_file">is_character_file</a></code>(file_status s) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>s.type() == character_file</code></p>
</blockquote>
<pre><code>bool <a name="is_character_file2">is_character_file</a>(const path&amp; p);
bool <a name="is_character_file3">is_character_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>is_character_file(status(p))</code> or <code>is_character_file(status(p, ec))</code>,
respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p>
</blockquote>
<pre>bool <code><a name="is_directory">is_directory</a></code>(file_status s) noexcept;</pre> <pre>bool <code><a name="is_directory">is_directory</a></code>(file_status s) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>s.type() == directory_file</code></p> <p><i>Returns:</i> <code>s.type() == directory_file</code></p>
@ -3504,8 +3594,8 @@ const path&amp; <a name="initial_path2">initial_path</a>(<code>system::error_cod
bool <a name="is_directory3">is_directory</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre> bool <a name="is_directory3">is_directory</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>is_directory(status(p))</code> or <code>is_directory(status(p, ec))</code>, <p><i>Returns:</i> <code>is_directory(status(p))</code> or <code>is_directory(status(p, ec))</code>,
respectively.</p> respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws <p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p> nothing.</p>
</blockquote> </blockquote>
<pre><code>bool <a name="is_empty">is_empty</a>(const path&amp; p); <pre><code>bool <a name="is_empty">is_empty</a>(const path&amp; p);
@ -3516,20 +3606,17 @@ bool <a name="is_empty2">is_empty</a></a>(const path&amp; p, system::error_code&
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ? directory_iterator(p) == directory_iterator()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ? directory_iterator(p) == directory_iterator()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : file_size(p) == 0;</code></p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : file_size(p) == 0;</code></p>
</blockquote> </blockquote>
<pre>bool <code><a name="is_regular_file">is_regular_file</a></code>(file_status s) noexcept;</pre> <pre>bool <code><a name="is_fifo">is_fifo</a></code>(file_status s) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>s.type() == regular_file</code></p> <p><i>Returns:</i> <code>s.type() == fifo_file</code></p>
</blockquote> </blockquote>
<pre><code>bool <a name="is_regular_file2">is_regular_file</a>(const path&amp; p);</code></pre> <pre><code>bool <a name="is_fifo2">is_fifo</a>(const path&amp; p);
bool <a name="is_fifo3">is_fifo</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>is_regular_file(status(p))</code>.</p> <p><i>Returns:</i> <code>is_fifo(status(p))</code> or <code>is_fifo(status(p, ec))</code>,
<p><i>Throws:</i> <code>filesystem_error</code> if <code>status(p)</code> would throw <code>filesystem_error.</code></p> respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
</blockquote> <p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
<pre><code>bool <a name="is_regular_file3">is_regular_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre> nothing.</p>
<blockquote>
<p><i>Effects:</i> Sets <code>ec</code> as if by <code>status(p, ec)</code>. [<i>Note:</i> <code>status_error</code>, <code>file_not_found</code> and <code>type_unknown</code> cases set <code>ec</code> to error values. To distinguish between cases, call the <code>status</code> function directly. <i>—end
note</i>] </p>
<p><i>Returns:</i> <code>is_regular_file(status(p, ec))</code>.</p>
</blockquote> </blockquote>
<pre>bool <a name="is_other">is_other</a>(file_status s) noexcept;</pre> <pre>bool <a name="is_other">is_other</a>(file_status s) noexcept;</pre>
<blockquote> <blockquote>
@ -3539,8 +3626,44 @@ bool <a name="is_empty2">is_empty</a></a>(const path&amp; p, system::error_code&
bool <a name="is_other3">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre> bool <a name="is_other3">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>is_other(status(p))</code> or <code>is_other(status(p, ec))</code>, <p><i>Returns:</i> <code>is_other(status(p))</code> or <code>is_other(status(p, ec))</code>,
respectively.</p> respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws <p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p>
</blockquote>
<pre>bool <code><a name="is_regular_file">is_regular_file</a></code>(file_status s) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>s.type() == regular_file</code></p>
</blockquote>
<pre><code>bool <a name="is_regular_file2">is_regular_file</a>(const path&amp; p);
bool <a name="is_regular_file3">is_regular_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>is_regular_file(status(p))</code> or <code>is_regular_file(status(p, ec))</code>,
respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p>
</blockquote>
<pre>bool <a name="is_reparse_file">is_reparse_file</a>(file_status s) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>s.type() == reparse_file</code></p>
</blockquote>
<pre><code>bool <a name="is_reparse_file2">is_reparse_file</a>(const path&amp; p);
bool <a name="is_reparse_file3">is_reparse_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>is_reparse_file(symlink_status(p))</code> or <code>is_reparse_file(symlink_status(p, ec))</code>,
respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p>
</blockquote>
<pre>bool <a name="is_socket">is_socket</a>(file_status s) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>s.type() == socket_file</code></p>
</blockquote>
<pre><code>bool <a name="is_socket2">is_socket</a>(const path&amp; p);
bool <a name="is_socket3">is_socket</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>is_socket(status(p))</code> or <code>is_socket(status(p, ec))</code>,
respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p> nothing.</p>
</blockquote> </blockquote>
<pre>bool <a name="is_symlink">is_symlink</a>(file_status s) noexcept;</pre> <pre>bool <a name="is_symlink">is_symlink</a>(file_status s) noexcept;</pre>
@ -3551,8 +3674,8 @@ bool <a name="is_other3">is_other</a>(const path&amp; p, system::error_code&amp;
bool <a name="is_symlink3">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre> bool <a name="is_symlink3">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>is_symlink(symlink_status(p))</code> or <code>is_symlink(symlink_status(p, ec))</code>, <p><i>Returns:</i> <code>is_symlink(symlink_status(p))</code> or <code>is_symlink(symlink_status(p, ec))</code>,
respectively.</p> respectively. The overload with argument <code>ec</code> returns <code>false</code> if an error occurs.</p>
<p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws <p><i>Throws:</i> <code>filesystem_error</code>; the overload with argument <code>ec</code> throws
nothing.</p> nothing.</p>
</blockquote> </blockquote>
<pre><code>std::time_t <a name="creation_time">creation_time</a>(const path&amp; p); <pre><code>std::time_t <a name="creation_time">creation_time</a>(const path&amp; p);

View File

@ -45,6 +45,7 @@
<li><b>v4:</b> <code>directory_entry</code> constructors and modifiers that initialize or modify the path now automatically call <code>refresh</code>. This may result in errors that were not indicated before and in <b>v3</b>, if querying the filesystem for file statuses fails (e.g. if the file does not exist). This new behavior is similar to std::filesystem.</li> <li><b>v4:</b> <code>directory_entry</code> constructors and modifiers that initialize or modify the path now automatically call <code>refresh</code>. This may result in errors that were not indicated before and in <b>v3</b>, if querying the filesystem for file statuses fails (e.g. if the file does not exist). This new behavior is similar to std::filesystem.</li>
<li><b>v4:</b> <code>directory_entry</code> constructors and methods taking <code>file_status</code> parameters are removed. Users are recommended to remove these arguments and rely on <code>directory_entry</code> calling <code>refresh</code> internally.</li> <li><b>v4:</b> <code>directory_entry</code> constructors and methods taking <code>file_status</code> parameters are removed. Users are recommended to remove these arguments and rely on <code>directory_entry</code> calling <code>refresh</code> internally.</li>
<li>Added <code>directory_entry</code> member methods for checking the file type of the file, similar to std::filesystem.</li> <li>Added <code>directory_entry</code> member methods for checking the file type of the file, similar to std::filesystem.</li>
<li>Added more methods for testing file status: <code>is_block_file</code>, <code>is_character_file</code>, <code>is_fifo</code>, <code>is_socket</code> and <code>is_reparse_file</code>.</li>
<li><code>recursive_directory_iterator</code> is now more likely to reuse information about the file type that is obtained during filesystem iteration. This may improve performance. (<a href="https://github.com/boostorg/filesystem/issues/288">#288</a>)</li> <li><code>recursive_directory_iterator</code> is now more likely to reuse information about the file type that is obtained during filesystem iteration. This may improve performance. (<a href="https://github.com/boostorg/filesystem/issues/288">#288</a>)</li>
<li>File streams defined in <code>boost/filesystem/fstream.hpp</code> are now movable, if the standard library file streams are. (<a href="https://github.com/boostorg/filesystem/issues/280">#280</a>)</li> <li>File streams defined in <code>boost/filesystem/fstream.hpp</code> are now movable, if the standard library file streams are. (<a href="https://github.com/boostorg/filesystem/issues/280">#280</a>)</li>
<li>Generic <code>path</code> comparison operators are now more restricted to avoid potential ambiguities when user's code contains a <code>using namespace boost::filesystem;</code> directive. (<a href="https://github.com/boostorg/filesystem/issues/285">#285</a>)</li> <li>Generic <code>path</code> comparison operators are now more restricted to avoid potential ambiguities when user's code contains a <code>using namespace boost::filesystem;</code> directive. (<a href="https://github.com/boostorg/filesystem/issues/285">#285</a>)</li>

View File

@ -278,6 +278,56 @@ public:
return this->symlink_file_type(ec) == filesystem::symlink_file; 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 bool is_other() const
{ {
filesystem::file_type ft = this->file_type(); filesystem::file_type ft = this->file_type();
@ -418,66 +468,142 @@ inline file_status status(directory_entry const& e)
{ {
return e.status(); return e.status();
} }
inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{ {
return e.status(ec); 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) 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 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) inline bool status_known(directory_entry const& e)
{ {
return filesystem::status_known(e.status()); return filesystem::status_known(e.status());
} }
inline bool status_known(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT inline bool status_known(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{ {
return filesystem::status_known(e.status(ec)); return filesystem::status_known(e.status(ec));
} }
inline bool exists(directory_entry const& e) 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 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) 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 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) 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 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) 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 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) 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 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 #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead") BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
inline bool is_regular(directory_entry const& e) inline bool is_regular(directory_entry const& e)

View File

@ -155,13 +155,13 @@ public:
// Note: std::move is not constexpr in C++11, that's why we're not using it here // 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 : BOOST_CONSTEXPR file_status(file_status&& rhs) BOOST_NOEXCEPT :
m_value(static_cast< file_type&& >(rhs.m_value)), 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 BOOST_CXX14_CONSTEXPR file_status& operator=(file_status&& rhs) BOOST_NOEXCEPT
{ {
m_value = static_cast< file_type&& >(rhs.m_value); 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; return *this;
} }
#endif #endif
@ -174,28 +174,28 @@ public:
BOOST_CXX14_CONSTEXPR void type(file_type v) BOOST_NOEXCEPT { m_value = v; } 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_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(); 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); return !(*this == rhs);
} }
private: private:
file_type m_value; file_type m_value;
enum perms m_perms; perms m_perms;
}; };
inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT 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 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 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 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 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 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 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 inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT

View File

@ -193,52 +193,102 @@ inline file_status symlink_status(path const& p, system::error_code& ec)
inline bool exists(path const& p) 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) inline bool exists(path const& p, system::error_code& ec)
{ {
return exists(detail::status(p, &ec)); return filesystem::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));
} }
inline bool is_regular_file(path const& p) 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) 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) 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) 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_DEPRECATED #ifndef BOOST_FILESYSTEM_NO_DEPRECATED