is_file, file_flag -> is_regular, regular_flag per TR2 proposal

[SVN r32201]
This commit is contained in:
Beman Dawes 2006-01-02 02:30:53 +00:00
parent d2f2371de4
commit aac5f49666
6 changed files with 49 additions and 49 deletions

View File

@ -24,7 +24,7 @@
&nbsp;&nbsp;&nbsp; <a href="#exists">exists</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_error">is_error</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_directory">is_directory</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_file">is_file</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_regular">is_regular</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_symlink">is_symlink</a><br>
&nbsp;&nbsp;&nbsp; <a href="#is_empty">is_empty</a><br>
&nbsp;&nbsp;&nbsp; <a href="#equivalent">equivalent</a><br>
@ -69,7 +69,7 @@ header. </p>
static const status_flags error_flag;
static const status_flags not_found_flag;
static const status_flags directory_flag;
static const status_flags file_flag;
static const status_flags regular_flag;
static const status_flags other_flag;
static const status_flags symlink_flag;
@ -108,7 +108,7 @@ header. </p>
bool exists() const;
bool is_directory() const;
bool is_file() const;
bool is_regular() const;
bool is_other() const;
bool is_symlink() const;
@ -148,10 +148,10 @@ header. </p>
template&lt;class Path&gt; bool <a href="#exists">exists</a>( const Path &amp; ph );
bool exists( status_flags f );
bool is_error( status_flags f );
template&lt;class Path&gt; bool <a href="#is_file">is_directory</a>( const <code>Path</code> &amp; ph );
template&lt;class Path&gt; bool <a href="#is_directory">is_directory</a>( const <code>Path</code> &amp; ph );
bool is_directory( status_flags f );
template&lt;class Path&gt; bool <a href="#is_file">is_file</a>( const <code>Path</code> &amp; ph );
bool is_file( status_flags f );
template&lt;class Path&gt; bool <a href="#is_regular">is_regular</a>( const <code>Path</code> &amp; ph );
bool is_regular( status_flags f );
template&lt;class Path&gt; bool <a href="#is_other">is_other</a>( const <code>Path</code> &amp; ph );
bool is_other( status_flags f );
template&lt;class Path&gt; bool <a href="#is_symlink">is_symlink</a>( const <code>Path</code> &amp; ph );
@ -364,7 +364,7 @@ template&lt;class Path&gt; <a href="#status_flag">status_flags</a> status( con
<li>If the attributes indicate a file, as if by
<a href="design.htm#POSIX-01">[POSIX-01]</a>&nbsp;S_ISREG() (also see
<a href="i18n.html#Expectations">expectations</a>), <code>result |=
file_flag</code>.</li>
regular_flag</code>.</li>
<li>If result is 0, set result to <code>other_flag</code>.</li>
<li>Return result.</li>
</ul>
@ -390,7 +390,7 @@ template&lt;class Path&gt; <a href="#status_flag">status_flags</a> status( con
is a possibility only when the <code>symlink_t</code> argument is present.</li>
<li>Otherwise, one or more of the following, or'ed together: <code>
directory_flag</code>,&nbsp;
<code>file_flag</code>. <i>[More status bits may be added in the future.]</i></li>
<code>regular_flag</code>. <i>[More status bits may be added in the future.]</i></li>
</ul>
<p>See <a href="#Performance_note">performance note</a> for subtle
differences between behavior of Path and DirItr template signatures.</p>
@ -433,14 +433,14 @@ will be portable to systems like POSIX, where symbolic links may be present.</p>
<p><span style="background-color: #FFFFFF"><b>Returns: </b><code>(f &amp;
directory_flag) != 0</code></span></p>
</blockquote>
<h3><a name="is_file">is_file</a></h3>
<h3><a name="is_regular">is_regular</a></h3>
<blockquote>
<p><code>template&lt;class Path&gt; bool is_file( const Path &amp; ph );</code></p>
<p><code>template&lt;class Path&gt; bool is_regular( const Path &amp; ph );</code></p>
<p><b>Throws:</b> If <code>status(ph) == error_flag</code>.</p>
<p><b>Returns:</b> <code>(status(ph) &amp; file_flag) != 0</code></p>
<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF">is_file</span></code><span style="background-color: #FFFFFF">( status_flags f );</span></pre>
<p><b>Returns:</b> <code>(status(ph) &amp; regular_flag) != 0</code></p>
<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF">is_regular</span></code><span style="background-color: #FFFFFF">( status_flags f );</span></pre>
<p><span style="background-color: #FFFFFF"><b>Returns: </b><code>(f &amp;
file_flag) != 0</code></span></p>
regular_flag) != 0</code></span></p>
</blockquote>
<h3><a name="is_other">is_other</a></h3>
<blockquote>
@ -502,7 +502,7 @@ template&lt;class DirItr&gt; bool is_symlink( const DirItr &amp; ph );</code></p
<p><code>template&lt;class Path&gt; boost::intmax_t file_size( const Path &amp; ph );</code></p>
<p><b>Returns:</b> The size of the file in bytes as reported by the operating
system.</p>
<p><b>Throws:</b> if <code>!is_file(ph)</code></p>
<p><b>Throws:</b> if <code>!is_regular(ph)</code></p>
<p><b>Warming:</b> If a compiler does not support <code>maxint_t</code> large
enough to represent the operating system's maximum file size, or if the
implementation does not know how to query the operating system for large file

View File

@ -72,7 +72,7 @@ int main( int argc, char * argv[] )
for ( fs::wdirectory_iterator it( L"." );
it != fs::wdirectory_iterator(); ++it )
{
if ( it->is_file() )
if ( it->is_regular() )
{
copy_file( *it, target_dir / it->path().leaf() );
}

View File

@ -55,7 +55,7 @@ int main( int argc, char* argv[] )
++dir_count;
std::cout << dir_itr->leaf() << " [directory]\n";
}
else if ( (flags & fs::file_flag) == fs::file_flag )
else if ( (flags & fs::regular_flag) == fs::regular_flag )
{
++file_count;
std::cout << dir_itr->leaf() << "\n";

View File

@ -65,7 +65,7 @@ namespace boost
static const status_flags error_flag = 1;
static const status_flags not_found_flag = 2;
static const status_flags directory_flag = 4;
static const status_flags file_flag = 8;
static const status_flags regular_flag = 8;
static const status_flags other_flag = 16;
static const status_flags symlink_flag = 32;
@ -235,14 +235,14 @@ namespace boost
return (sf & directory_flag) != 0;
}
BOOST_FS_FUNC(bool) is_file( const Path & ph )
BOOST_FS_FUNC(bool) is_regular( const Path & ph )
{
system_error_type ec;
status_flags sf( detail::status_api( ph.external_file_string(), &ec ) );
if ( sf == error_flag )
boost::throw_exception( basic_filesystem_error<Path>(
"boost::filesystem::is_file", ph, ec ) );
return (sf & file_flag) != 0;
"boost::filesystem::is_regular", ph, ec ) );
return (sf & regular_flag) != 0;
}
BOOST_FS_FUNC(bool) is_other( const Path & ph )
@ -275,7 +275,7 @@ namespace boost
inline bool exists( status_flags f ) { return f != 0 && ((f & not_found_flag) == 0); }
inline bool is_error( status_flags f ) { return (f & error_flag) != 0; }
inline bool is_directory( status_flags f ) { return (f & directory_flag) != 0; }
inline bool is_file( status_flags f ) { return (f & file_flag ) != 0; }
inline bool is_regular( status_flags f ) { return (f & regular_flag ) != 0; }
inline bool is_other( status_flags f ) { return (f & other_flag ) != 0; }
inline bool is_symlink( status_flags f ) { return (f & symlink_flag ) != 0; }
@ -542,10 +542,10 @@ namespace boost
inline bool is_directory( const wpath & ph )
{ return is_directory<wpath>( ph ); }
inline bool is_file( const path & ph )
{ return is_file<path>( ph ); }
inline bool is_file( const wpath & ph )
{ return is_file<wpath>( ph ); }
inline bool is_regular( const path & ph )
{ return is_regular<path>( ph ); }
inline bool is_regular( const wpath & ph )
{ return is_regular<wpath>( ph ); }
inline bool is_other( const path & ph )
{ return is_other<path>( ph ); }
@ -916,7 +916,7 @@ namespace boost
bool exists() const;
bool is_directory() const;
bool is_file() const;
bool is_regular() const;
bool is_other() const;
bool is_symlink() const;
@ -995,10 +995,10 @@ namespace boost
}
template<class Path>
bool basic_directory_entry<Path>::is_file() const
bool basic_directory_entry<Path>::is_regular() const
{
m_get_status_if_needed();
return (m_status & file_flag) != 0;
return (m_status & regular_flag) != 0;
}
template<class Path>

View File

@ -179,7 +179,7 @@ namespace
? fs::not_found_flag : fs::error_flag;
}
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0
? fs::directory_flag : fs::file_flag;
? fs::directory_flag : fs::regular_flag;
}
BOOL get_file_attributes_ex( const char * ph,
@ -703,7 +703,7 @@ namespace boost
symlink_sf = sf = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
== FILE_ATTRIBUTE_DIRECTORY)
? fs::directory_flag
: fs::file_flag;
: fs::regular_flag;
return 0;
}
@ -722,7 +722,7 @@ namespace boost
symlink_sf = sf = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
== FILE_ATTRIBUTE_DIRECTORY)
? fs::directory_flag
: fs::file_flag;
: fs::regular_flag;
return 0;
}
@ -822,7 +822,7 @@ namespace boost
symlink_sf = sf = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
== FILE_ATTRIBUTE_DIRECTORY)
? fs::directory_flag
: fs::file_flag;
: fs::regular_flag;
return 0;
}
@ -853,7 +853,7 @@ namespace boost
symlink_sf = sf = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
== FILE_ATTRIBUTE_DIRECTORY)
? fs::directory_flag
: fs::file_flag;
: fs::regular_flag;
return 0;
}
@ -872,7 +872,7 @@ namespace boost
}
fs::status_flags result(0);
if ( S_ISDIR( path_stat.st_mode ) ) result |= fs::directory_flag;
if ( S_ISREG( path_stat.st_mode ) ) result |= fs::file_flag;
if ( S_ISREG( path_stat.st_mode ) ) result |= fs::regular_flag;
if ( result == 0 ) result = fs::other_flag;
return result;
}
@ -891,7 +891,7 @@ namespace boost
fs::status_flags result(0);
if ( S_ISLNK( path_stat.st_mode ) ) result |= fs::symlink_flag;
if ( S_ISDIR( path_stat.st_mode ) ) result |= fs::directory_flag;
if ( S_ISREG( path_stat.st_mode ) ) result |= fs::file_flag;
if ( S_ISREG( path_stat.st_mode ) ) result |= fs::regular_flag;
if ( result == 0 ) result = fs::other_flag;
return result;
}
@ -1189,7 +1189,7 @@ namespace boost
target = entry->d_name;
# ifdef BOOST_FILESYSTEM_STATUS_CACHE
if ( entry->d_type == DT_DIR ) sf = symlink_sf = fs::directory_flag;
else if ( entry->d_type == DT_REG ) sf = symlink_sf = fs::file_flag;
else if ( entry->d_type == DT_REG ) sf = symlink_sf = fs::regular_flag;
else if ( entry->d_type == DT_LNK )
{ sf = 0; symlink_sf = fs::symlink_flag; }
else sf = symlink_sf = fs::other_flag;

View File

@ -165,7 +165,7 @@ int test_main( int argc, char * argv[] )
fs::path ng( " no-way, Jose" );
BOOST_CHECK( !fs::exists( ng ) );
BOOST_CHECK( !fs::is_directory( ng ) );
BOOST_CHECK( !fs::is_file( ng ) );
BOOST_CHECK( !fs::is_regular( ng ) );
BOOST_CHECK( !fs::is_symlink( ng ) );
BOOST_CHECK( (fs::status( ng ) & fs::not_found_flag) != 0 );
BOOST_CHECK( (fs::status( "" ) & fs::not_found_flag) != 0 );
@ -173,14 +173,14 @@ int test_main( int argc, char * argv[] )
BOOST_CHECK( !fs::exists( flags ) );
BOOST_CHECK( !fs::is_error( flags ) );
BOOST_CHECK( !fs::is_directory( flags ) );
BOOST_CHECK( !fs::is_file( flags ) );
BOOST_CHECK( !fs::is_regular( flags ) );
BOOST_CHECK( !fs::is_other( flags ) );
BOOST_CHECK( !fs::is_symlink( flags ) );
flags = fs::status( "" );
BOOST_CHECK( !fs::exists( flags ) );
BOOST_CHECK( !fs::is_error( flags ) );
BOOST_CHECK( !fs::is_directory( flags ) );
BOOST_CHECK( !fs::is_file( flags ) );
BOOST_CHECK( !fs::is_regular( flags ) );
BOOST_CHECK( !fs::is_other( flags ) );
BOOST_CHECK( !fs::is_symlink( flags ) );
@ -264,14 +264,14 @@ int test_main( int argc, char * argv[] )
BOOST_CHECK( fs::exists( dir ) );
BOOST_CHECK( BOOST_FS_IS_EMPTY( dir ) );
BOOST_CHECK( fs::is_directory( dir ) );
BOOST_CHECK( !fs::is_file( dir ) );
BOOST_CHECK( !fs::is_regular( dir ) );
BOOST_CHECK( !fs::is_other( dir ) );
BOOST_CHECK( !fs::is_symlink( dir ) );
flags = fs::status( dir );
BOOST_CHECK( fs::exists( flags ) );
BOOST_CHECK( !fs::is_error( flags ) );
BOOST_CHECK( fs::is_directory( flags ) );
BOOST_CHECK( !fs::is_file( flags ) );
BOOST_CHECK( !fs::is_regular( flags ) );
BOOST_CHECK( !fs::is_other( flags ) );
BOOST_CHECK( !fs::is_symlink( flags ) );
@ -317,7 +317,7 @@ int test_main( int argc, char * argv[] )
fs::directory_iterator dir_itr( dir );
BOOST_CHECK( dir_itr->exists() );
BOOST_CHECK( dir_itr->is_directory() );
BOOST_CHECK( !dir_itr->is_file() );
BOOST_CHECK( !dir_itr->is_regular() );
BOOST_CHECK( !dir_itr->is_other() );
BOOST_CHECK( !dir_itr->is_symlink() );
@ -394,7 +394,7 @@ int test_main( int argc, char * argv[] )
create_file( file_ph, "" );
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::is_directory( file_ph ) );
BOOST_CHECK( fs::is_file( file_ph ) );
BOOST_CHECK( fs::is_regular( file_ph ) );
BOOST_CHECK( BOOST_FS_IS_EMPTY( file_ph ) );
BOOST_CHECK( fs::file_size( file_ph ) == 0 );
BOOST_CHECK( CHECK_EXCEPTION( bind( BOOST_BND(fs::create_directory),
@ -403,7 +403,7 @@ int test_main( int argc, char * argv[] )
BOOST_CHECK( fs::exists( flags ) );
BOOST_CHECK( !fs::is_error( flags ) );
BOOST_CHECK( !fs::is_directory( flags ) );
BOOST_CHECK( fs::is_file( flags ) );
BOOST_CHECK( fs::is_regular( flags ) );
BOOST_CHECK( !fs::is_other( flags ) );
BOOST_CHECK( !fs::is_symlink( flags ) );
@ -413,7 +413,7 @@ int test_main( int argc, char * argv[] )
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::is_directory( file_ph ) );
BOOST_CHECK( fs::is_file( file_ph ) );
BOOST_CHECK( fs::is_regular( file_ph ) );
BOOST_CHECK( fs::file_size( file_ph ) == 7 );
verify_file( file_ph, "foobar1" );
@ -483,7 +483,7 @@ int test_main( int argc, char * argv[] )
BOOST_CHECK( fs::exists( flags ) );
BOOST_CHECK( !fs::is_error( flags ) );
BOOST_CHECK( !fs::is_directory( flags ) );
BOOST_CHECK( fs::is_file( flags ) );
BOOST_CHECK( fs::is_regular( flags ) );
BOOST_CHECK( !fs::is_other( flags ) );
BOOST_CHECK( fs::is_symlink( flags ) );
}
@ -637,12 +637,12 @@ int test_main( int argc, char * argv[] )
create_file( file_ph, "" );
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::is_directory( file_ph ) );
BOOST_CHECK( fs::is_file( file_ph ) );
BOOST_CHECK( fs::is_regular( file_ph ) );
std::system("ln -s link_target non_dangling_link");
link = "non_dangling_link";
BOOST_CHECK( fs::exists( link ) );
BOOST_CHECK( !fs::is_directory( link ) );
BOOST_CHECK( fs::is_file( link ) );
BOOST_CHECK( fs::is_regular( link ) );
BOOST_CHECK( fs::is_symlink( link ) );
BOOST_CHECK( fs::remove( link ) );
BOOST_CHECK( fs::exists( file_ph ) );
@ -658,7 +658,7 @@ int test_main( int argc, char * argv[] )
create_file( file_ph, "foobar2" );
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::is_directory( file_ph ) );
BOOST_CHECK( fs::is_file( file_ph ) );
BOOST_CHECK( fs::is_regular( file_ph ) );
BOOST_CHECK( fs::file_size( file_ph ) == 7 );
verify_file( file_ph, "foobar2" );