mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-29 19:42:08 +00:00
change status_flag to status_flags
[SVN r29552]
This commit is contained in:
@@ -10,12 +10,14 @@
|
||||
|
||||
#include "boost/filesystem/operations.hpp"
|
||||
#include "boost/filesystem/path.hpp"
|
||||
#include "boost/progress.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
boost::progress_timer t( std::clog );
|
||||
|
||||
fs::path full_path( fs::initial_path<fs::path>() );
|
||||
|
||||
@@ -46,12 +48,18 @@ int main( int argc, char* argv[] )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( fs::is_directory( *dir_itr ) )
|
||||
#if 1
|
||||
fs::status_flag flags( fs::status( *dir_itr ) );
|
||||
#else
|
||||
fs::status_flag flags( fs::file_flag );
|
||||
#endif
|
||||
|
||||
if ( (flags & fs::directory_flag) == fs::directory_flag )
|
||||
{
|
||||
++dir_count;
|
||||
std::cout << dir_itr->leaf() << " [directory]\n";
|
||||
}
|
||||
else if ( fs::is_file( *dir_itr ) )
|
||||
else if ( (flags & fs::file_flag) == fs::file_flag )
|
||||
{
|
||||
++file_count;
|
||||
std::cout << dir_itr->leaf() << "\n";
|
||||
|
||||
@@ -39,6 +39,14 @@
|
||||
# define BOOST_WINDOWS_PATH
|
||||
# endif
|
||||
|
||||
// BOOST_FILESYSTEM_STATUS_CACHE enables status_flags cache in
|
||||
// basic_directory_iterator -----------------------------------------------//
|
||||
|
||||
// TODO: find out how Linux, others, enable dirent::d_type. __USE_BSD????
|
||||
# if defined(BOOST_WINDOWS_API) || defined(__APPLE__)
|
||||
# define BOOST_FILESYSTEM_STATUS_CACHE
|
||||
# endif
|
||||
|
||||
// narrow support only for badly broken compilers or libraries -------------//
|
||||
|
||||
# if defined(BOOST_NO_STD_WSTRING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace boost
|
||||
{
|
||||
template<class Path> class basic_directory_iterator;
|
||||
|
||||
typedef char status_flag;
|
||||
static const status_flag error_flag = 1;
|
||||
static const status_flag not_found_flag = 2;
|
||||
static const status_flag directory_flag = 4;
|
||||
static const status_flag file_flag = 8;
|
||||
static const status_flag symlink_flag = 16;
|
||||
typedef char status_flags;
|
||||
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 symlink_flag = 16;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@@ -82,13 +82,13 @@ namespace detail
|
||||
};
|
||||
|
||||
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flag
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flags
|
||||
status_api( const std::string & ph,
|
||||
boost::filesystem::system_error_type * ec = 0 );
|
||||
BOOST_FILESYSTEM_DECL bool
|
||||
symbolic_link_exists_api( const std::string & ); // deprecated
|
||||
# ifndef BOOST_WINDOWS_API
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flag
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flags
|
||||
symlink_status_api( const std::string & ph,
|
||||
boost::filesystem::system_error_type * ec = 0 );
|
||||
# endif
|
||||
@@ -123,7 +123,7 @@ namespace detail
|
||||
|
||||
# if !defined(BOOST_FILESYSTEM_NARROW_ONLY)
|
||||
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flag
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flags
|
||||
status_api( const std::wstring & ph,
|
||||
boost::filesystem::system_error_type * ec = 0 );
|
||||
BOOST_FILESYSTEM_DECL query_pair
|
||||
@@ -168,11 +168,11 @@ namespace detail
|
||||
|
||||
// query functions ---------------------------------------------------------//
|
||||
|
||||
BOOST_FS_FUNC(status_flag)
|
||||
BOOST_FS_FUNC(status_flags)
|
||||
status( const Path & ph, system_error_type * ec = 0 )
|
||||
{ return detail::status_api( ph.external_file_string(), ec ); }
|
||||
|
||||
BOOST_FS_FUNC(status_flag)
|
||||
BOOST_FS_FUNC(status_flags)
|
||||
symlink_status( const Path & ph, system_error_type * ec = 0 )
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
{ return detail::status_api( ph.external_file_string(), ec ); }
|
||||
@@ -186,7 +186,7 @@ namespace detail
|
||||
BOOST_FS_FUNC(bool) exists( const Path & ph )
|
||||
{
|
||||
system_error_type ec;
|
||||
status_flag sf( detail::status_api( ph.external_file_string(), &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::exists", ph, ec ) );
|
||||
@@ -196,7 +196,7 @@ namespace detail
|
||||
BOOST_FS_FUNC(bool) is_directory( const Path & ph )
|
||||
{
|
||||
system_error_type ec;
|
||||
status_flag sf( detail::status_api( ph.external_file_string(), &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_directory", ph, ec ) );
|
||||
@@ -206,7 +206,7 @@ namespace detail
|
||||
BOOST_FS_FUNC(bool) is_file( const Path & ph )
|
||||
{
|
||||
system_error_type ec;
|
||||
status_flag sf( detail::status_api( ph.external_file_string(), &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 ) );
|
||||
@@ -219,7 +219,7 @@ namespace detail
|
||||
return false;
|
||||
# else
|
||||
system_error_type ec;
|
||||
status_flag sf( detail::symlink_status_api( ph.external_file_string(), &ec ) );
|
||||
status_flags sf( detail::symlink_status_api( ph.external_file_string(), &ec ) );
|
||||
if ( sf == error_flag )
|
||||
boost::throw_exception( basic_filesystem_error<Path>(
|
||||
"boost::filesystem::is_symlink", ph, ec ) );
|
||||
@@ -428,14 +428,14 @@ namespace detail
|
||||
|
||||
// "do-the-right-thing" overloads ---------------------------------------//
|
||||
|
||||
inline status_flag status( const path & ph, system_error_type * ec = 0 )
|
||||
inline status_flags status( const path & ph, system_error_type * ec = 0 )
|
||||
{ return status<path>( ph, ec ); }
|
||||
inline status_flag status( const wpath & ph, system_error_type * ec = 0 )
|
||||
inline status_flags status( const wpath & ph, system_error_type * ec = 0 )
|
||||
{ return status<wpath>( ph, ec ); }
|
||||
|
||||
inline status_flag symlink_status( const path & ph, system_error_type * ec = 0 )
|
||||
inline status_flags symlink_status( const path & ph, system_error_type * ec = 0 )
|
||||
{ return symlink_status<path>( ph, ec ); }
|
||||
inline status_flag symlink_status( const wpath & ph, system_error_type * ec = 0 )
|
||||
inline status_flags symlink_status( const wpath & ph, system_error_type * ec = 0 )
|
||||
{ return symlink_status<wpath>( ph, ec ); }
|
||||
|
||||
inline bool exists( const path & ph ) { return exists<path>( ph ); }
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace
|
||||
# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
|
||||
template< class String >
|
||||
fs::status_flag status_template( const String & ph,
|
||||
fs::status_flags status_template( const String & ph,
|
||||
boost::filesystem::system_error_type * ec )
|
||||
{
|
||||
DWORD attr( get_file_attributes( ph.c_str() ) );
|
||||
@@ -414,7 +414,7 @@ namespace
|
||||
remove_template( const String & ph )
|
||||
{
|
||||
fs::system_error_type ec;
|
||||
fs::status_flag sf( fs::detail::status_api( ph, &ec ) );
|
||||
fs::status_flags sf( fs::detail::status_api( ph, &ec ) );
|
||||
if ( sf == fs::error_flag ) return ec;
|
||||
if ( (sf & fs::directory_flag) != 0 )
|
||||
{
|
||||
@@ -486,14 +486,14 @@ namespace boost
|
||||
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
|
||||
BOOST_FILESYSTEM_DECL fs::status_flag
|
||||
BOOST_FILESYSTEM_DECL fs::status_flags
|
||||
status_api( const std::string & ph,
|
||||
boost::filesystem::system_error_type * ec )
|
||||
{ return status_template( ph, ec ); }
|
||||
|
||||
# ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
|
||||
BOOST_FILESYSTEM_DECL fs::status_flag
|
||||
BOOST_FILESYSTEM_DECL fs::status_flags
|
||||
status_api( const std::wstring & ph,
|
||||
boost::filesystem::system_error_type * ec )
|
||||
{ return status_template( ph, ec ); }
|
||||
@@ -767,7 +767,7 @@ namespace boost
|
||||
|
||||
# else // BOOST_POSIX_API
|
||||
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flag
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flags
|
||||
status_api( const std::string & ph,
|
||||
boost::filesystem::system_error_type * ec )
|
||||
{
|
||||
@@ -778,13 +778,13 @@ namespace boost
|
||||
return ( (errno == ENOENT) || (errno == ENOTDIR) )
|
||||
? fs::not_found_flag : fs::error_flag;
|
||||
}
|
||||
fs::status_flag result(0);
|
||||
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;
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flag
|
||||
BOOST_FILESYSTEM_DECL boost::filesystem::status_flags
|
||||
symlink_status_api( const std::string & ph,
|
||||
boost::filesystem::system_error_type * ec )
|
||||
{
|
||||
@@ -796,7 +796,7 @@ namespace boost
|
||||
? fs::not_found_flag : fs::error_flag;
|
||||
}
|
||||
if ( S_ISLNK( path_stat.st_mode ) ) return fs::symlink_flag;
|
||||
fs::status_flag result(0);
|
||||
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;
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user