mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 05:31:49 +00:00
Reformatted code for more consistent look and better readability.
This commit is contained in:
parent
83429c9bfd
commit
c03249c375
@ -29,6 +29,6 @@ int main()
|
|||||||
unsigned char buf[16] = {};
|
unsigned char buf[16] = {};
|
||||||
boost::winapi::BCRYPT_ALG_HANDLE_ handle;
|
boost::winapi::BCRYPT_ALG_HANDLE_ handle;
|
||||||
boost::winapi::NTSTATUS_ status = boost::winapi::BCryptOpenAlgorithmProvider(&handle, boost::winapi::BCRYPT_RNG_ALGORITHM_, NULL, 0);
|
boost::winapi::NTSTATUS_ status = boost::winapi::BCryptOpenAlgorithmProvider(&handle, boost::winapi::BCRYPT_RNG_ALGORITHM_, NULL, 0);
|
||||||
status = boost::winapi::BCryptGenRandom(handle, reinterpret_cast<boost::winapi::PUCHAR_>(static_cast<unsigned char*>(buf)), static_cast<boost::winapi::ULONG_>(sizeof(buf)), 0);
|
status = boost::winapi::BCryptGenRandom(handle, reinterpret_cast< boost::winapi::PUCHAR_ >(static_cast< unsigned char* >(buf)), static_cast< boost::winapi::ULONG_ >(sizeof(buf)), 0);
|
||||||
boost::winapi::BCryptCloseAlgorithmProvider(handle, 0);
|
boost::winapi::BCryptCloseAlgorithmProvider(handle, 0);
|
||||||
}
|
}
|
||||||
|
@ -17,92 +17,92 @@ using boost::filesystem::path;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
std::ifstream infile;
|
||||||
|
std::ofstream posix_outfile;
|
||||||
|
std::ifstream posix_infile;
|
||||||
|
std::ofstream outfile;
|
||||||
|
|
||||||
|
bool posix;
|
||||||
|
|
||||||
|
const string empty_string;
|
||||||
|
|
||||||
|
struct column_base
|
||||||
{
|
{
|
||||||
std::ifstream infile;
|
|
||||||
std::ofstream posix_outfile;
|
|
||||||
std::ifstream posix_infile;
|
|
||||||
std::ofstream outfile;
|
|
||||||
|
|
||||||
bool posix;
|
|
||||||
|
|
||||||
const string empty_string;
|
|
||||||
|
|
||||||
struct column_base
|
|
||||||
{
|
|
||||||
virtual string heading() const = 0;
|
virtual string heading() const = 0;
|
||||||
virtual string cell_value( const path & p ) const = 0;
|
virtual string cell_value(const path& p) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct c0 : public column_base
|
struct c0 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>string()</code>"); }
|
string heading() const { return string("<code>string()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.string(); }
|
string cell_value(const path& p) const { return p.string(); }
|
||||||
} o0;
|
} o0;
|
||||||
|
|
||||||
struct c1 : public column_base
|
struct c1 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>generic_<br>string()</code>"); }
|
string heading() const { return string("<code>generic_<br>string()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.generic_string(); }
|
string cell_value(const path& p) const { return p.generic_string(); }
|
||||||
} o1;
|
} o1;
|
||||||
|
|
||||||
struct c2 : public column_base
|
struct c2 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("Iteration<br>over<br>Elements"); }
|
string heading() const { return string("Iteration<br>over<br>Elements"); }
|
||||||
string cell_value( const path & p ) const
|
string cell_value(const path& p) const
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
for( path::iterator i(p.begin()); i != p.end(); ++i )
|
for (path::iterator i(p.begin()); i != p.end(); ++i)
|
||||||
{
|
{
|
||||||
if ( i != p.begin() ) s += ',';
|
if (i != p.begin())
|
||||||
|
s += ',';
|
||||||
s += (*i).string();
|
s += (*i).string();
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
} o2;
|
} o2;
|
||||||
|
|
||||||
struct c3 : public column_base
|
struct c3 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>root_<br>path()</code>"); }
|
string heading() const { return string("<code>root_<br>path()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.root_path().string(); }
|
string cell_value(const path& p) const { return p.root_path().string(); }
|
||||||
} o3;
|
} o3;
|
||||||
|
|
||||||
struct c4 : public column_base
|
struct c4 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>root_<br>name()</code>"); }
|
string heading() const { return string("<code>root_<br>name()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.root_name().string(); }
|
string cell_value(const path& p) const { return p.root_name().string(); }
|
||||||
} o4;
|
} o4;
|
||||||
|
|
||||||
struct c5 : public column_base
|
struct c5 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>root_<br>directory()</code>"); }
|
string heading() const { return string("<code>root_<br>directory()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.root_directory().string(); }
|
string cell_value(const path& p) const { return p.root_directory().string(); }
|
||||||
} o5;
|
} o5;
|
||||||
|
|
||||||
struct c6 : public column_base
|
struct c6 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>relative_<br>path()</code>"); }
|
string heading() const { return string("<code>relative_<br>path()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.relative_path().string(); }
|
string cell_value(const path& p) const { return p.relative_path().string(); }
|
||||||
} o6;
|
} o6;
|
||||||
|
|
||||||
struct c7 : public column_base
|
struct c7 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>parent_<br>path()</code>"); }
|
string heading() const { return string("<code>parent_<br>path()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.parent_path().string(); }
|
string cell_value(const path& p) const { return p.parent_path().string(); }
|
||||||
} o7;
|
} o7;
|
||||||
|
|
||||||
struct c8 : public column_base
|
struct c8 : public column_base
|
||||||
{
|
{
|
||||||
string heading() const { return string("<code>filename()</code>"); }
|
string heading() const { return string("<code>filename()</code>"); }
|
||||||
string cell_value( const path & p ) const { return p.filename().string(); }
|
string cell_value(const path& p) const { return p.filename().string(); }
|
||||||
} o8;
|
} o8;
|
||||||
|
|
||||||
const column_base * column[] = { &o2, &o0, &o1, &o3, &o4, &o5, &o6, &o7, &o8 };
|
const column_base* column[] = { &o2, &o0, &o1, &o3, &o4, &o5, &o6, &o7, &o8 };
|
||||||
|
|
||||||
// do_cell ---------------------------------------------------------------//
|
// do_cell ---------------------------------------------------------------//
|
||||||
|
|
||||||
void do_cell( const string & test_case, int i )
|
void do_cell(const string& test_case, int i)
|
||||||
{
|
{
|
||||||
string temp = column[i]->cell_value(path(test_case));
|
string temp = column[i]->cell_value(path(test_case));
|
||||||
string value;
|
string value;
|
||||||
outfile << "<td>";
|
outfile << "<td>";
|
||||||
@ -126,12 +126,12 @@ namespace
|
|||||||
outfile << value;
|
outfile << value;
|
||||||
}
|
}
|
||||||
outfile << "</td>\n";
|
outfile << "</td>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// do_row ------------------------------------------------------------------//
|
// do_row ------------------------------------------------------------------//
|
||||||
|
|
||||||
void do_row( const string & test_case )
|
void do_row(const string& test_case)
|
||||||
{
|
{
|
||||||
outfile << "<tr>\n";
|
outfile << "<tr>\n";
|
||||||
|
|
||||||
if (test_case.empty())
|
if (test_case.empty())
|
||||||
@ -139,32 +139,30 @@ namespace
|
|||||||
else
|
else
|
||||||
outfile << "<td><code>" << test_case << "</code></td>\n";
|
outfile << "<td><code>" << test_case << "</code></td>\n";
|
||||||
|
|
||||||
for ( int i = 0; i < sizeof(column)/sizeof(column_base&); ++i )
|
for (int i = 0; i < sizeof(column) / sizeof(column_base&); ++i)
|
||||||
{
|
{
|
||||||
do_cell( test_case, i );
|
do_cell(test_case, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile << "</tr>\n";
|
outfile << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// do_table ----------------------------------------------------------------//
|
// do_table ----------------------------------------------------------------//
|
||||||
|
|
||||||
void do_table()
|
void do_table()
|
||||||
{
|
{
|
||||||
outfile <<
|
outfile << "<h1>Path Decomposition Table</h1>\n"
|
||||||
"<h1>Path Decomposition Table</h1>\n"
|
|
||||||
"<p>Shaded entries indicate cases where <i>POSIX</i> and <i>Windows</i>\n"
|
"<p>Shaded entries indicate cases where <i>POSIX</i> and <i>Windows</i>\n"
|
||||||
"implementations yield different results. The top value is the\n"
|
"implementations yield different results. The top value is the\n"
|
||||||
"<i>POSIX</i> result and the bottom value is the <i>Windows</i> result.\n"
|
"<i>POSIX</i> result and the bottom value is the <i>Windows</i> result.\n"
|
||||||
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n"
|
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n"
|
||||||
"<p>\n"
|
"<p>\n";
|
||||||
;
|
|
||||||
|
|
||||||
// generate the column headings
|
// generate the column headings
|
||||||
|
|
||||||
outfile << "<tr><td><b>Constructor<br>argument</b></td>\n";
|
outfile << "<tr><td><b>Constructor<br>argument</b></td>\n";
|
||||||
|
|
||||||
for ( int i = 0; i < sizeof(column)/sizeof(column_base&); ++i )
|
for (int i = 0; i < sizeof(column) / sizeof(column_base&); ++i)
|
||||||
{
|
{
|
||||||
outfile << "<td><b>" << column[i]->heading() << "</b></td>\n";
|
outfile << "<td><b>" << column[i]->heading() << "</b></td>\n";
|
||||||
}
|
}
|
||||||
@ -174,16 +172,16 @@ namespace
|
|||||||
// generate a row for each input line
|
// generate a row for each input line
|
||||||
|
|
||||||
string test_case;
|
string test_case;
|
||||||
while ( std::getline( infile, test_case ) )
|
while (std::getline(infile, test_case))
|
||||||
{
|
{
|
||||||
if (!test_case.empty() && *--test_case.end() == '\r')
|
if (!test_case.empty() && *--test_case.end() == '\r')
|
||||||
test_case.erase(test_case.size()-1);
|
test_case.erase(test_case.size() - 1);
|
||||||
if (test_case.empty() || test_case[0] != '#')
|
if (test_case.empty() || test_case[0] != '#')
|
||||||
do_row( test_case );
|
do_row(test_case);
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile << "</table>\n";
|
outfile << "</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
@ -192,24 +190,22 @@ namespace
|
|||||||
#define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE
|
#define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE
|
||||||
#include <boost/test/included/prg_exec_monitor.hpp>
|
#include <boost/test/included/prg_exec_monitor.hpp>
|
||||||
|
|
||||||
int cpp_main( int argc, char * argv[] ) // note name!
|
int cpp_main(int argc, char* argv[]) // note name!
|
||||||
{
|
{
|
||||||
if ( argc != 5 )
|
if (argc != 5)
|
||||||
{
|
{
|
||||||
std::cerr <<
|
std::cerr << "Usage: path_table \"POSIX\"|\"Windows\" input-file posix-file output-file\n"
|
||||||
"Usage: path_table \"POSIX\"|\"Windows\" input-file posix-file output-file\n"
|
|
||||||
"Run on POSIX first, then on Windows\n"
|
"Run on POSIX first, then on Windows\n"
|
||||||
" \"POSIX\" causes POSIX results to be saved in posix-file;\n"
|
" \"POSIX\" causes POSIX results to be saved in posix-file;\n"
|
||||||
" \"Windows\" causes POSIX results read from posix-file\n"
|
" \"Windows\" causes POSIX results read from posix-file\n"
|
||||||
" input-file contains the paths to appear in the table.\n"
|
" input-file contains the paths to appear in the table.\n"
|
||||||
" posix-file will be used for POSIX results\n"
|
" posix-file will be used for POSIX results\n"
|
||||||
" output-file will contain the generated HTML.\n"
|
" output-file will contain the generated HTML.\n";
|
||||||
;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile.open( argv[2] );
|
infile.open(argv[2]);
|
||||||
if ( !infile )
|
if (!infile)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not open input file: " << argv[2] << std::endl;
|
std::cerr << "Could not open input file: " << argv[2] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
@ -218,8 +214,8 @@ int cpp_main( int argc, char * argv[] ) // note name!
|
|||||||
if (string(argv[1]) == "POSIX")
|
if (string(argv[1]) == "POSIX")
|
||||||
{
|
{
|
||||||
posix = true;
|
posix = true;
|
||||||
posix_outfile.open( argv[3] );
|
posix_outfile.open(argv[3]);
|
||||||
if ( !posix_outfile )
|
if (!posix_outfile)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not open POSIX output file: " << argv[3] << std::endl;
|
std::cerr << "Could not open POSIX output file: " << argv[3] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
@ -228,16 +224,16 @@ int cpp_main( int argc, char * argv[] ) // note name!
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
posix = false;
|
posix = false;
|
||||||
posix_infile.open( argv[3] );
|
posix_infile.open(argv[3]);
|
||||||
if ( !posix_infile )
|
if (!posix_infile)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not open POSIX input file: " << argv[3] << std::endl;
|
std::cerr << "Could not open POSIX input file: " << argv[3] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile.open( argv[4] );
|
outfile.open(argv[4]);
|
||||||
if ( !outfile )
|
if (!outfile)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not open output file: " << argv[2] << std::endl;
|
std::cerr << "Could not open output file: " << argv[2] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
@ -247,14 +243,12 @@ int cpp_main( int argc, char * argv[] ) // note name!
|
|||||||
"<head>\n"
|
"<head>\n"
|
||||||
"<title>Path Decomposition Table</title>\n"
|
"<title>Path Decomposition Table</title>\n"
|
||||||
"</head>\n"
|
"</head>\n"
|
||||||
"<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
|
"<body bgcolor=\"#ffffff\" text=\"#000000\">\n";
|
||||||
;
|
|
||||||
|
|
||||||
do_table();
|
do_table();
|
||||||
|
|
||||||
outfile << "</body>\n"
|
outfile << "</body>\n"
|
||||||
"</html>\n"
|
"</html>\n";
|
||||||
;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,18 @@
|
|||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
int cpp_main(int argc, char* argv[])
|
int cpp_main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
cout << "BOOST_WINDOWS_API" << endl;
|
cout << "BOOST_WINDOWS_API" << endl;
|
||||||
# else
|
#else
|
||||||
cout << "BOOST_POSIX_API" << endl;
|
cout << "BOOST_POSIX_API" << endl;
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
path test_dir(current_path() / "dspr_demo");
|
path test_dir(current_path() / "dspr_demo");
|
||||||
|
|
||||||
|
@ -24,69 +24,75 @@ using boost::system::error_code;
|
|||||||
using boost::system::system_error;
|
using boost::system::system_error;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
void report_system_error(const system_error& ex)
|
||||||
{
|
{
|
||||||
void report_system_error(const system_error& ex)
|
|
||||||
{
|
|
||||||
cout << " threw system_error:\n"
|
cout << " threw system_error:\n"
|
||||||
<< " ex.code().value() is " << ex.code().value() << '\n'
|
<< " ex.code().value() is " << ex.code().value() << '\n'
|
||||||
<< " ex.code().category().name() is " << ex.code().category().name() << '\n'
|
<< " ex.code().category().name() is " << ex.code().category().name() << '\n'
|
||||||
<< " ex.what() is " << ex.what() << '\n'
|
<< " ex.what() is " << ex.what() << '\n';
|
||||||
;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void report_filesystem_error(const system_error& ex)
|
void report_filesystem_error(const system_error& ex)
|
||||||
{
|
{
|
||||||
cout << " threw filesystem_error exception:\n"
|
cout << " threw filesystem_error exception:\n"
|
||||||
<< " ex.code().value() is " << ex.code().value() << '\n'
|
<< " ex.code().value() is " << ex.code().value() << '\n'
|
||||||
<< " ex.code().category().name() is " << ex.code().category().name() << '\n'
|
<< " ex.code().category().name() is " << ex.code().category().name() << '\n'
|
||||||
<< " ex.what() is " << ex.what() << '\n'
|
<< " ex.what() is " << ex.what() << '\n';
|
||||||
;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void report_status(fs::file_status s)
|
void report_status(fs::file_status s)
|
||||||
{
|
{
|
||||||
cout << " file_status::type() is ";
|
cout << " file_status::type() is ";
|
||||||
switch (s.type())
|
switch (s.type())
|
||||||
{
|
{
|
||||||
case fs::status_error:
|
case fs::status_error:
|
||||||
cout << "status_error\n"; break;
|
cout << "status_error\n";
|
||||||
|
break;
|
||||||
case fs::file_not_found:
|
case fs::file_not_found:
|
||||||
cout << "file_not_found\n"; break;
|
cout << "file_not_found\n";
|
||||||
|
break;
|
||||||
case fs::regular_file:
|
case fs::regular_file:
|
||||||
cout << "regular_file\n"; break;
|
cout << "regular_file\n";
|
||||||
|
break;
|
||||||
case fs::directory_file:
|
case fs::directory_file:
|
||||||
cout << "directory_file\n"; break;
|
cout << "directory_file\n";
|
||||||
|
break;
|
||||||
case fs::symlink_file:
|
case fs::symlink_file:
|
||||||
cout << "symlink_file\n"; break;
|
cout << "symlink_file\n";
|
||||||
|
break;
|
||||||
case fs::block_file:
|
case fs::block_file:
|
||||||
cout << "block_file\n"; break;
|
cout << "block_file\n";
|
||||||
|
break;
|
||||||
case fs::character_file:
|
case fs::character_file:
|
||||||
cout << "character_file\n"; break;
|
cout << "character_file\n";
|
||||||
|
break;
|
||||||
case fs::fifo_file:
|
case fs::fifo_file:
|
||||||
cout << "fifo_file\n"; break;
|
cout << "fifo_file\n";
|
||||||
|
break;
|
||||||
case fs::socket_file:
|
case fs::socket_file:
|
||||||
cout << "socket_file\n"; break;
|
cout << "socket_file\n";
|
||||||
|
break;
|
||||||
case fs::type_unknown:
|
case fs::type_unknown:
|
||||||
cout << "type_unknown\n"; break;
|
cout << "type_unknown\n";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
cout << "not a valid enumeration constant\n";
|
cout << "not a valid enumeration constant\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_error_code(const error_code& ec)
|
void report_error_code(const error_code& ec)
|
||||||
{
|
{
|
||||||
cout << " ec:\n"
|
cout << " ec:\n"
|
||||||
<< " value() is " << ec.value() << '\n'
|
<< " value() is " << ec.value() << '\n'
|
||||||
<< " category().name() is " << ec.category().name() << '\n'
|
<< " category().name() is " << ec.category().name() << '\n'
|
||||||
<< " message() is " << ec.message() << '\n'
|
<< " message() is " << ec.message() << '\n';
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool threw_exception;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool threw_exception;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
@ -108,10 +114,10 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
//// construct path - with error_code
|
//// construct path - with error_code
|
||||||
|
|
||||||
path p (argv[1]);
|
path p(argv[1]);
|
||||||
|
|
||||||
fs::file_status s;
|
fs::file_status s;
|
||||||
bool b (false);
|
bool b(false);
|
||||||
fs::directory_iterator di;
|
fs::directory_iterator di;
|
||||||
|
|
||||||
// get status - no error_code
|
// get status - no error_code
|
||||||
@ -119,7 +125,10 @@ int main(int argc, char* argv[])
|
|||||||
cout << "\nstatus(\"" << p.string() << "\");\n";
|
cout << "\nstatus(\"" << p.string() << "\");\n";
|
||||||
threw_exception = false;
|
threw_exception = false;
|
||||||
|
|
||||||
try { s = fs::status(p); }
|
try
|
||||||
|
{
|
||||||
|
s = fs::status(p);
|
||||||
|
}
|
||||||
catch (const system_error& ex)
|
catch (const system_error& ex)
|
||||||
{
|
{
|
||||||
report_filesystem_error(ex);
|
report_filesystem_error(ex);
|
||||||
@ -141,7 +150,10 @@ int main(int argc, char* argv[])
|
|||||||
cout << "\nexists(\"" << p.string() << "\");\n";
|
cout << "\nexists(\"" << p.string() << "\");\n";
|
||||||
threw_exception = false;
|
threw_exception = false;
|
||||||
|
|
||||||
try { b = fs::exists(p); }
|
try
|
||||||
|
{
|
||||||
|
b = fs::exists(p);
|
||||||
|
}
|
||||||
catch (const system_error& ex)
|
catch (const system_error& ex)
|
||||||
{
|
{
|
||||||
report_filesystem_error(ex);
|
report_filesystem_error(ex);
|
||||||
@ -160,7 +172,10 @@ int main(int argc, char* argv[])
|
|||||||
cout << "\ndirectory_iterator(\"" << p.string() << "\");\n";
|
cout << "\ndirectory_iterator(\"" << p.string() << "\");\n";
|
||||||
threw_exception = false;
|
threw_exception = false;
|
||||||
|
|
||||||
try { di = fs::directory_iterator(p); }
|
try
|
||||||
|
{
|
||||||
|
di = fs::directory_iterator(p);
|
||||||
|
}
|
||||||
catch (const system_error& ex)
|
catch (const system_error& ex)
|
||||||
{
|
{
|
||||||
report_filesystem_error(ex);
|
report_filesystem_error(ex);
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( argc != 2 )
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
std::cout << "Usage: file_size path\n";
|
std::cout << "Usage: file_size path\n";
|
||||||
return 1;
|
return 1;
|
||||||
@ -24,21 +24,21 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << '\n';
|
std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << '\n';
|
||||||
|
|
||||||
fs::path p( argv[1] );
|
fs::path p(argv[1]);
|
||||||
|
|
||||||
if ( !fs::exists( p ) )
|
if (!fs::exists(p))
|
||||||
{
|
{
|
||||||
std::cout << "not found: " << argv[1] << std::endl;
|
std::cout << "not found: " << argv[1] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !fs::is_regular( p ) )
|
if (!fs::is_regular(p))
|
||||||
{
|
{
|
||||||
std::cout << "not a regular file: " << argv[1] << std::endl;
|
std::cout << "not a regular file: " << argv[1] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "size of " << argv[1] << " is " << fs::file_size( p )
|
std::cout << "size of " << argv[1] << " is " << fs::file_size(p)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,42 +13,41 @@
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
|
|
||||||
using std::cout; using std::endl;
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
path p;
|
|
||||||
|
|
||||||
void print_boost_macros()
|
path p;
|
||||||
{
|
|
||||||
|
void print_boost_macros()
|
||||||
|
{
|
||||||
std::cout << "Boost "
|
std::cout << "Boost "
|
||||||
<< BOOST_VERSION / 100000 << '.'
|
<< BOOST_VERSION / 100000 << '.'
|
||||||
<< BOOST_VERSION / 100 % 1000 << '.'
|
<< BOOST_VERSION / 100 % 1000 << '.'
|
||||||
<< BOOST_VERSION % 100 << ", "
|
<< BOOST_VERSION % 100 << ", "
|
||||||
# ifndef _WIN64
|
#ifndef _WIN64
|
||||||
<< BOOST_COMPILER << ", "
|
<< BOOST_COMPILER << ", "
|
||||||
# else
|
#else
|
||||||
<< BOOST_COMPILER << " with _WIN64 defined, "
|
<< BOOST_COMPILER << " with _WIN64 defined, "
|
||||||
# endif
|
#endif
|
||||||
<< BOOST_STDLIB << ", "
|
<< BOOST_STDLIB << ", "
|
||||||
<< BOOST_PLATFORM
|
<< BOOST_PLATFORM
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* file_type_tab[] =
|
const char* file_type_tab[] = { "status_error", "file_not_found", "regular_file", "directory_file",
|
||||||
{ "status_error", "file_not_found", "regular_file", "directory_file",
|
|
||||||
"symlink_file", "block_file", "character_file", "fifo_file", "socket_file",
|
"symlink_file", "block_file", "character_file", "fifo_file", "socket_file",
|
||||||
"type_unknown"
|
"type_unknown" };
|
||||||
};
|
|
||||||
|
|
||||||
const char* file_type_c_str(enum file_type t)
|
const char* file_type_c_str(enum file_type t)
|
||||||
{
|
{
|
||||||
return file_type_tab[t];
|
return file_type_tab[t];
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_status(file_status s, boost::system::error_code ec)
|
void show_status(file_status s, boost::system::error_code ec)
|
||||||
{
|
{
|
||||||
boost::system::error_condition econd;
|
boost::system::error_condition econd;
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
@ -72,10 +71,10 @@ namespace
|
|||||||
cout << "is_directory(s) is " << (is_directory(s) ? "true" : "false") << "\n";
|
cout << "is_directory(s) is " << (is_directory(s) ? "true" : "false") << "\n";
|
||||||
cout << "is_other(s) is " << (is_other(s) ? "true" : "false") << "\n";
|
cout << "is_other(s) is " << (is_other(s) ? "true" : "false") << "\n";
|
||||||
cout << "is_symlink(s) is " << (is_symlink(s) ? "true" : "false") << "\n";
|
cout << "is_symlink(s) is " << (is_symlink(s) ? "true" : "false") << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void try_exists()
|
void try_exists()
|
||||||
{
|
{
|
||||||
cout << "\nexists(" << p << ") ";
|
cout << "\nexists(" << p << ") ";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -86,10 +85,10 @@ namespace
|
|||||||
{
|
{
|
||||||
cout << "throws a filesystem_error exception: " << ex.what() << "\n";
|
cout << "throws a filesystem_error exception: " << ex.what() << "\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int cpp_main(int argc, char* argv[])
|
int cpp_main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
print_boost_macros();
|
print_boost_macros();
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
# ifdef BOOST_FILESYSTEM_NARROW_ONLY
|
#ifdef BOOST_FILESYSTEM_NARROW_ONLY
|
||||||
# error This compiler or standard library does not support wide-character strings or paths
|
#error This compiler or standard library does not support wide-character strings or paths
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include "mbpath.hpp"
|
#include "mbpath.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -25,33 +25,48 @@
|
|||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
|
||||||
|
// we can't use boost::filesystem::copy_file() because the argument types
|
||||||
|
// differ, so provide a not-very-smart replacement.
|
||||||
|
void copy_file(const fs::wpath& from, const user::mbpath& to)
|
||||||
{
|
{
|
||||||
// we can't use boost::filesystem::copy_file() because the argument types
|
fs::ifstream from_file(from, std::ios_base::in | std::ios_base::binary);
|
||||||
// differ, so provide a not-very-smart replacement.
|
if (!from_file)
|
||||||
|
|
||||||
void copy_file( const fs::wpath & from, const user::mbpath & to )
|
|
||||||
{
|
{
|
||||||
fs::ifstream from_file( from, std::ios_base::in | std::ios_base::binary );
|
std::cout << "input open failed\n";
|
||||||
if ( !from_file ) { std::cout << "input open failed\n"; return; }
|
return;
|
||||||
|
|
||||||
fs::ofstream to_file( to, std::ios_base::out | std::ios_base::binary );
|
|
||||||
if ( !to_file ) { std::cout << "output open failed\n"; return; }
|
|
||||||
|
|
||||||
char c;
|
|
||||||
while ( from_file.get(c) )
|
|
||||||
{
|
|
||||||
to_file.put(c);
|
|
||||||
if ( to_file.fail() ) { std::cout << "write error\n"; return; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !from_file.eof() ) { std::cout << "read error\n"; }
|
fs::ofstream to_file(to, std::ios_base::out | std::ios_base::binary);
|
||||||
|
if (!to_file)
|
||||||
|
{
|
||||||
|
std::cout << "output open failed\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char c;
|
||||||
|
while (from_file.get(c))
|
||||||
|
{
|
||||||
|
to_file.put(c);
|
||||||
|
if (to_file.fail())
|
||||||
|
{
|
||||||
|
std::cout << "write error\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!from_file.eof())
|
||||||
|
{
|
||||||
|
std::cout << "read error\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char * argv[] )
|
} // namespace
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if ( argc != 2 )
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
std::cout << "Copy files in the current directory to a target directory\n"
|
std::cout << "Copy files in the current directory to a target directory\n"
|
||||||
<< "Usage: mbcopy <target-dir>\n";
|
<< "Usage: mbcopy <target-dir>\n";
|
||||||
@ -60,31 +75,26 @@ int main( int argc, char * argv[] )
|
|||||||
|
|
||||||
// For encoding, use Boost UTF-8 codecvt
|
// For encoding, use Boost UTF-8 codecvt
|
||||||
std::locale global_loc = std::locale();
|
std::locale global_loc = std::locale();
|
||||||
std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet );
|
std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
|
||||||
user::mbpath_traits::imbue( loc );
|
user::mbpath_traits::imbue(loc);
|
||||||
|
|
||||||
std::string target_string( argv[1] );
|
std::string target_string(argv[1]);
|
||||||
user::mbpath target_dir( user::mbpath_traits::to_internal( target_string ) );
|
user::mbpath target_dir(user::mbpath_traits::to_internal(target_string));
|
||||||
|
|
||||||
if ( !fs::is_directory( target_dir ) )
|
if (!fs::is_directory(target_dir))
|
||||||
{
|
{
|
||||||
std::cout << "Error: " << argv[1] << " is not a directory\n";
|
std::cout << "Error: " << argv[1] << " is not a directory\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( fs::wdirectory_iterator it( L"." );
|
for (fs::wdirectory_iterator it(L".");
|
||||||
it != fs::wdirectory_iterator(); ++it )
|
it != fs::wdirectory_iterator(); ++it)
|
||||||
{
|
{
|
||||||
if ( fs::is_regular_file(it->status()) )
|
if (fs::is_regular_file(it->status()))
|
||||||
{
|
{
|
||||||
copy_file( *it, target_dir / it->path().filename() );
|
copy_file(*it, target_dir / it->path().filename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
// See Boost.Filesystem home page at http://www.boost.org/libs/filesystem
|
// See Boost.Filesystem home page at http://www.boost.org/libs/filesystem
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
# ifdef BOOST_FILESYSTEM_NARROW_ONLY
|
#ifdef BOOST_FILESYSTEM_NARROW_ONLY
|
||||||
# error This compiler or standard library does not support wide-character strings or paths
|
#error This compiler or standard library does not support wide-character strings or paths
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include "mbpath.hpp"
|
#include "mbpath.hpp"
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
@ -19,62 +19,60 @@
|
|||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
// ISO C calls this "the locale-specific native environment":
|
|
||||||
std::locale loc("");
|
|
||||||
|
|
||||||
const std::codecvt<wchar_t, char, std::mbstate_t> *
|
// ISO C calls this "the locale-specific native environment":
|
||||||
cvt( &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
|
std::locale loc("");
|
||||||
( loc ) );
|
|
||||||
|
const std::codecvt< wchar_t, char, std::mbstate_t >*
|
||||||
|
cvt(&std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc));
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace user {
|
||||||
|
|
||||||
|
mbpath_traits::external_string_type
|
||||||
|
mbpath_traits::to_external(const mbpath& ph, const internal_string_type& src)
|
||||||
|
{
|
||||||
|
std::size_t work_size(cvt->max_length() * (src.size() + 1));
|
||||||
|
boost::scoped_array< char > work(new char[work_size]);
|
||||||
|
std::mbstate_t state;
|
||||||
|
const internal_string_type::value_type* from_next;
|
||||||
|
external_string_type::value_type* to_next;
|
||||||
|
if (cvt->out(
|
||||||
|
state, src.c_str(), src.c_str() + src.size(), from_next, work.get(),
|
||||||
|
work.get() + work_size, to_next) != std::codecvt_base::ok)
|
||||||
|
boost::throw_exception< fs::basic_filesystem_error< mbpath > >(
|
||||||
|
fs::basic_filesystem_error< mbpath >(
|
||||||
|
"user::mbpath::to_external conversion error",
|
||||||
|
ph, boost::system::error_code(EINVAL, boost::system::errno_ecat)));
|
||||||
|
*to_next = '\0';
|
||||||
|
return external_string_type(work.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace user
|
mbpath_traits::internal_string_type
|
||||||
|
mbpath_traits::to_internal(const external_string_type& src)
|
||||||
{
|
{
|
||||||
mbpath_traits::external_string_type
|
std::size_t work_size(src.size() + 1);
|
||||||
mbpath_traits::to_external( const mbpath & ph,
|
boost::scoped_array< wchar_t > work(new wchar_t[work_size]);
|
||||||
const internal_string_type & src )
|
|
||||||
{
|
|
||||||
std::size_t work_size( cvt->max_length() * (src.size()+1) );
|
|
||||||
boost::scoped_array<char> work( new char[ work_size ] );
|
|
||||||
std::mbstate_t state;
|
std::mbstate_t state;
|
||||||
const internal_string_type::value_type * from_next;
|
const external_string_type::value_type* from_next;
|
||||||
external_string_type::value_type * to_next;
|
internal_string_type::value_type* to_next;
|
||||||
if ( cvt->out(
|
if (cvt->in(
|
||||||
state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
|
state, src.c_str(), src.c_str() + src.size(), from_next, work.get(),
|
||||||
work.get()+work_size, to_next ) != std::codecvt_base::ok )
|
work.get() + work_size, to_next) != std::codecvt_base::ok)
|
||||||
boost::throw_exception<fs::basic_filesystem_error<mbpath> >(
|
boost::throw_exception< fs::basic_filesystem_error< mbpath > >(
|
||||||
fs::basic_filesystem_error<mbpath>(
|
fs::basic_filesystem_error< mbpath >(
|
||||||
"user::mbpath::to_external conversion error",
|
|
||||||
ph, boost::system::error_code( EINVAL, boost::system::errno_ecat ) ) );
|
|
||||||
*to_next = '\0';
|
|
||||||
return external_string_type( work.get() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mbpath_traits::internal_string_type
|
|
||||||
mbpath_traits::to_internal( const external_string_type & src )
|
|
||||||
{
|
|
||||||
std::size_t work_size( src.size()+1 );
|
|
||||||
boost::scoped_array<wchar_t> work( new wchar_t[ work_size ] );
|
|
||||||
std::mbstate_t state;
|
|
||||||
const external_string_type::value_type * from_next;
|
|
||||||
internal_string_type::value_type * to_next;
|
|
||||||
if ( cvt->in(
|
|
||||||
state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
|
|
||||||
work.get()+work_size, to_next ) != std::codecvt_base::ok )
|
|
||||||
boost::throw_exception<fs::basic_filesystem_error<mbpath> >(
|
|
||||||
fs::basic_filesystem_error<mbpath>(
|
|
||||||
"user::mbpath::to_internal conversion error",
|
"user::mbpath::to_internal conversion error",
|
||||||
boost::system::error_code( EINVAL, boost::system::errno_ecat ) ) );
|
boost::system::error_code(EINVAL, boost::system::errno_ecat)));
|
||||||
*to_next = L'\0';
|
*to_next = L'\0';
|
||||||
return internal_string_type( work.get() );
|
return internal_string_type(work.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbpath_traits::imbue( const std::locale & new_loc )
|
void mbpath_traits::imbue(const std::locale& new_loc)
|
||||||
{
|
{
|
||||||
loc = new_loc;
|
loc = new_loc;
|
||||||
cvt = &std::use_facet
|
cvt = &std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc);
|
||||||
<std::codecvt<wchar_t, char, std::mbstate_t> >( loc );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace user
|
} // namespace user
|
||||||
|
@ -14,31 +14,34 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
namespace user
|
namespace user {
|
||||||
|
|
||||||
|
struct mbpath_traits;
|
||||||
|
|
||||||
|
typedef boost::filesystem::basic_path< std::wstring, mbpath_traits > mbpath;
|
||||||
|
|
||||||
|
struct mbpath_traits
|
||||||
{
|
{
|
||||||
struct mbpath_traits;
|
|
||||||
|
|
||||||
typedef boost::filesystem::basic_path<std::wstring, mbpath_traits> mbpath;
|
|
||||||
|
|
||||||
struct mbpath_traits
|
|
||||||
{
|
|
||||||
typedef std::wstring internal_string_type;
|
typedef std::wstring internal_string_type;
|
||||||
typedef std::string external_string_type;
|
typedef std::string external_string_type;
|
||||||
|
|
||||||
static external_string_type to_external( const mbpath & ph,
|
static external_string_type to_external(const mbpath& ph, const internal_string_type& src);
|
||||||
const internal_string_type & src );
|
|
||||||
|
|
||||||
static internal_string_type to_internal( const external_string_type & src );
|
static internal_string_type to_internal(const external_string_type& src);
|
||||||
|
|
||||||
|
static void imbue(const std::locale& loc);
|
||||||
|
};
|
||||||
|
|
||||||
static void imbue( const std::locale & loc );
|
|
||||||
};
|
|
||||||
} // namespace user
|
} // namespace user
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_basic_path< user::mbpath >
|
||||||
{
|
{
|
||||||
namespace filesystem
|
static const bool value = true;
|
||||||
{
|
};
|
||||||
template<> struct is_basic_path<user::mbpath>
|
|
||||||
{ static const bool value = true; };
|
} // namespace filesystem
|
||||||
}
|
} // namespace boost
|
||||||
}
|
|
||||||
|
@ -9,10 +9,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
const char * say_what(bool b) { return b ? "true" : "false"; }
|
const char* say_what(bool b)
|
||||||
|
{
|
||||||
|
return b ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@ -21,11 +25,11 @@ int main(int argc, char* argv[])
|
|||||||
cout << "Usage: path_info path-element [path-element...]\n"
|
cout << "Usage: path_info path-element [path-element...]\n"
|
||||||
"Composes a path via operator/= from one or more path-element arguments\n"
|
"Composes a path via operator/= from one or more path-element arguments\n"
|
||||||
"Example: path_info foo/bar baz\n"
|
"Example: path_info foo/bar baz\n"
|
||||||
# ifdef BOOST_POSIX_API
|
#ifdef BOOST_POSIX_API
|
||||||
" would report info about the composed path foo/bar/baz\n";
|
" would report info about the composed path foo/bar/baz\n";
|
||||||
# else // BOOST_WINDOWS_API
|
#else // BOOST_WINDOWS_API
|
||||||
" would report info about the composed path foo/bar\\baz\n";
|
" would report info about the composed path foo/bar\\baz\n";
|
||||||
# endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,13 +46,13 @@ int main(int argc, char* argv[])
|
|||||||
cout << " " << element << '\n';
|
cout << " " << element << '\n';
|
||||||
|
|
||||||
cout << "\nobservers, native format:" << endl;
|
cout << "\nobservers, native format:" << endl;
|
||||||
# ifdef BOOST_POSIX_API
|
#ifdef BOOST_POSIX_API
|
||||||
cout << " native()-------------: " << p.native() << endl;
|
cout << " native()-------------: " << p.native() << endl;
|
||||||
cout << " c_str()--------------: " << p.c_str() << endl;
|
cout << " c_str()--------------: " << p.c_str() << endl;
|
||||||
# else // BOOST_WINDOWS_API
|
#else // BOOST_WINDOWS_API
|
||||||
wcout << L" native()-------------: " << p.native() << endl;
|
wcout << L" native()-------------: " << p.native() << endl;
|
||||||
wcout << L" c_str()--------------: " << p.c_str() << endl;
|
wcout << L" c_str()--------------: " << p.c_str() << endl;
|
||||||
# endif
|
#endif
|
||||||
cout << " string()-------------: " << p.string() << endl;
|
cout << " string()-------------: " << p.string() << endl;
|
||||||
wcout << L" wstring()------------: " << p.wstring() << endl;
|
wcout << L" wstring()------------: " << p.wstring() << endl;
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
// As an example program, we don't want to use any deprecated features
|
// As an example program, we don't want to use any deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
@ -70,15 +70,15 @@ int main(int argc, char* argv[])
|
|||||||
++other_count;
|
++other_count;
|
||||||
std::cout << dir_itr->path().filename() << " [other]\n";
|
std::cout << dir_itr->path().filename() << " [other]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception & ex)
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
++err_count;
|
++err_count;
|
||||||
std::cout << dir_itr->path().filename() << " " << ex.what() << std::endl;
|
std::cout << dir_itr->path().filename() << " " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "\n" << file_count << " files\n"
|
std::cout << "\n"
|
||||||
|
<< file_count << " files\n"
|
||||||
<< dir_count << " directories\n"
|
<< dir_count << " directories\n"
|
||||||
<< other_count << " others\n"
|
<< other_count << " others\n"
|
||||||
<< err_count << " errors\n";
|
<< err_count << " errors\n";
|
||||||
|
@ -20,7 +20,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
boost::filesystem::path p(argv[1]), name(p.filename());
|
boost::filesystem::path p(argv[1]), name(p.filename());
|
||||||
|
|
||||||
for(;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
std::cout << "filename " << name << " has stem " << name.stem()
|
std::cout << "filename " << name << " has stem " << name.stem()
|
||||||
<< " and extension " << name.extension() << "\n";
|
<< " and extension " << name.extension() << "\n";
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
typedef std::basic_string<TCHAR> tstring;
|
typedef std::basic_string< TCHAR > tstring;
|
||||||
|
|
||||||
void func( const fs::path & p )
|
void func(fs::path const& p)
|
||||||
{
|
{
|
||||||
assert( fs::exists( p ) );
|
assert(fs::exists(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -27,13 +27,13 @@ int main()
|
|||||||
fs::path cp = fs::current_path();
|
fs::path cp = fs::current_path();
|
||||||
|
|
||||||
// demo: get tstring from the path
|
// demo: get tstring from the path
|
||||||
tstring cp_as_tstring = cp.string<tstring>();
|
tstring cp_as_tstring = cp.string< tstring >();
|
||||||
|
|
||||||
// demo: pass tstring to filesystem function taking path
|
// demo: pass tstring to filesystem function taking path
|
||||||
assert( fs::exists( cp_as_tstring ) );
|
assert(fs::exists(cp_as_tstring));
|
||||||
|
|
||||||
// demo: pass tstring to user function taking path
|
// demo: pass tstring to user function taking path
|
||||||
func( cp_as_tstring );
|
func(cp_as_tstring);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
@ -26,10 +27,8 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
if (is_regular_file(p)) // is path p a regular file?
|
if (is_regular_file(p)) // is path p a regular file?
|
||||||
cout << p << " size is " << file_size(p) << '\n';
|
cout << p << " size is " << file_size(p) << '\n';
|
||||||
|
|
||||||
else if (is_directory(p)) // is path p a directory?
|
else if (is_directory(p)) // is path p a directory?
|
||||||
cout << p << " is a directory\n";
|
cout << p << " is a directory\n";
|
||||||
|
|
||||||
else
|
else
|
||||||
cout << p << " exists, but is not a regular file or directory\n";
|
cout << p << " exists, but is not a regular file or directory\n";
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
@ -20,20 +21,21 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
path p (argv[1]);
|
path p(argv[1]);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (exists(p))
|
if (exists(p))
|
||||||
{
|
{
|
||||||
if (is_regular_file(p))
|
if (is_regular_file(p))
|
||||||
|
{
|
||||||
cout << p << " size is " << file_size(p) << '\n';
|
cout << p << " size is " << file_size(p) << '\n';
|
||||||
|
}
|
||||||
else if (is_directory(p))
|
else if (is_directory(p))
|
||||||
{
|
{
|
||||||
cout << p << " is a directory containing:\n";
|
cout << p << " is a directory containing:\n";
|
||||||
|
|
||||||
for (const directory_entry& x : directory_iterator(p))
|
for (directory_entry const& x : directory_iterator(p))
|
||||||
cout << " " << x.path() << '\n';
|
cout << " " << x.path() << '\n';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -42,8 +44,7 @@ int main(int argc, char* argv[])
|
|||||||
else
|
else
|
||||||
cout << p << " does not exist\n";
|
cout << p << " does not exist\n";
|
||||||
}
|
}
|
||||||
|
catch (filesystem_error& ex)
|
||||||
catch (const filesystem_error& ex)
|
|
||||||
{
|
{
|
||||||
cout << ex.what() << '\n';
|
cout << ex.what() << '\n';
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
@ -22,20 +23,21 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
path p (argv[1]);
|
path p(argv[1]);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (exists(p))
|
if (exists(p))
|
||||||
{
|
{
|
||||||
if (is_regular_file(p))
|
if (is_regular_file(p))
|
||||||
|
{
|
||||||
cout << p << " size is " << file_size(p) << '\n';
|
cout << p << " size is " << file_size(p) << '\n';
|
||||||
|
}
|
||||||
else if (is_directory(p))
|
else if (is_directory(p))
|
||||||
{
|
{
|
||||||
cout << p << " is a directory containing:\n";
|
cout << p << " is a directory containing:\n";
|
||||||
|
|
||||||
std::vector<path> v;
|
std::vector< path > v;
|
||||||
|
|
||||||
for (auto&& x : directory_iterator(p))
|
for (auto&& x : directory_iterator(p))
|
||||||
v.push_back(x.path());
|
v.push_back(x.path());
|
||||||
@ -51,8 +53,7 @@ int main(int argc, char* argv[])
|
|||||||
else
|
else
|
||||||
cout << p << " does not exist\n";
|
cout << p << " does not exist\n";
|
||||||
}
|
}
|
||||||
|
catch (filesystem_error& ex)
|
||||||
catch (const filesystem_error& ex)
|
|
||||||
{
|
{
|
||||||
cout << ex.what() << '\n';
|
cout << ex.what() << '\n';
|
||||||
}
|
}
|
||||||
|
@ -10,21 +10,22 @@
|
|||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// \u263A is "Unicode WHITE SMILING FACE = have a nice day!"
|
// \u263A is "Unicode WHITE SMILING FACE = have a nice day!"
|
||||||
std::string narrow_string ("smile2");
|
std::string narrow_string("smile2");
|
||||||
std::wstring wide_string (L"smile2\u263A");
|
std::wstring wide_string(L"smile2\u263A");
|
||||||
std::list<char> narrow_list;
|
std::list< char > narrow_list;
|
||||||
narrow_list.push_back('s');
|
narrow_list.push_back('s');
|
||||||
narrow_list.push_back('m');
|
narrow_list.push_back('m');
|
||||||
narrow_list.push_back('i');
|
narrow_list.push_back('i');
|
||||||
narrow_list.push_back('l');
|
narrow_list.push_back('l');
|
||||||
narrow_list.push_back('e');
|
narrow_list.push_back('e');
|
||||||
narrow_list.push_back('3');
|
narrow_list.push_back('3');
|
||||||
std::list<wchar_t> wide_list;
|
std::list< wchar_t > wide_list;
|
||||||
wide_list.push_back(L's');
|
wide_list.push_back(L's');
|
||||||
wide_list.push_back(L'm');
|
wide_list.push_back(L'm');
|
||||||
wide_list.push_back(L'i');
|
wide_list.push_back(L'i');
|
||||||
@ -33,20 +34,36 @@ int main()
|
|||||||
wide_list.push_back(L'3');
|
wide_list.push_back(L'3');
|
||||||
wide_list.push_back(L'\u263A');
|
wide_list.push_back(L'\u263A');
|
||||||
|
|
||||||
{ fs::ofstream f("smile"); }
|
{
|
||||||
{ fs::ofstream f(L"smile\u263A"); }
|
fs::ofstream f("smile");
|
||||||
{ fs::ofstream f(narrow_string); }
|
}
|
||||||
{ fs::ofstream f(wide_string); }
|
{
|
||||||
{ fs::ofstream f(narrow_list); }
|
fs::ofstream f(L"smile\u263A");
|
||||||
{ fs::ofstream f(wide_list); }
|
}
|
||||||
|
{
|
||||||
|
fs::ofstream f(narrow_string);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
fs::ofstream f(wide_string);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
fs::ofstream f(narrow_list);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
fs::ofstream f(wide_list);
|
||||||
|
}
|
||||||
narrow_list.pop_back();
|
narrow_list.pop_back();
|
||||||
narrow_list.push_back('4');
|
narrow_list.push_back('4');
|
||||||
wide_list.pop_back();
|
wide_list.pop_back();
|
||||||
wide_list.pop_back();
|
wide_list.pop_back();
|
||||||
wide_list.push_back(L'4');
|
wide_list.push_back(L'4');
|
||||||
wide_list.push_back(L'\u263A');
|
wide_list.push_back(L'\u263A');
|
||||||
{ fs::ofstream f(fs::path(narrow_list.begin(), narrow_list.end())); }
|
{
|
||||||
{ fs::ofstream f(fs::path(wide_list.begin(), wide_list.end())); }
|
fs::ofstream f(fs::path(narrow_list.begin(), narrow_list.end()));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
fs::ofstream f(fs::path(wide_list.begin(), wide_list.end()));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -22,7 +23,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (recursive_directory_iterator it (argv[1]);
|
for (recursive_directory_iterator it(argv[1]);
|
||||||
it != recursive_directory_iterator();
|
it != recursive_directory_iterator();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
@ -37,8 +38,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (std::exception& ex)
|
||||||
catch (const std::exception& ex)
|
|
||||||
{
|
{
|
||||||
std::cout << "************* exception *****************\n";
|
std::cout << "************* exception *****************\n";
|
||||||
std::cout << ex.what() << '\n';
|
std::cout << ex.what() << '\n';
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -22,25 +23,26 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (recursive_directory_iterator it (argv[1]);
|
for (recursive_directory_iterator it(argv[1]);
|
||||||
it != recursive_directory_iterator();
|
it != recursive_directory_iterator();)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= it.level(); ++i)
|
for (int i = 0; i <= it.level(); ++i)
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
|
||||||
std::cout << it->path() << '\n';
|
std::cout << it->path() << '\n';
|
||||||
|
|
||||||
try { ++it; }
|
try
|
||||||
catch (const filesystem_error& ex)
|
{
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
catch (filesystem_error& ex)
|
||||||
{
|
{
|
||||||
std::cout << "************* filesystem_error *****************\n";
|
std::cout << "************* filesystem_error *****************\n";
|
||||||
std::cout << ex.what() << '\n';
|
std::cout << ex.what() << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (std::exception& ex)
|
||||||
catch (const std::exception& ex)
|
|
||||||
{
|
{
|
||||||
std::cout << "************* exception *****************\n";
|
std::cout << "************* exception *****************\n";
|
||||||
std::cout << ex.what() << '\n';
|
std::cout << ex.what() << '\n';
|
||||||
|
@ -24,9 +24,8 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
for (recursive_directory_iterator it (argv[1], ec);
|
for (recursive_directory_iterator it(argv[1], ec);
|
||||||
it != recursive_directory_iterator();
|
it != recursive_directory_iterator();)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= it.level(); ++i)
|
for (int i = 0; i <= it.level(); ++i)
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
#ifndef BOOST_FILESYSTEM_FILESYSTEM_HPP
|
#ifndef BOOST_FILESYSTEM_FILESYSTEM_HPP
|
||||||
#define BOOST_FILESYSTEM_FILESYSTEM_HPP
|
#define BOOST_FILESYSTEM_FILESYSTEM_HPP
|
||||||
|
|
||||||
# include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
# include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
# include <boost/filesystem/exception.hpp>
|
#include <boost/filesystem/exception.hpp>
|
||||||
# include <boost/filesystem/directory.hpp>
|
#include <boost/filesystem/directory.hpp>
|
||||||
# include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
# include <boost/filesystem/file_status.hpp>
|
#include <boost/filesystem/file_status.hpp>
|
||||||
# include <boost/filesystem/convenience.hpp>
|
#include <boost/filesystem/convenience.hpp>
|
||||||
# include <boost/filesystem/string_file.hpp>
|
#include <boost/filesystem/string_file.hpp>
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM_FILESYSTEM_HPP
|
#endif // BOOST_FILESYSTEM_FILESYSTEM_HPP
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
#ifndef BOOST_FILESYSTEM3_CONFIG_HPP
|
#ifndef BOOST_FILESYSTEM3_CONFIG_HPP
|
||||||
#define BOOST_FILESYSTEM3_CONFIG_HPP
|
#define BOOST_FILESYSTEM3_CONFIG_HPP
|
||||||
|
|
||||||
# if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3
|
#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3
|
||||||
# error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
|
#error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# if !defined(BOOST_FILESYSTEM_VERSION)
|
#if !defined(BOOST_FILESYSTEM_VERSION)
|
||||||
# define BOOST_FILESYSTEM_VERSION 3
|
#define BOOST_FILESYSTEM_VERSION 3
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
|
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
|
||||||
|
|
||||||
@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
// BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
|
// BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
|
||||||
|
|
||||||
# ifdef BOOST_FILESYSTEM_SOURCE
|
#ifdef BOOST_FILESYSTEM_SOURCE
|
||||||
# define BOOST_FILESYSTEM_DEPRECATED
|
#define BOOST_FILESYSTEM_DEPRECATED
|
||||||
# undef BOOST_FILESYSTEM_NO_DEPRECATED // fixes #9454, src bld fails if NO_DEP defined
|
#undef BOOST_FILESYSTEM_NO_DEPRECATED // fixes #9454, src bld fails if NO_DEP defined
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
// throw an exception ----------------------------------------------------------------//
|
// throw an exception ----------------------------------------------------------------//
|
||||||
//
|
//
|
||||||
@ -46,50 +46,48 @@
|
|||||||
|
|
||||||
#define BOOST_FILESYSTEM_THROW(EX) throw EX
|
#define BOOST_FILESYSTEM_THROW(EX) throw EX
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
// This header implements separate compilation features as described in
|
// This header implements separate compilation features as described in
|
||||||
// http://www.boost.org/more/separate_compilation.html
|
// http://www.boost.org/more/separate_compilation.html
|
||||||
|
|
||||||
// normalize macros ------------------------------------------------------------------//
|
// normalize macros ------------------------------------------------------------------//
|
||||||
|
|
||||||
#if !defined(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) \
|
#if !defined(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
|
||||||
&& !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
|
#define BOOST_FILESYSTEM_STATIC_LINK
|
||||||
# define BOOST_FILESYSTEM_STATIC_LINK
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_FILESYSTEM_DYN_LINK)
|
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||||
# define BOOST_FILESYSTEM_DYN_LINK
|
#define BOOST_FILESYSTEM_DYN_LINK
|
||||||
#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
|
#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
|
||||||
# define BOOST_FILESYSTEM_STATIC_LINK
|
#define BOOST_FILESYSTEM_STATIC_LINK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_FILESYSTEM_DYN_LINK) && defined(BOOST_FILESYSTEM_STATIC_LINK)
|
#if defined(BOOST_FILESYSTEM_DYN_LINK) && defined(BOOST_FILESYSTEM_STATIC_LINK)
|
||||||
# error Must not define both BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK
|
#error Must not define both BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
|
#if defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||||
# define BOOST_FILESYSTEM_NO_LIB
|
#define BOOST_FILESYSTEM_NO_LIB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enable dynamic linking ------------------------------------------------------------//
|
// enable dynamic linking ------------------------------------------------------------//
|
||||||
|
|
||||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||||
# if defined(BOOST_FILESYSTEM_SOURCE)
|
#if defined(BOOST_FILESYSTEM_SOURCE)
|
||||||
# define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_EXPORT
|
#define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_EXPORT
|
||||||
# else
|
|
||||||
# define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_IMPORT
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define BOOST_FILESYSTEM_DECL
|
#define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_IMPORT
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define BOOST_FILESYSTEM_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enable automatic library variant selection ----------------------------------------//
|
// enable automatic library variant selection ----------------------------------------//
|
||||||
|
|
||||||
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||||
&& !defined(BOOST_FILESYSTEM_NO_LIB)
|
|
||||||
//
|
//
|
||||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||||
// once it's done with it:
|
// once it's done with it:
|
||||||
@ -99,7 +97,7 @@
|
|||||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||||
//
|
//
|
||||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||||
# define BOOST_DYN_LINK
|
#define BOOST_DYN_LINK
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
// And include the header that does the work:
|
// And include the header that does the work:
|
||||||
|
@ -15,44 +15,42 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
|
|
||||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
|
|
||||||
|
inline std::string extension(const path& p)
|
||||||
{
|
{
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
|
|
||||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
|
||||||
|
|
||||||
inline std::string extension(const path & p)
|
|
||||||
{
|
|
||||||
return p.extension().string();
|
return p.extension().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string basename(const path & p)
|
inline std::string basename(const path& p)
|
||||||
{
|
{
|
||||||
return p.stem().string();
|
return p.stem().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline path change_extension( const path & p, const path & new_extension )
|
inline path change_extension(const path& p, const path& new_extension)
|
||||||
{
|
{
|
||||||
path new_p( p );
|
path new_p(p);
|
||||||
new_p.replace_extension( new_extension );
|
new_p.replace_extension(new_extension);
|
||||||
return new_p;
|
return new_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace filesystem
|
||||||
} // namespace filesystem
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
#endif // BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
||||||
|
@ -20,24 +20,22 @@
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
inline const char* macro_value(const char* name, const char* value)
|
||||||
{
|
{
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
inline const char* macro_value(const char* name, const char* value)
|
|
||||||
{
|
|
||||||
static const char* no_value = "[no value]";
|
static const char* no_value = "[no value]";
|
||||||
static const char* not_defined = "[not defined]";
|
static const char* not_defined = "[not defined]";
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
|
BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
|
||||||
BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
|
BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
|
||||||
|
|
||||||
return strcmp(name, value + 1)
|
return strcmp(name, value + 1) ? ((*value && *(value + 1)) ? (value + 1) : no_value) : not_defined; // name == value+1 so the macro is not defined
|
||||||
? ((*value && *(value+1)) ? (value+1) : no_value)
|
}
|
||||||
: not_defined; // name == value+1 so the macro is not defined
|
|
||||||
}
|
} // namespace detail
|
||||||
} // detail
|
} // namespace boost
|
||||||
} // boost
|
|
||||||
|
|
||||||
#define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
|
#define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
|
||||||
|
|
||||||
|
@ -10,9 +10,14 @@
|
|||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
|
|
||||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||||
namespace boost { namespace filesystem { namespace detail {
|
namespace boost { \
|
||||||
|
namespace filesystem { \
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
#define BOOST_UTF8_END_NAMESPACE \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
||||||
|
|
||||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
@ -62,22 +62,23 @@ public:
|
|||||||
typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry
|
typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry
|
||||||
|
|
||||||
directory_entry() BOOST_NOEXCEPT {}
|
directory_entry() BOOST_NOEXCEPT {}
|
||||||
|
|
||||||
explicit directory_entry(const boost::filesystem::path& p) :
|
explicit directory_entry(const boost::filesystem::path& p) :
|
||||||
m_path(p), m_status(file_status()), m_symlink_status(file_status())
|
m_path(p), m_status(file_status()), m_symlink_status(file_status())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
directory_entry(const boost::filesystem::path& p,
|
|
||||||
file_status st, file_status symlink_st = file_status()) :
|
directory_entry(const boost::filesystem::path& p, file_status st, file_status symlink_st = file_status()) :
|
||||||
m_path(p), m_status(st), m_symlink_status(symlink_st)
|
m_path(p), m_status(st), m_symlink_status(symlink_st)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_entry(const directory_entry& rhs) :
|
directory_entry(directory_entry const& rhs) :
|
||||||
m_path(rhs.m_path), m_status(rhs.m_status), m_symlink_status(rhs.m_symlink_status)
|
m_path(rhs.m_path), m_status(rhs.m_status), m_symlink_status(rhs.m_symlink_status)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_entry& operator=(const directory_entry& rhs)
|
directory_entry& operator=(directory_entry const& rhs)
|
||||||
{
|
{
|
||||||
m_path = rhs.m_path;
|
m_path = rhs.m_path;
|
||||||
m_status = rhs.m_status;
|
m_status = rhs.m_status;
|
||||||
@ -91,9 +92,12 @@ public:
|
|||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
directory_entry(directory_entry&& rhs) BOOST_NOEXCEPT :
|
directory_entry(directory_entry&& rhs) BOOST_NOEXCEPT :
|
||||||
m_path(std::move(rhs.m_path)), m_status(std::move(rhs.m_status)), m_symlink_status(std::move(rhs.m_symlink_status))
|
m_path(std::move(rhs.m_path)),
|
||||||
|
m_status(std::move(rhs.m_status)),
|
||||||
|
m_symlink_status(std::move(rhs.m_symlink_status))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_entry& operator=(directory_entry&& rhs) BOOST_NOEXCEPT
|
directory_entry& operator=(directory_entry&& rhs) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_path = std::move(rhs.m_path);
|
m_path = std::move(rhs.m_path);
|
||||||
@ -103,16 +107,14 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void assign(const boost::filesystem::path& p,
|
void assign(const boost::filesystem::path& p, file_status st = file_status(), file_status symlink_st = file_status())
|
||||||
file_status st = file_status(), file_status symlink_st = file_status())
|
|
||||||
{
|
{
|
||||||
m_path = p;
|
m_path = p;
|
||||||
m_status = st;
|
m_status = st;
|
||||||
m_symlink_status = symlink_st;
|
m_symlink_status = symlink_st;
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_filename(const boost::filesystem::path& p,
|
void replace_filename(const boost::filesystem::path& p, file_status st = file_status(), file_status symlink_st = file_status())
|
||||||
file_status st = file_status(), file_status symlink_st = file_status())
|
|
||||||
{
|
{
|
||||||
m_path.remove_filename();
|
m_path.remove_filename();
|
||||||
m_path /= p;
|
m_path /= p;
|
||||||
@ -120,30 +122,33 @@ public:
|
|||||||
m_symlink_status = symlink_st;
|
m_symlink_status = symlink_st;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
void replace_leaf(const boost::filesystem::path& p, file_status st, file_status symlink_st)
|
void replace_leaf(const boost::filesystem::path& p, file_status st, file_status symlink_st)
|
||||||
{
|
{
|
||||||
replace_filename(p, st, symlink_st);
|
replace_filename(p, st, symlink_st);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
const boost::filesystem::path& path() const BOOST_NOEXCEPT { return m_path; }
|
const boost::filesystem::path& path() const BOOST_NOEXCEPT
|
||||||
operator const boost::filesystem::path&() const BOOST_NOEXCEPT { return m_path; }
|
{
|
||||||
|
return m_path;
|
||||||
|
}
|
||||||
|
operator boost::filesystem::path const&() const BOOST_NOEXCEPT { return m_path; }
|
||||||
file_status status() const { return get_status(); }
|
file_status status() const { return get_status(); }
|
||||||
file_status status(system::error_code& ec) const BOOST_NOEXCEPT { return get_status(&ec); }
|
file_status status(system::error_code& ec) const BOOST_NOEXCEPT { return get_status(&ec); }
|
||||||
file_status symlink_status() const { return get_symlink_status(); }
|
file_status symlink_status() const { return get_symlink_status(); }
|
||||||
file_status symlink_status(system::error_code& ec) const BOOST_NOEXCEPT { return get_symlink_status(&ec); }
|
file_status symlink_status(system::error_code& ec) const BOOST_NOEXCEPT { return get_symlink_status(&ec); }
|
||||||
|
|
||||||
bool operator==(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path == rhs.m_path; }
|
bool operator==(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path == rhs.m_path; }
|
||||||
bool operator!=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path != rhs.m_path; }
|
bool operator!=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path != rhs.m_path; }
|
||||||
bool operator< (const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path < rhs.m_path; }
|
bool operator<(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path < rhs.m_path; }
|
||||||
bool operator<=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path <= rhs.m_path; }
|
bool operator<=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path <= rhs.m_path; }
|
||||||
bool operator> (const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path > rhs.m_path; }
|
bool operator>(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path > rhs.m_path; }
|
||||||
bool operator>=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path >= rhs.m_path; }
|
bool operator>=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path >= rhs.m_path; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOST_FILESYSTEM_DECL file_status get_status(system::error_code* ec=0) const;
|
BOOST_FILESYSTEM_DECL file_status get_status(system::error_code* ec = 0) const;
|
||||||
BOOST_FILESYSTEM_DECL file_status get_symlink_status(system::error_code* ec=0) const;
|
BOOST_FILESYSTEM_DECL file_status get_symlink_status(system::error_code* ec = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::filesystem::path m_path;
|
boost::filesystem::path m_path;
|
||||||
@ -151,7 +156,6 @@ private:
|
|||||||
mutable file_status m_symlink_status; // lstat()-like
|
mutable file_status m_symlink_status; // lstat()-like
|
||||||
}; // directory_entry
|
}; // directory_entry
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// //
|
// //
|
||||||
// directory_entry overloads //
|
// directory_entry overloads //
|
||||||
@ -160,28 +164,79 @@ private:
|
|||||||
|
|
||||||
// Without these functions, calling (for example) 'is_directory' with a 'directory_entry' results in:
|
// Without these functions, calling (for example) 'is_directory' with a 'directory_entry' results in:
|
||||||
// - a conversion to 'path' using 'operator const boost::filesystem::path&()',
|
// - a conversion to 'path' using 'operator const boost::filesystem::path&()',
|
||||||
// - then a call to 'is_directory(const path& p)' which recomputes the status with 'detail::status(p)'.
|
// - then a call to 'is_directory(path const& p)' which recomputes the status with 'detail::status(p)'.
|
||||||
//
|
//
|
||||||
// These functions avoid a costly recomputation of the status if one calls 'is_directory(e)' instead of 'is_directory(e.status())'
|
// These functions avoid a costly recomputation of the status if one calls 'is_directory(e)' instead of 'is_directory(e.status())'
|
||||||
|
|
||||||
inline file_status status (const directory_entry& e) { return e.status(); }
|
inline file_status status(directory_entry const& e)
|
||||||
inline file_status status (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return e.status(ec); }
|
{
|
||||||
inline bool type_present (const directory_entry& e) { return filesystem::type_present(e.status()); }
|
return e.status();
|
||||||
inline bool type_present (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::type_present(e.status(ec)); }
|
}
|
||||||
inline bool status_known (const directory_entry& e) { return filesystem::status_known(e.status()); }
|
inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
inline bool status_known (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::status_known(e.status(ec)); }
|
{
|
||||||
inline bool exists (const directory_entry& e) { return filesystem::exists(e.status()); }
|
return e.status(ec);
|
||||||
inline bool exists (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::exists(e.status(ec)); }
|
}
|
||||||
inline bool is_regular_file(const directory_entry& e) { return filesystem::is_regular_file(e.status()); }
|
inline bool type_present(directory_entry const& e)
|
||||||
inline bool is_regular_file(const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_regular_file(e.status(ec)); }
|
{
|
||||||
inline bool is_directory (const directory_entry& e) { return filesystem::is_directory(e.status()); }
|
return filesystem::type_present(e.status());
|
||||||
inline bool is_directory (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_directory(e.status(ec)); }
|
}
|
||||||
inline bool is_symlink (const directory_entry& e) { return filesystem::is_symlink(e.symlink_status()); }
|
inline bool type_present(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
inline bool is_symlink (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_symlink(e.symlink_status(ec)); }
|
{
|
||||||
inline bool is_other (const directory_entry& e) { return filesystem::is_other(e.status()); }
|
return filesystem::type_present(e.status(ec));
|
||||||
inline bool is_other (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_other(e.status(ec)); }
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
inline bool exists(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return filesystem::exists(e.status(ec));
|
||||||
|
}
|
||||||
|
inline bool is_regular_file(directory_entry const& e)
|
||||||
|
{
|
||||||
|
return filesystem::is_regular_file(e.status());
|
||||||
|
}
|
||||||
|
inline bool is_regular_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return filesystem::is_regular_file(e.status(ec));
|
||||||
|
}
|
||||||
|
inline bool is_directory(directory_entry const& e)
|
||||||
|
{
|
||||||
|
return filesystem::is_directory(e.status());
|
||||||
|
}
|
||||||
|
inline bool is_directory(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return filesystem::is_directory(e.status(ec));
|
||||||
|
}
|
||||||
|
inline bool is_symlink(directory_entry const& e)
|
||||||
|
{
|
||||||
|
return filesystem::is_symlink(e.symlink_status());
|
||||||
|
}
|
||||||
|
inline bool is_symlink(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return filesystem::is_symlink(e.symlink_status(ec));
|
||||||
|
}
|
||||||
|
inline bool is_other(directory_entry const& e)
|
||||||
|
{
|
||||||
|
return filesystem::is_other(e.status());
|
||||||
|
}
|
||||||
|
inline bool is_other(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return filesystem::is_other(e.status(ec));
|
||||||
|
}
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
inline bool is_regular (const directory_entry& e) { return filesystem::is_regular(e.status()); }
|
inline bool is_regular(directory_entry const& e)
|
||||||
|
{
|
||||||
|
return filesystem::is_regular(e.status());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
@ -209,12 +264,12 @@ class directory_iterator;
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
system::error_code dir_itr_close(// never throws()
|
system::error_code dir_itr_close( // never throws()
|
||||||
void*& handle
|
void*& handle
|
||||||
#if defined(BOOST_POSIX_API)
|
#if defined(BOOST_POSIX_API)
|
||||||
, void*& buffer
|
, void*& buffer
|
||||||
#endif
|
#endif
|
||||||
) BOOST_NOEXCEPT;
|
) BOOST_NOEXCEPT;
|
||||||
|
|
||||||
struct dir_itr_imp :
|
struct dir_itr_imp :
|
||||||
public boost::intrusive_ref_counter< dir_itr_imp >
|
public boost::intrusive_ref_counter< dir_itr_imp >
|
||||||
@ -245,7 +300,7 @@ struct dir_itr_imp :
|
|||||||
};
|
};
|
||||||
|
|
||||||
// see path::iterator: comment below
|
// see path::iterator: comment below
|
||||||
BOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it, const path& p, unsigned int opts, system::error_code* ec);
|
BOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it, path const& p, unsigned int opts, system::error_code* ec);
|
||||||
BOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it, system::error_code* ec);
|
BOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it, system::error_code* ec);
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@ -265,7 +320,7 @@ class directory_iterator :
|
|||||||
{
|
{
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
||||||
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it, const path& p, unsigned int opts, system::error_code* ec);
|
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it, path const& p, unsigned int opts, system::error_code* ec);
|
||||||
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it, system::error_code* ec);
|
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it, system::error_code* ec);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -273,23 +328,23 @@ public:
|
|||||||
|
|
||||||
// iterator_facade derived classes don't seem to like implementations in
|
// iterator_facade derived classes don't seem to like implementations in
|
||||||
// separate translation unit dll's, so forward to detail functions
|
// separate translation unit dll's, so forward to detail functions
|
||||||
explicit directory_iterator(const path& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts = directory_options::none)
|
explicit directory_iterator(path const& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts = directory_options::none)
|
||||||
{
|
{
|
||||||
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), 0);
|
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_iterator(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
directory_iterator(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(directory_options::none), &ec);
|
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(directory_options::none), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_iterator(const path& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec) BOOST_NOEXCEPT
|
directory_iterator(path const& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), &ec);
|
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_DEFAULTED_FUNCTION(directory_iterator(directory_iterator const& that), : m_imp(that.m_imp) {})
|
BOOST_DEFAULTED_FUNCTION(directory_iterator(directory_iterator const& that), : m_imp(that.m_imp) {})
|
||||||
BOOST_DEFAULTED_FUNCTION(directory_iterator& operator= (directory_iterator const& that), { m_imp = that.m_imp; return *this; })
|
BOOST_DEFAULTED_FUNCTION(directory_iterator& operator=(directory_iterator const& that), { m_imp = that.m_imp; return *this; })
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
directory_iterator(directory_iterator&& that) BOOST_NOEXCEPT :
|
directory_iterator(directory_iterator&& that) BOOST_NOEXCEPT :
|
||||||
@ -297,7 +352,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_iterator& operator= (directory_iterator&& that) BOOST_NOEXCEPT
|
directory_iterator& operator=(directory_iterator&& that) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_imp = std::move(that.m_imp);
|
m_imp = std::move(that.m_imp);
|
||||||
return *this;
|
return *this;
|
||||||
@ -346,37 +401,66 @@ private:
|
|||||||
// begin() and end() are only used by a range-based for statement in the context of
|
// begin() and end() are only used by a range-based for statement in the context of
|
||||||
// auto - thus the top-level const is stripped - so returning const is harmless and
|
// auto - thus the top-level const is stripped - so returning const is harmless and
|
||||||
// emphasizes begin() is just a pass through.
|
// emphasizes begin() is just a pass through.
|
||||||
inline const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline directory_iterator const& begin(directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
inline directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_iterator end(directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
// enable C++14 generic accessors for range const iterators
|
// enable C++14 generic accessors for range const iterators
|
||||||
inline const directory_iterator& cbegin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline directory_iterator const& cbegin(directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
inline directory_iterator cend(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_iterator cend(directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
// enable directory_iterator BOOST_FOREACH -----------------------------------------//
|
// enable directory_iterator BOOST_FOREACH -----------------------------------------//
|
||||||
|
|
||||||
inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT
|
||||||
inline directory_iterator range_begin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
{
|
||||||
inline directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
return iter;
|
||||||
inline directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
}
|
||||||
|
|
||||||
|
inline directory_iterator range_begin(directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_iterator range_end(directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
|
|
||||||
// namespace boost template specializations
|
// namespace boost template specializations
|
||||||
template<typename C, typename Enabler>
|
template< typename C, typename Enabler >
|
||||||
struct range_mutable_iterator;
|
struct range_mutable_iterator;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct range_mutable_iterator<boost::filesystem::directory_iterator, void>
|
struct range_mutable_iterator< boost::filesystem::directory_iterator, void >
|
||||||
{
|
{
|
||||||
typedef boost::filesystem::directory_iterator type;
|
typedef boost::filesystem::directory_iterator type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename C, typename Enabler>
|
template< typename C, typename Enabler >
|
||||||
struct range_const_iterator;
|
struct range_const_iterator;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct range_const_iterator<boost::filesystem::directory_iterator, void>
|
struct range_const_iterator< boost::filesystem::directory_iterator, void >
|
||||||
{
|
{
|
||||||
typedef boost::filesystem::directory_iterator type;
|
typedef boost::filesystem::directory_iterator type;
|
||||||
};
|
};
|
||||||
@ -418,7 +502,7 @@ struct recur_dir_itr_imp :
|
|||||||
explicit recur_dir_itr_imp(unsigned int opts) BOOST_NOEXCEPT : m_options(opts) {}
|
explicit recur_dir_itr_imp(unsigned int opts) BOOST_NOEXCEPT : m_options(opts) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_construct(recursive_directory_iterator& it, const path& dir_path, unsigned int opts, system::error_code* ec);
|
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_construct(recursive_directory_iterator& it, path const& dir_path, unsigned int opts, system::error_code* ec);
|
||||||
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
|
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
|
||||||
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
|
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
|
||||||
|
|
||||||
@ -439,48 +523,48 @@ class recursive_directory_iterator :
|
|||||||
{
|
{
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
||||||
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_construct(recursive_directory_iterator& it, const path& dir_path, unsigned int opts, system::error_code* ec);
|
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_construct(recursive_directory_iterator& it, path const& dir_path, unsigned int opts, system::error_code* ec);
|
||||||
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
|
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
|
||||||
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
|
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
recursive_directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator
|
recursive_directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator
|
||||||
|
|
||||||
explicit recursive_directory_iterator(const path& dir_path)
|
explicit recursive_directory_iterator(path const& dir_path)
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), 0);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_directory_iterator(const path& dir_path, system::error_code& ec)
|
recursive_directory_iterator(path const& dir_path, system::error_code& ec)
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), &ec);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts)
|
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts)
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec)
|
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec)
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||||
// Deprecated constructors
|
// Deprecated constructors
|
||||||
recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts)
|
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts)
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts, system::error_code& ec) BOOST_NOEXCEPT
|
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
|
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
|
||||||
}
|
}
|
||||||
#endif // BOOST_FILESYSTEM_NO_DEPRECATED
|
#endif // BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
|
|
||||||
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator(recursive_directory_iterator const& that), : m_imp(that.m_imp) {})
|
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator(recursive_directory_iterator const& that), : m_imp(that.m_imp) {})
|
||||||
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator& operator= (recursive_directory_iterator const& that), { m_imp = that.m_imp; return *this; })
|
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator& operator=(recursive_directory_iterator const& that), { m_imp = that.m_imp; return *this; })
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
recursive_directory_iterator(recursive_directory_iterator&& that) BOOST_NOEXCEPT :
|
recursive_directory_iterator(recursive_directory_iterator&& that) BOOST_NOEXCEPT :
|
||||||
@ -488,7 +572,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_directory_iterator& operator= (recursive_directory_iterator&& that) BOOST_NOEXCEPT
|
recursive_directory_iterator& operator=(recursive_directory_iterator&& that) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_imp = std::move(that.m_imp);
|
m_imp = std::move(that.m_imp);
|
||||||
return *this;
|
return *this;
|
||||||
@ -514,7 +598,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
int level() const BOOST_NOEXCEPT { return depth(); }
|
int level() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return depth();
|
||||||
|
}
|
||||||
bool no_push_pending() const BOOST_NOEXCEPT { return !recursion_pending(); }
|
bool no_push_pending() const BOOST_NOEXCEPT { return !recursion_pending(); }
|
||||||
bool no_push_request() const BOOST_NOEXCEPT { return !recursion_pending(); }
|
bool no_push_request() const BOOST_NOEXCEPT { return !recursion_pending(); }
|
||||||
#endif
|
#endif
|
||||||
@ -539,7 +626,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
void no_push(bool value = true) BOOST_NOEXCEPT { disable_recursion_pending(value); }
|
void no_push(bool value = true) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
disable_recursion_pending(value);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
file_status status() const
|
file_status status() const
|
||||||
@ -594,30 +684,60 @@ typedef recursive_directory_iterator wrecursive_directory_iterator;
|
|||||||
// begin() and end() are only used by a range-based for statement in the context of
|
// begin() and end() are only used by a range-based for statement in the context of
|
||||||
// auto - thus the top-level const is stripped - so returning const is harmless and
|
// auto - thus the top-level const is stripped - so returning const is harmless and
|
||||||
// emphasizes begin() is just a pass through.
|
// emphasizes begin() is just a pass through.
|
||||||
inline const recursive_directory_iterator& begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline recursive_directory_iterator const& begin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
inline recursive_directory_iterator end(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline recursive_directory_iterator end(recursive_directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return recursive_directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
// enable C++14 generic accessors for range const iterators
|
// enable C++14 generic accessors for range const iterators
|
||||||
inline const recursive_directory_iterator& cbegin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline recursive_directory_iterator const& cbegin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
inline recursive_directory_iterator cend(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline recursive_directory_iterator cend(recursive_directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return recursive_directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
// enable recursive directory iterator BOOST_FOREACH -------------------------------//
|
// enable recursive directory iterator BOOST_FOREACH -------------------------------//
|
||||||
|
|
||||||
inline recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
inline recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT
|
||||||
inline recursive_directory_iterator range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
{
|
||||||
inline recursive_directory_iterator range_end(recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
return iter;
|
||||||
inline recursive_directory_iterator range_end(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
}
|
||||||
|
|
||||||
|
inline recursive_directory_iterator range_begin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline recursive_directory_iterator range_end(recursive_directory_iterator&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return recursive_directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline recursive_directory_iterator range_end(recursive_directory_iterator const&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return recursive_directory_iterator();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
|
|
||||||
// namespace boost template specializations
|
// namespace boost template specializations
|
||||||
template<>
|
template<>
|
||||||
struct range_mutable_iterator<boost::filesystem::recursive_directory_iterator, void>
|
struct range_mutable_iterator< boost::filesystem::recursive_directory_iterator, void >
|
||||||
{
|
{
|
||||||
typedef boost::filesystem::recursive_directory_iterator type;
|
typedef boost::filesystem::recursive_directory_iterator type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct range_const_iterator<boost::filesystem::recursive_directory_iterator, void>
|
struct range_const_iterator< boost::filesystem::recursive_directory_iterator, void >
|
||||||
{
|
{
|
||||||
typedef boost::filesystem::recursive_directory_iterator type;
|
typedef boost::filesystem::recursive_directory_iterator type;
|
||||||
};
|
};
|
||||||
@ -625,4 +745,5 @@ struct range_const_iterator<boost::filesystem::recursive_directory_iterator, voi
|
|||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_DIRECTORY_HPP
|
#endif // BOOST_FILESYSTEM3_DIRECTORY_HPP
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
@ -31,9 +31,9 @@
|
|||||||
#if defined(BOOST_MSVC)
|
#if defined(BOOST_MSVC)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
// 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B'
|
// 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B'
|
||||||
#pragma warning(disable: 4251)
|
#pragma warning(disable : 4251)
|
||||||
// non dll-interface class 'A' used as base for dll-interface class 'B'
|
// non dll-interface class 'A' used as base for dll-interface class 'B'
|
||||||
#pragma warning(disable: 4275)
|
#pragma warning(disable : 4275)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
BOOST_FILESYSTEM_DECL filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec);
|
BOOST_FILESYSTEM_DECL filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec);
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL filesystem_error(filesystem_error const& that);
|
BOOST_FILESYSTEM_DECL filesystem_error(filesystem_error const& that);
|
||||||
BOOST_FILESYSTEM_DECL filesystem_error& operator= (filesystem_error const& that);
|
BOOST_FILESYSTEM_DECL filesystem_error& operator=(filesystem_error const& that);
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW;
|
BOOST_FILESYSTEM_DECL ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW;
|
||||||
|
|
||||||
@ -83,8 +83,14 @@ private:
|
|||||||
std::string m_what; // not built until needed
|
std::string m_what; // not built until needed
|
||||||
|
|
||||||
BOOST_DEFAULTED_FUNCTION(impl(), {})
|
BOOST_DEFAULTED_FUNCTION(impl(), {})
|
||||||
explicit impl(path const& path1) : m_path1(path1) {}
|
explicit impl(path const& path1) :
|
||||||
impl(path const& path1, path const& path2) : m_path1(path1), m_path2(path2) {}
|
m_path1(path1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
impl(path const& path1, path const& path2) :
|
||||||
|
m_path1(path1), m_path2(path2)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
boost::intrusive_ptr< impl > m_imp_ptr;
|
boost::intrusive_ptr< impl > m_imp_ptr;
|
||||||
};
|
};
|
||||||
@ -97,4 +103,5 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_EXCEPTION_HPP
|
#endif // BOOST_FILESYSTEM3_EXCEPTION_HPP
|
||||||
|
@ -18,12 +18,11 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
|
|
||||||
#include <boost/detail/bitmask.hpp>
|
#include <boost/detail/bitmask.hpp>
|
||||||
|
|
||||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||||
@ -40,9 +39,9 @@ namespace filesystem {
|
|||||||
enum file_type
|
enum file_type
|
||||||
{
|
{
|
||||||
status_error,
|
status_error,
|
||||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
status_unknown = status_error,
|
status_unknown = status_error,
|
||||||
# endif
|
#endif
|
||||||
file_not_found,
|
file_not_found,
|
||||||
regular_file,
|
regular_file,
|
||||||
directory_file,
|
directory_file,
|
||||||
@ -116,7 +115,7 @@ enum perms
|
|||||||
|
|
||||||
// BOOST_BITMASK op~ casts to int32_least_t, producing invalid enum values
|
// BOOST_BITMASK op~ casts to int32_least_t, producing invalid enum values
|
||||||
_detail_extend_perms_32_1 = 0x7fffffff,
|
_detail_extend_perms_32_1 = 0x7fffffff,
|
||||||
_detail_extend_perms_32_2 = -0x7fffffff-1
|
_detail_extend_perms_32_2 = -0x7fffffff - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_BITMASK(perms)
|
BOOST_BITMASK(perms)
|
||||||
@ -129,15 +128,18 @@ class file_status
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BOOST_CONSTEXPR file_status() BOOST_NOEXCEPT :
|
BOOST_CONSTEXPR file_status() BOOST_NOEXCEPT :
|
||||||
m_value(status_error), m_perms(perms_not_known)
|
m_value(status_error),
|
||||||
|
m_perms(perms_not_known)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
explicit BOOST_CONSTEXPR file_status(file_type v) BOOST_NOEXCEPT :
|
explicit BOOST_CONSTEXPR file_status(file_type v) BOOST_NOEXCEPT :
|
||||||
m_value(v), m_perms(perms_not_known)
|
m_value(v),
|
||||||
|
m_perms(perms_not_known)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
BOOST_CONSTEXPR file_status(file_type v, perms prms) BOOST_NOEXCEPT :
|
BOOST_CONSTEXPR file_status(file_type v, perms prms) BOOST_NOEXCEPT :
|
||||||
m_value(v), m_perms(prms)
|
m_value(v),
|
||||||
|
m_perms(prms)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +148,8 @@ public:
|
|||||||
// functions. GCC is not even consistent for the same release on different platforms.
|
// functions. GCC is not even consistent for the same release on different platforms.
|
||||||
|
|
||||||
BOOST_CONSTEXPR file_status(const file_status& rhs) BOOST_NOEXCEPT :
|
BOOST_CONSTEXPR file_status(const file_status& rhs) BOOST_NOEXCEPT :
|
||||||
m_value(rhs.m_value), m_perms(rhs.m_perms)
|
m_value(rhs.m_value),
|
||||||
|
m_perms(rhs.m_perms)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
BOOST_CXX14_CONSTEXPR file_status& operator=(const file_status& rhs) BOOST_NOEXCEPT
|
BOOST_CXX14_CONSTEXPR file_status& operator=(const file_status& rhs) BOOST_NOEXCEPT
|
||||||
@ -156,10 +159,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
// 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_perms(static_cast< enum perms&& >(rhs.m_perms))
|
m_value(static_cast< file_type&& >(rhs.m_value)),
|
||||||
|
m_perms(static_cast< enum 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
|
||||||
@ -168,7 +172,7 @@ public:
|
|||||||
m_perms = static_cast< enum perms&& >(rhs.m_perms);
|
m_perms = static_cast< enum perms&& >(rhs.m_perms);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
// observers
|
// observers
|
||||||
BOOST_CONSTEXPR file_type type() const BOOST_NOEXCEPT { return m_value; }
|
BOOST_CONSTEXPR file_type type() const BOOST_NOEXCEPT { return m_value; }
|
||||||
@ -196,42 +200,52 @@ inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT
|
|||||||
{
|
{
|
||||||
return f.type() != status_error;
|
return f.type() != 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() != 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
|
||||||
{
|
{
|
||||||
return filesystem::type_present(f) && filesystem::permissions_present(f);
|
return filesystem::type_present(f) && filesystem::permissions_present(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
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() != status_error && f.type() != 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() == 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() == 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() == symlink_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT
|
inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return filesystem::exists(f) && !filesystem::is_regular_file(f)
|
return filesystem::exists(f) && !filesystem::is_regular_file(f) && !filesystem::is_directory(f) && !filesystem::is_symlink(f);
|
||||||
&& !filesystem::is_directory(f) && !filesystem::is_symlink(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
inline bool is_regular(file_status f) BOOST_NOEXCEPT { return filesystem::is_regular_file(f); }
|
inline bool is_regular(file_status f) BOOST_NOEXCEPT
|
||||||
# endif
|
{
|
||||||
|
return filesystem::is_regular_file(f);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_FILE_STATUS_HPP
|
#endif // BOOST_FILESYSTEM3_FILE_STATUS_HPP
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@ -26,160 +26,160 @@
|
|||||||
|
|
||||||
// on Windows, except for standard libaries known to have wchar_t overloads for
|
// on Windows, except for standard libaries known to have wchar_t overloads for
|
||||||
// file stream I/O, use path::string() to get a narrow character c_str()
|
// file stream I/O, use path::string() to get a narrow character c_str()
|
||||||
#if defined(BOOST_WINDOWS_API) \
|
#if defined(BOOST_WINDOWS_API) && (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
|
||||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
|
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
|
||||||
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
|
#define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
|
||||||
# define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
|
|
||||||
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
||||||
# define BOOST_FILESYSTEM_C_STR c_str()
|
#define BOOST_FILESYSTEM_C_STR c_str()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
#if defined(BOOST_MSVC)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
// 'boost::filesystem::basic_fstream<charT>' : inherits 'std::basic_istream<_Elem,_Traits>::std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' via dominance
|
// 'boost::filesystem::basic_fstream<charT>' : inherits 'std::basic_istream<_Elem,_Traits>::std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' via dominance
|
||||||
#pragma warning(disable: 4250)
|
#pragma warning(disable : 4250)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
{
|
namespace filesystem {
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// basic_filebuf //
|
// basic_filebuf //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
template < class charT, class traits = std::char_traits<charT> >
|
template< class charT, class traits = std::char_traits< charT > >
|
||||||
class basic_filebuf : public std::basic_filebuf<charT,traits>
|
class basic_filebuf :
|
||||||
{
|
public std::basic_filebuf< charT, traits >
|
||||||
private: // disallow copying
|
{
|
||||||
basic_filebuf(const basic_filebuf&);
|
public:
|
||||||
const basic_filebuf& operator=(const basic_filebuf&);
|
BOOST_DEFAULTED_FUNCTION(basic_filebuf(), {})
|
||||||
|
BOOST_DELETED_FUNCTION(basic_filebuf(const basic_filebuf&))
|
||||||
|
BOOST_DELETED_FUNCTION(const basic_filebuf& operator=(const basic_filebuf&))
|
||||||
|
|
||||||
public:
|
public:
|
||||||
basic_filebuf() {}
|
basic_filebuf< charT, traits >* open(const path& p, std::ios_base::openmode mode)
|
||||||
virtual ~basic_filebuf() {}
|
|
||||||
|
|
||||||
basic_filebuf<charT,traits>*
|
|
||||||
open(const path& p, std::ios_base::openmode mode)
|
|
||||||
{
|
{
|
||||||
return std::basic_filebuf<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode)
|
return std::basic_filebuf< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode) ? this : 0;
|
||||||
? this : 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// basic_ifstream //
|
// basic_ifstream //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
template < class charT, class traits = std::char_traits<charT> >
|
template< class charT, class traits = std::char_traits< charT > >
|
||||||
class basic_ifstream : public std::basic_ifstream<charT,traits>
|
class basic_ifstream :
|
||||||
{
|
public std::basic_ifstream< charT, traits >
|
||||||
private: // disallow copying
|
{
|
||||||
basic_ifstream(const basic_ifstream&);
|
public:
|
||||||
const basic_ifstream& operator=(const basic_ifstream&);
|
BOOST_DEFAULTED_FUNCTION(basic_ifstream(), {})
|
||||||
|
|
||||||
public:
|
|
||||||
basic_ifstream() {}
|
|
||||||
|
|
||||||
// use two signatures, rather than one signature with default second
|
// use two signatures, rather than one signature with default second
|
||||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||||
|
|
||||||
explicit basic_ifstream(const path& p)
|
explicit basic_ifstream(const path& p) :
|
||||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
|
std::basic_ifstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
|
||||||
|
|
||||||
basic_ifstream(const path& p, std::ios_base::openmode mode)
|
basic_ifstream(const path& p, std::ios_base::openmode mode) :
|
||||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
std::basic_ifstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||||
|
|
||||||
|
BOOST_DELETED_FUNCTION(basic_ifstream(const basic_ifstream&))
|
||||||
|
BOOST_DELETED_FUNCTION(const basic_ifstream& operator=(const basic_ifstream&))
|
||||||
|
|
||||||
|
public:
|
||||||
void open(const path& p)
|
void open(const path& p)
|
||||||
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in); }
|
{
|
||||||
|
std::basic_ifstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in);
|
||||||
|
}
|
||||||
|
|
||||||
void open(const path& p, std::ios_base::openmode mode)
|
void open(const path& p, std::ios_base::openmode mode)
|
||||||
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
{
|
||||||
|
std::basic_ifstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||||
virtual ~basic_ifstream() {}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// basic_ofstream //
|
// basic_ofstream //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
template < class charT, class traits = std::char_traits<charT> >
|
template< class charT, class traits = std::char_traits< charT > >
|
||||||
class basic_ofstream : public std::basic_ofstream<charT,traits>
|
class basic_ofstream :
|
||||||
{
|
public std::basic_ofstream< charT, traits >
|
||||||
private: // disallow copying
|
{
|
||||||
basic_ofstream(const basic_ofstream&);
|
public:
|
||||||
const basic_ofstream& operator=(const basic_ofstream&);
|
BOOST_DEFAULTED_FUNCTION(basic_ofstream(), {})
|
||||||
|
|
||||||
public:
|
|
||||||
basic_ofstream() {}
|
|
||||||
|
|
||||||
// use two signatures, rather than one signature with default second
|
// use two signatures, rather than one signature with default second
|
||||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||||
|
|
||||||
explicit basic_ofstream(const path& p)
|
explicit basic_ofstream(const path& p) :
|
||||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
|
std::basic_ofstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
|
||||||
|
|
||||||
basic_ofstream(const path& p, std::ios_base::openmode mode)
|
basic_ofstream(const path& p, std::ios_base::openmode mode) :
|
||||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
std::basic_ofstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||||
|
|
||||||
|
BOOST_DELETED_FUNCTION(basic_ofstream(const basic_ofstream&))
|
||||||
|
BOOST_DELETED_FUNCTION(const basic_ofstream& operator=(const basic_ofstream&))
|
||||||
|
|
||||||
|
public:
|
||||||
void open(const path& p)
|
void open(const path& p)
|
||||||
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out); }
|
{
|
||||||
|
std::basic_ofstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out);
|
||||||
|
}
|
||||||
|
|
||||||
void open(const path& p, std::ios_base::openmode mode)
|
void open(const path& p, std::ios_base::openmode mode)
|
||||||
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
{
|
||||||
|
std::basic_ofstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||||
virtual ~basic_ofstream() {}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// basic_fstream //
|
// basic_fstream //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
template < class charT, class traits = std::char_traits<charT> >
|
template< class charT, class traits = std::char_traits< charT > >
|
||||||
class basic_fstream : public std::basic_fstream<charT,traits>
|
class basic_fstream :
|
||||||
{
|
public std::basic_fstream< charT, traits >
|
||||||
private: // disallow copying
|
{
|
||||||
basic_fstream(const basic_fstream&);
|
public:
|
||||||
const basic_fstream & operator=(const basic_fstream&);
|
BOOST_DEFAULTED_FUNCTION(basic_fstream(), {})
|
||||||
|
|
||||||
public:
|
|
||||||
basic_fstream() {}
|
|
||||||
|
|
||||||
// use two signatures, rather than one signature with default second
|
// use two signatures, rather than one signature with default second
|
||||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||||
|
|
||||||
explicit basic_fstream(const path& p)
|
explicit basic_fstream(const path& p) :
|
||||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR,
|
std::basic_fstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in | std::ios_base::out) {}
|
||||||
std::ios_base::in | std::ios_base::out) {}
|
|
||||||
|
|
||||||
basic_fstream(const path& p, std::ios_base::openmode mode)
|
basic_fstream(const path& p, std::ios_base::openmode mode) :
|
||||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
std::basic_fstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||||
|
|
||||||
|
BOOST_DELETED_FUNCTION(basic_fstream(const basic_fstream&))
|
||||||
|
BOOST_DELETED_FUNCTION(const basic_fstream& operator=(const basic_fstream&))
|
||||||
|
|
||||||
|
public:
|
||||||
void open(const path& p)
|
void open(const path& p)
|
||||||
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR,
|
{
|
||||||
std::ios_base::in | std::ios_base::out); }
|
std::basic_fstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in | std::ios_base::out);
|
||||||
|
}
|
||||||
|
|
||||||
void open(const path& p, std::ios_base::openmode mode)
|
void open(const path& p, std::ios_base::openmode mode)
|
||||||
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
{
|
||||||
|
std::basic_fstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||||
virtual ~basic_fstream() {}
|
}
|
||||||
|
};
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// typedefs //
|
// typedefs //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
typedef basic_filebuf<char> filebuf;
|
typedef basic_filebuf< char > filebuf;
|
||||||
typedef basic_ifstream<char> ifstream;
|
typedef basic_ifstream< char > ifstream;
|
||||||
typedef basic_ofstream<char> ofstream;
|
typedef basic_ofstream< char > ofstream;
|
||||||
typedef basic_fstream<char> fstream;
|
typedef basic_fstream< char > fstream;
|
||||||
|
|
||||||
typedef basic_filebuf<wchar_t> wfilebuf;
|
typedef basic_filebuf< wchar_t > wfilebuf;
|
||||||
typedef basic_ifstream<wchar_t> wifstream;
|
typedef basic_ifstream< wchar_t > wifstream;
|
||||||
typedef basic_ofstream<wchar_t> wofstream;
|
typedef basic_ofstream< wchar_t > wofstream;
|
||||||
typedef basic_fstream<wchar_t> wfstream;
|
typedef basic_fstream< wchar_t > wfstream;
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
@ -189,4 +189,5 @@ namespace filesystem
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_FSTREAM_HPP
|
#endif // BOOST_FILESYSTEM3_FSTREAM_HPP
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
@ -93,80 +93,78 @@ BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path absolute(const path& p, const path& base, system::error_code* ec=0);
|
path absolute(path const& p, path const& base, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
file_status status(const path&p, system::error_code* ec=0);
|
file_status status(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
file_status symlink_status(const path& p, system::error_code* ec=0);
|
file_status symlink_status(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool is_empty(const path& p, system::error_code* ec=0);
|
bool is_empty(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path initial_path(system::error_code* ec=0);
|
path initial_path(system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path canonical(const path& p, const path& base, system::error_code* ec=0);
|
path canonical(path const& p, path const& base, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void copy(const path& from, const path& to, unsigned int options, system::error_code* ec=0);
|
void copy(path const& from, path const& to, unsigned int options, system::error_code* ec = 0);
|
||||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void copy_directory(const path& from, const path& to, system::error_code* ec=0);
|
void copy_directory(path const& from, path const& to, system::error_code* ec = 0);
|
||||||
#endif
|
#endif
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool copy_file(const path& from, const path& to, // See ticket #2925
|
bool copy_file(path const& from, path const& to, // See ticket #2925
|
||||||
unsigned int options, system::error_code* ec=0); // see copy_options for options
|
unsigned int options, system::error_code* ec = 0); // see copy_options for options
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0);
|
void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool create_directories(const path& p, system::error_code* ec=0);
|
bool create_directories(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool create_directory(const path& p, const path* existing, system::error_code* ec=0);
|
bool create_directory(path const& p, const path* existing, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void create_directory_symlink(const path& to, const path& from,
|
void create_directory_symlink(path const& to, path const& from, system::error_code* ec = 0);
|
||||||
system::error_code* ec=0);
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void create_hard_link(const path& to, const path& from, system::error_code* ec=0);
|
void create_hard_link(path const& to, path const& from, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void create_symlink(const path& to, const path& from, system::error_code* ec=0);
|
void create_symlink(path const& to, path const& from, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path current_path(system::error_code* ec=0);
|
path current_path(system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void current_path(const path& p, system::error_code* ec=0);
|
void current_path(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool equivalent(const path& p1, const path& p2, system::error_code* ec=0);
|
bool equivalent(path const& p1, path const& p2, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
boost::uintmax_t file_size(const path& p, system::error_code* ec=0);
|
boost::uintmax_t file_size(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
boost::uintmax_t hard_link_count(const path& p, system::error_code* ec=0);
|
boost::uintmax_t hard_link_count(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
std::time_t creation_time(const path& p, system::error_code* ec=0);
|
std::time_t creation_time(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
std::time_t last_write_time(const path& p, system::error_code* ec=0);
|
std::time_t last_write_time(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void last_write_time(const path& p, const std::time_t new_time,
|
void last_write_time(path const& p, const std::time_t new_time, system::error_code* ec = 0);
|
||||||
system::error_code* ec=0);
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void permissions(const path& p, perms prms, system::error_code* ec=0);
|
void permissions(path const& p, perms prms, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path read_symlink(const path& p, system::error_code* ec=0);
|
path read_symlink(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path relative(const path& p, const path& base, system::error_code* ec = 0);
|
path relative(path const& p, path const& base, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
bool remove(const path& p, system::error_code* ec=0);
|
bool remove(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
boost::uintmax_t remove_all(const path& p, system::error_code* ec=0);
|
boost::uintmax_t remove_all(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void rename(const path& old_p, const path& new_p, system::error_code* ec=0);
|
void rename(path const& old_p, path const& new_p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void resize_file(const path& p, uintmax_t size, system::error_code* ec=0);
|
void resize_file(path const& p, uintmax_t size, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
space_info space(const path& p, system::error_code* ec=0);
|
space_info space(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path system_complete(const path& p, system::error_code* ec=0);
|
path system_complete(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path temp_directory_path(system::error_code* ec=0);
|
path temp_directory_path(system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path unique_path(const path& p, system::error_code* ec=0);
|
path unique_path(path const& p, system::error_code* ec = 0);
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
path weakly_canonical(const path& p, system::error_code* ec = 0);
|
path weakly_canonical(path const& p, system::error_code* ec = 0);
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@ -176,54 +174,97 @@ path weakly_canonical(const path& p, system::error_code* ec = 0);
|
|||||||
// //
|
// //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
inline
|
inline file_status status(path const& p)
|
||||||
file_status status(const path& p) {return detail::status(p);}
|
{
|
||||||
inline
|
return detail::status(p);
|
||||||
file_status status(const path& p, system::error_code& ec)
|
}
|
||||||
{return detail::status(p, &ec);}
|
|
||||||
inline
|
inline file_status status(path const& p, system::error_code& ec)
|
||||||
file_status symlink_status(const path& p) {return detail::symlink_status(p);}
|
{
|
||||||
inline
|
return detail::status(p, &ec);
|
||||||
file_status symlink_status(const path& p, system::error_code& ec)
|
}
|
||||||
{return detail::symlink_status(p, &ec);}
|
|
||||||
inline
|
inline file_status symlink_status(path const& p)
|
||||||
bool exists(const path& p) {return exists(detail::status(p));}
|
{
|
||||||
inline
|
return detail::symlink_status(p);
|
||||||
bool exists(const path& p, system::error_code& ec)
|
}
|
||||||
{return exists(detail::status(p, &ec));}
|
|
||||||
inline
|
inline file_status symlink_status(path const& p, system::error_code& ec)
|
||||||
bool is_directory(const path& p) {return is_directory(detail::status(p));}
|
{
|
||||||
inline
|
return detail::symlink_status(p, &ec);
|
||||||
bool is_directory(const path& p, system::error_code& ec)
|
}
|
||||||
{return is_directory(detail::status(p, &ec));}
|
|
||||||
inline
|
inline bool exists(path const& p)
|
||||||
bool is_regular_file(const path& p) {return is_regular_file(detail::status(p));}
|
{
|
||||||
inline
|
return exists(detail::status(p));
|
||||||
bool is_regular_file(const path& p, system::error_code& ec)
|
}
|
||||||
{return is_regular_file(detail::status(p, &ec));}
|
|
||||||
inline
|
inline bool exists(path const& p, system::error_code& ec)
|
||||||
bool is_other(const path& p) {return is_other(detail::status(p));}
|
{
|
||||||
inline
|
return exists(detail::status(p, &ec));
|
||||||
bool is_other(const path& p, system::error_code& ec)
|
}
|
||||||
{return is_other(detail::status(p, &ec));}
|
|
||||||
inline
|
inline bool is_directory(path const& p)
|
||||||
bool is_symlink(const path& p) {return is_symlink(detail::symlink_status(p));}
|
{
|
||||||
inline
|
return is_directory(detail::status(p));
|
||||||
bool is_symlink(const path& p, system::error_code& ec)
|
}
|
||||||
{return is_symlink(detail::symlink_status(p, &ec));}
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_other(path const& p)
|
||||||
|
{
|
||||||
|
return is_other(detail::status(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_other(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return is_other(detail::status(p, &ec));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_symlink(path const& p)
|
||||||
|
{
|
||||||
|
return 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));
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
inline
|
inline bool is_regular(path const& p)
|
||||||
bool is_regular(const path& p) {return is_regular(detail::status(p));}
|
{
|
||||||
inline
|
return is_regular(detail::status(p));
|
||||||
bool is_regular(const path& p, system::error_code& ec)
|
}
|
||||||
{return is_regular(detail::status(p, &ec));}
|
|
||||||
|
inline bool is_regular(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return is_regular(detail::status(p, &ec));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline
|
inline bool is_empty(path const& p)
|
||||||
bool is_empty(const path& p) {return detail::is_empty(p);}
|
{
|
||||||
inline
|
return detail::is_empty(p);
|
||||||
bool is_empty(const path& p, system::error_code& ec)
|
}
|
||||||
{return detail::is_empty(p, &ec);}
|
|
||||||
|
inline bool is_empty(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return detail::is_empty(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// //
|
// //
|
||||||
@ -231,306 +272,428 @@ bool is_empty(const path& p, system::error_code& ec)
|
|||||||
// //
|
// //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
inline
|
inline path initial_path()
|
||||||
path initial_path() {return detail::initial_path();}
|
{
|
||||||
|
return detail::initial_path();
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline path initial_path(system::error_code& ec)
|
||||||
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
|
{
|
||||||
|
return detail::initial_path(&ec);
|
||||||
|
}
|
||||||
|
|
||||||
template <class Path>
|
template< class Path >
|
||||||
path initial_path() {return initial_path();}
|
path initial_path()
|
||||||
template <class Path>
|
{
|
||||||
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
|
return initial_path();
|
||||||
|
}
|
||||||
|
template< class Path >
|
||||||
|
path initial_path(system::error_code& ec)
|
||||||
|
{
|
||||||
|
return detail::initial_path(&ec);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline path current_path()
|
||||||
path current_path() {return detail::current_path();}
|
{
|
||||||
|
return detail::current_path();
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline path current_path(system::error_code& ec)
|
||||||
path current_path(system::error_code& ec) {return detail::current_path(&ec);}
|
{
|
||||||
|
return detail::current_path(&ec);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline void current_path(path const& p)
|
||||||
void current_path(const path& p) {detail::current_path(p);}
|
{
|
||||||
|
detail::current_path(p);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline void current_path(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
void current_path(const path& p, system::error_code& ec) BOOST_NOEXCEPT {detail::current_path(p, &ec);}
|
{
|
||||||
|
detail::current_path(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline path absolute(path const& p, path const& base = current_path())
|
||||||
path absolute(const path& p, const path& base=current_path()) {return detail::absolute(p, base);}
|
{
|
||||||
inline
|
return detail::absolute(p, base);
|
||||||
path absolute(const path& p, system::error_code& ec)
|
}
|
||||||
|
|
||||||
|
inline path absolute(path const& p, system::error_code& ec)
|
||||||
{
|
{
|
||||||
path base = current_path(ec);
|
path base = current_path(ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
return path();
|
return path();
|
||||||
return detail::absolute(p, base, &ec);
|
return detail::absolute(p, base, &ec);
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
path absolute(const path& p, const path& base, system::error_code& ec) {return detail::absolute(p, base, &ec);}
|
|
||||||
|
|
||||||
inline
|
inline path absolute(path const& p, path const& base, system::error_code& ec)
|
||||||
path canonical(const path& p, const path& base=current_path())
|
{
|
||||||
{return detail::canonical(p, base);}
|
return detail::absolute(p, base, &ec);
|
||||||
inline
|
}
|
||||||
path canonical(const path& p, system::error_code& ec)
|
|
||||||
|
inline path canonical(path const& p, path const& base = current_path())
|
||||||
|
{
|
||||||
|
return detail::canonical(p, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path canonical(path const& p, system::error_code& ec)
|
||||||
{
|
{
|
||||||
path base = current_path(ec);
|
path base = current_path(ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
return path();
|
return path();
|
||||||
return detail::canonical(p, base, &ec);
|
return detail::canonical(p, base, &ec);
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
path canonical(const path& p, const path& base, system::error_code& ec)
|
inline path canonical(path const& p, path const& base, system::error_code& ec)
|
||||||
{return detail::canonical(p, base, &ec);}
|
{
|
||||||
|
return detail::canonical(p, base, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
inline
|
inline path complete(path const& p)
|
||||||
path complete(const path& p)
|
|
||||||
{
|
{
|
||||||
return absolute(p, initial_path());
|
return absolute(p, initial_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline path complete(path const& p, path const& base)
|
||||||
path complete(const path& p, const path& base)
|
|
||||||
{
|
{
|
||||||
return absolute(p, base);
|
return absolute(p, base);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline
|
inline void copy(path const& from, path const& to)
|
||||||
void copy(const path& from, const path& to)
|
|
||||||
{
|
{
|
||||||
detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
|
detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
void copy(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
|
inline void copy(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
|
detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
void copy(const path& from, const path& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
|
inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
|
||||||
{
|
{
|
||||||
detail::copy(from, to, static_cast< unsigned int >(options));
|
detail::copy(from, to, static_cast< unsigned int >(options));
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
void copy(const path& from, const path& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
|
inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
detail::copy(from, to, static_cast< unsigned int >(options), &ec);
|
detail::copy(from, to, static_cast< unsigned int >(options), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||||
inline
|
inline void copy_directory(path const& from, path const& to)
|
||||||
void copy_directory(const path& from, const path& to)
|
{
|
||||||
{detail::copy_directory(from, to);}
|
detail::copy_directory(from, to);
|
||||||
inline
|
}
|
||||||
void copy_directory(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
|
|
||||||
{detail::copy_directory(from, to, &ec);}
|
inline void copy_directory(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
detail::copy_directory(from, to, &ec);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
inline
|
|
||||||
bool copy_file(const path& from, const path& to)
|
inline bool copy_file(path const& from, path const& to)
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
|
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
bool copy_file(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
|
inline bool copy_file(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
|
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
bool copy_file(const path& from, const path& to, // See ticket #2925
|
inline bool copy_file(path const& from, path const& to, // See ticket #2925
|
||||||
BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
|
BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(options));
|
return detail::copy_file(from, to, static_cast< unsigned int >(options));
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
bool copy_file(const path& from, const path& to, // See ticket #2925
|
inline bool copy_file(path const& from, path const& to, // See ticket #2925
|
||||||
BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
|
BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||||
inline
|
inline bool copy_file(path const& from, path const& to, // See ticket #2925
|
||||||
bool copy_file(const path& from, const path& to, // See ticket #2925
|
|
||||||
BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
|
BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(options));
|
return detail::copy_file(from, to, static_cast< unsigned int >(options));
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
bool copy_file(const path& from, const path& to, // See ticket #2925
|
inline bool copy_file(path const& from, path const& to, // See ticket #2925
|
||||||
BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
|
BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
||||||
}
|
}
|
||||||
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||||
inline
|
|
||||||
void copy_symlink(const path& existing_symlink,
|
|
||||||
const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);}
|
|
||||||
|
|
||||||
inline
|
inline void copy_symlink(path const& existing_symlink, path const& new_symlink)
|
||||||
void copy_symlink(const path& existing_symlink, const path& new_symlink,
|
{
|
||||||
system::error_code& ec) BOOST_NOEXCEPT
|
detail::copy_symlink(existing_symlink, new_symlink);
|
||||||
{detail::copy_symlink(existing_symlink, new_symlink, &ec);}
|
}
|
||||||
inline
|
|
||||||
bool create_directories(const path& p) {return detail::create_directories(p);}
|
|
||||||
|
|
||||||
inline
|
inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
bool create_directories(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::create_directories(p, &ec);}
|
detail::copy_symlink(existing_symlink, new_symlink, &ec);
|
||||||
inline
|
}
|
||||||
bool create_directory(const path& p) {return detail::create_directory(p, 0);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directories(path const& p)
|
||||||
bool create_directory(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::create_directory(p, 0, &ec);}
|
return detail::create_directories(p);
|
||||||
inline
|
}
|
||||||
bool create_directory(const path& p, const path& existing)
|
|
||||||
{return detail::create_directory(p, &existing);}
|
|
||||||
inline
|
|
||||||
bool create_directory(const path& p, const path& existing, system::error_code& ec) BOOST_NOEXCEPT
|
|
||||||
{return detail::create_directory(p, &existing, &ec);}
|
|
||||||
inline
|
|
||||||
void create_directory_symlink(const path& to, const path& from)
|
|
||||||
{detail::create_directory_symlink(to, from);}
|
|
||||||
inline
|
|
||||||
void create_directory_symlink(const path& to, const path& from, system::error_code& ec) BOOST_NOEXCEPT
|
|
||||||
{detail::create_directory_symlink(to, from, &ec);}
|
|
||||||
inline
|
|
||||||
void create_hard_link(const path& to, const path& new_hard_link) {detail::create_hard_link(to, new_hard_link);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directories(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{detail::create_hard_link(to, new_hard_link, &ec);}
|
return detail::create_directories(p, &ec);
|
||||||
inline
|
}
|
||||||
void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directory(path const& p)
|
||||||
void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{detail::create_symlink(to, new_symlink, &ec);}
|
return detail::create_directory(p, 0);
|
||||||
inline
|
}
|
||||||
bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
bool equivalent(const path& p1, const path& p2, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::equivalent(p1, p2, &ec);}
|
return detail::create_directory(p, 0, &ec);
|
||||||
inline
|
}
|
||||||
boost::uintmax_t file_size(const path& p) {return detail::file_size(p);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directory(path const& p, path const& existing)
|
||||||
boost::uintmax_t file_size(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::file_size(p, &ec);}
|
return detail::create_directory(p, &existing);
|
||||||
inline
|
}
|
||||||
boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}
|
|
||||||
|
|
||||||
inline
|
inline bool create_directory(path const& p, path const& existing, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::hard_link_count(p, &ec);}
|
return detail::create_directory(p, &existing, &ec);
|
||||||
inline
|
}
|
||||||
std::time_t creation_time(const path& p) { return detail::creation_time(p); }
|
|
||||||
|
|
||||||
inline
|
inline void create_directory_symlink(path const& to, path const& from)
|
||||||
std::time_t creation_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{ return detail::creation_time(p, &ec); }
|
detail::create_directory_symlink(to, from);
|
||||||
inline
|
}
|
||||||
std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}
|
|
||||||
|
|
||||||
inline
|
inline void create_directory_symlink(path const& to, path const& from, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
std::time_t last_write_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::last_write_time(p, &ec);}
|
detail::create_directory_symlink(to, from, &ec);
|
||||||
inline
|
}
|
||||||
void last_write_time(const path& p, const std::time_t new_time)
|
|
||||||
{detail::last_write_time(p, new_time);}
|
|
||||||
inline
|
|
||||||
void last_write_time(const path& p, const std::time_t new_time,
|
|
||||||
system::error_code& ec) BOOST_NOEXCEPT
|
|
||||||
{detail::last_write_time(p, new_time, &ec);}
|
|
||||||
inline
|
|
||||||
void permissions(const path& p, perms prms)
|
|
||||||
{detail::permissions(p, prms);}
|
|
||||||
inline
|
|
||||||
void permissions(const path& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
|
|
||||||
{detail::permissions(p, prms, &ec);}
|
|
||||||
|
|
||||||
inline
|
inline void create_hard_link(path const& to, path const& new_hard_link)
|
||||||
path read_symlink(const path& p) {return detail::read_symlink(p);}
|
{
|
||||||
|
detail::create_hard_link(to, new_hard_link);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
path read_symlink(const path& p, system::error_code& ec)
|
{
|
||||||
{return detail::read_symlink(p, &ec);}
|
detail::create_hard_link(to, new_hard_link, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline void create_symlink(path const& to, path const& new_symlink)
|
||||||
bool remove(const path& p) {return detail::remove(p);}
|
{
|
||||||
|
detail::create_symlink(to, new_symlink);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
bool remove(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::remove(p, &ec);}
|
detail::create_symlink(to, new_symlink, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline bool equivalent(path const& p1, path const& p2)
|
||||||
boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}
|
{
|
||||||
|
return detail::equivalent(p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
boost::uintmax_t remove_all(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::remove_all(p, &ec);}
|
return detail::equivalent(p1, p2, &ec);
|
||||||
inline
|
}
|
||||||
void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}
|
|
||||||
|
|
||||||
inline
|
inline boost::uintmax_t file_size(path const& p)
|
||||||
void rename(const path& old_p, const path& new_p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{detail::rename(old_p, new_p, &ec);}
|
return detail::file_size(p);
|
||||||
inline // name suggested by Scott McMurray
|
}
|
||||||
void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}
|
|
||||||
|
|
||||||
inline
|
inline boost::uintmax_t file_size(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
void resize_file(const path& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{detail::resize_file(p, size, &ec);}
|
return detail::file_size(p, &ec);
|
||||||
inline
|
}
|
||||||
path relative(const path& p, const path& base=current_path())
|
|
||||||
{return detail::relative(p, base);}
|
inline boost::uintmax_t hard_link_count(path const& p)
|
||||||
inline
|
{
|
||||||
path relative(const path& p, system::error_code& ec)
|
return detail::hard_link_count(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline boost::uintmax_t hard_link_count(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::hard_link_count(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::time_t creation_time(path const& p)
|
||||||
|
{
|
||||||
|
return detail::creation_time(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::time_t creation_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::creation_time(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::time_t last_write_time(path const& p)
|
||||||
|
{
|
||||||
|
return detail::last_write_time(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::time_t last_write_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::last_write_time(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void last_write_time(path const& p, const std::time_t new_time)
|
||||||
|
{
|
||||||
|
detail::last_write_time(p, new_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void last_write_time(path const& p, const std::time_t new_time, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
detail::last_write_time(p, new_time, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void permissions(path const& p, perms prms)
|
||||||
|
{
|
||||||
|
detail::permissions(p, prms);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void permissions(path const& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
detail::permissions(p, prms, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path read_symlink(path const& p)
|
||||||
|
{
|
||||||
|
return detail::read_symlink(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path read_symlink(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return detail::read_symlink(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool remove(path const& p)
|
||||||
|
{
|
||||||
|
return detail::remove(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool remove(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::remove(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline boost::uintmax_t remove_all(path const& p)
|
||||||
|
{
|
||||||
|
return detail::remove_all(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline boost::uintmax_t remove_all(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::remove_all(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void rename(path const& old_p, path const& new_p)
|
||||||
|
{
|
||||||
|
detail::rename(old_p, new_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void rename(path const& old_p, path const& new_p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
detail::rename(old_p, new_p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
// name suggested by Scott McMurray
|
||||||
|
inline void resize_file(path const& p, uintmax_t size)
|
||||||
|
{
|
||||||
|
detail::resize_file(p, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void resize_file(path const& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
detail::resize_file(p, size, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path relative(path const& p, path const& base = current_path())
|
||||||
|
{
|
||||||
|
return detail::relative(p, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path relative(path const& p, system::error_code& ec)
|
||||||
{
|
{
|
||||||
path base = current_path(ec);
|
path base = current_path(ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
return path();
|
return path();
|
||||||
return detail::relative(p, base, &ec);
|
return detail::relative(p, base, &ec);
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
path relative(const path& p, const path& base, system::error_code& ec)
|
|
||||||
{return detail::relative(p, base, &ec);}
|
|
||||||
inline
|
|
||||||
space_info space(const path& p) {return detail::space(p);}
|
|
||||||
|
|
||||||
inline
|
inline path relative(path const& p, path const& base, system::error_code& ec)
|
||||||
space_info space(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
{
|
||||||
{return detail::space(p, &ec);}
|
return detail::relative(p, base, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline space_info space(path const& p)
|
||||||
|
{
|
||||||
|
return detail::space(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline space_info space(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::space(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
inline bool symbolic_link_exists(const path& p)
|
inline bool symbolic_link_exists(path const& p)
|
||||||
{ return is_symlink(filesystem::symlink_status(p)); }
|
{
|
||||||
|
return is_symlink(filesystem::symlink_status(p));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline
|
inline path system_complete(path const& p)
|
||||||
path system_complete(const path& p) {return detail::system_complete(p);}
|
{
|
||||||
|
return detail::system_complete(p);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline path system_complete(path const& p, system::error_code& ec)
|
||||||
path system_complete(const path& p, system::error_code& ec)
|
{
|
||||||
{return detail::system_complete(p, &ec);}
|
return detail::system_complete(p, &ec);
|
||||||
inline
|
}
|
||||||
path temp_directory_path() {return detail::temp_directory_path();}
|
|
||||||
|
|
||||||
inline
|
inline path temp_directory_path()
|
||||||
path temp_directory_path(system::error_code& ec)
|
{
|
||||||
{return detail::temp_directory_path(&ec);}
|
return detail::temp_directory_path();
|
||||||
inline
|
}
|
||||||
path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
|
|
||||||
{return detail::unique_path(p);}
|
|
||||||
inline
|
|
||||||
path unique_path(const path& p, system::error_code& ec)
|
|
||||||
{return detail::unique_path(p, &ec);}
|
|
||||||
inline
|
|
||||||
path weakly_canonical(const path& p) {return detail::weakly_canonical(p);}
|
|
||||||
|
|
||||||
inline
|
inline path temp_directory_path(system::error_code& ec)
|
||||||
path weakly_canonical(const path& p, system::error_code& ec)
|
{
|
||||||
{return detail::weakly_canonical(p, &ec);}
|
return detail::temp_directory_path(&ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path unique_path(path const& p = "%%%%-%%%%-%%%%-%%%%")
|
||||||
|
{
|
||||||
|
return detail::unique_path(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path unique_path(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return detail::unique_path(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path weakly_canonical(path const& p)
|
||||||
|
{
|
||||||
|
return detail::weakly_canonical(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline path weakly_canonical(path const& p, system::error_code& ec)
|
||||||
|
{
|
||||||
|
return detail::weakly_canonical(p, &ec);
|
||||||
|
}
|
||||||
|
|
||||||
// test helper -----------------------------------------------------------------------//
|
// test helper -----------------------------------------------------------------------//
|
||||||
|
|
||||||
@ -548,4 +711,5 @@ BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
|
|||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP
|
#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,15 +12,16 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/type_traits/is_array.hpp>
|
#include <boost/type_traits/is_array.hpp>
|
||||||
#include <boost/type_traits/decay.hpp>
|
#include <boost/type_traits/decay.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/core/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
|
#include <cstddef>
|
||||||
#include <cwchar> // for mbstate_t
|
#include <cwchar> // for mbstate_t
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -32,320 +33,358 @@
|
|||||||
|
|
||||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||||
|
|
||||||
namespace boost { namespace filesystem {
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL const system::error_category& codecvt_error_category();
|
BOOST_FILESYSTEM_DECL const system::error_category& codecvt_error_category();
|
||||||
// uses std::codecvt_base::result used for error codes:
|
// uses std::codecvt_base::result used for error codes:
|
||||||
//
|
//
|
||||||
// ok: Conversion successful.
|
// ok: Conversion successful.
|
||||||
// partial: Not all source characters converted; one or more additional source
|
// partial: Not all source characters converted; one or more additional source
|
||||||
// characters are needed to produce the final target character, or the
|
// characters are needed to produce the final target character, or the
|
||||||
// size of the target intermediate buffer was too small to hold the result.
|
// size of the target intermediate buffer was too small to hold the result.
|
||||||
// error: A character in the source could not be converted to the target encoding.
|
// error: A character in the source could not be converted to the target encoding.
|
||||||
// noconv: The source and target characters have the same type and encoding, so no
|
// noconv: The source and target characters have the same type and encoding, so no
|
||||||
// conversion was necessary.
|
// conversion was necessary.
|
||||||
|
|
||||||
class directory_entry;
|
class directory_entry;
|
||||||
|
|
||||||
namespace path_traits {
|
namespace path_traits {
|
||||||
|
|
||||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
|
typedef std::codecvt< wchar_t, char, std::mbstate_t > codecvt_type;
|
||||||
|
|
||||||
// is_pathable type trait; allows disabling over-agressive class path member templates
|
// is_pathable type trait; allows disabling over-agressive class path member templates
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
struct is_pathable { static const bool value = false; };
|
struct is_pathable
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
template<> struct is_pathable<char*> { static const bool value = true; };
|
template<>
|
||||||
template<> struct is_pathable<const char*> { static const bool value = true; };
|
struct is_pathable< char* >
|
||||||
template<> struct is_pathable<wchar_t*> { static const bool value = true; };
|
{
|
||||||
template<> struct is_pathable<const wchar_t*> { static const bool value = true; };
|
static const bool value = true;
|
||||||
template<> struct is_pathable<std::string> { static const bool value = true; };
|
};
|
||||||
template<> struct is_pathable<std::wstring> { static const bool value = true; };
|
|
||||||
template<> struct is_pathable<std::vector<char> > { static const bool value = true; };
|
|
||||||
template<> struct is_pathable<std::vector<wchar_t> > { static const bool value = true; };
|
|
||||||
template<> struct is_pathable<std::list<char> > { static const bool value = true; };
|
|
||||||
template<> struct is_pathable<std::list<wchar_t> > { static const bool value = true; };
|
|
||||||
template<> struct is_pathable<directory_entry> { static const bool value = true; };
|
|
||||||
|
|
||||||
// Pathable empty
|
template<>
|
||||||
|
struct is_pathable< const char* >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
template <class Container> inline
|
template<>
|
||||||
|
struct is_pathable< wchar_t* >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< const wchar_t* >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::string >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::wstring >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::vector< char > >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::vector< wchar_t > >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::list< char > >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< std::list< wchar_t > >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct is_pathable< directory_entry >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pathable empty
|
||||||
|
|
||||||
|
template< class Container >
|
||||||
|
inline
|
||||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||||
// conforming compilers. Replace by plain "bool" at some future date (2012?)
|
// conforming compilers. Replace by plain "bool" at some future date (2012?)
|
||||||
typename boost::disable_if<boost::is_array<Container>, bool>::type
|
typename boost::disable_if< boost::is_array< Container >, bool >::type
|
||||||
empty(const Container & c)
|
empty(Container const& c)
|
||||||
{ return c.begin() == c.end(); }
|
{
|
||||||
|
return c.begin() == c.end();
|
||||||
|
}
|
||||||
|
|
||||||
template <class T> inline
|
template< class T >
|
||||||
bool empty(T * const & c_str)
|
inline bool empty(T* const& c_str)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(c_str);
|
BOOST_ASSERT(c_str);
|
||||||
return !*c_str;
|
return !*c_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t N> inline
|
template< typename T, std::size_t N >
|
||||||
bool empty(T (&x)[N])
|
inline bool empty(T (&x)[N])
|
||||||
{ return !x[0]; }
|
{
|
||||||
|
return !x[0];
|
||||||
|
}
|
||||||
|
|
||||||
// value types differ ---------------------------------------------------------------//
|
// value types differ ---------------------------------------------------------------//
|
||||||
//
|
//
|
||||||
// A from_end argument of 0 is less efficient than a known end, so use only if needed
|
// A from_end argument of 0 is less efficient than a known end, so use only if needed
|
||||||
|
|
||||||
// with codecvt
|
// with codecvt
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void convert(const char* from,
|
void convert(const char* from,
|
||||||
const char* from_end, // 0 for null terminated MBCS
|
const char* from_end, // 0 for null terminated MBCS
|
||||||
std::wstring & to,
|
std::wstring& to, codecvt_type const& cvt);
|
||||||
const codecvt_type& cvt);
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void convert(const wchar_t* from,
|
void convert(const wchar_t* from,
|
||||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||||
std::string & to,
|
std::string& to, codecvt_type const& cvt);
|
||||||
const codecvt_type& cvt);
|
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, std::wstring& to, codecvt_type const& cvt)
|
||||||
void convert(const char* from,
|
{
|
||||||
std::wstring & to,
|
|
||||||
const codecvt_type& cvt)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
convert(from, 0, to, cvt);
|
convert(from, 0, to, cvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, std::string& to, codecvt_type const& cvt)
|
||||||
void convert(const wchar_t* from,
|
{
|
||||||
std::string & to,
|
|
||||||
const codecvt_type& cvt)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
convert(from, 0, to, cvt);
|
convert(from, 0, to, cvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// without codecvt
|
// without codecvt
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from,
|
||||||
void convert(const char* from,
|
|
||||||
const char* from_end, // 0 for null terminated MBCS
|
const char* from_end, // 0 for null terminated MBCS
|
||||||
std::wstring & to);
|
std::wstring& to);
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from,
|
||||||
void convert(const wchar_t* from,
|
|
||||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||||
std::string & to);
|
std::string& to);
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, std::wstring& to);
|
||||||
void convert(const char* from,
|
|
||||||
std::wstring & to);
|
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, std::string& to);
|
||||||
void convert(const wchar_t* from,
|
|
||||||
std::string & to);
|
|
||||||
|
|
||||||
// value types same -----------------------------------------------------------------//
|
// value types same -----------------------------------------------------------------//
|
||||||
|
|
||||||
// char with codecvt
|
// char with codecvt
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, const char* from_end, std::string& to, codecvt_type const&)
|
||||||
void convert(const char* from, const char* from_end, std::string & to,
|
{
|
||||||
const codecvt_type&)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
BOOST_ASSERT(from_end);
|
BOOST_ASSERT(from_end);
|
||||||
to.append(from, from_end);
|
to.append(from, from_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, std::string& to, codecvt_type const&)
|
||||||
void convert(const char* from,
|
{
|
||||||
std::string & to,
|
|
||||||
const codecvt_type&)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
to += from;
|
to += from;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wchar_t with codecvt
|
// wchar_t with codecvt
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to, codecvt_type const&)
|
||||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
|
{
|
||||||
const codecvt_type&)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
BOOST_ASSERT(from_end);
|
BOOST_ASSERT(from_end);
|
||||||
to.append(from, from_end);
|
to.append(from, from_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, std::wstring& to, codecvt_type const&)
|
||||||
void convert(const wchar_t* from,
|
{
|
||||||
std::wstring & to,
|
|
||||||
const codecvt_type&)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
to += from;
|
to += from;
|
||||||
}
|
}
|
||||||
|
|
||||||
// char without codecvt
|
// char without codecvt
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, const char* from_end, std::string& to)
|
||||||
void convert(const char* from, const char* from_end, std::string & to)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
BOOST_ASSERT(from_end);
|
BOOST_ASSERT(from_end);
|
||||||
to.append(from, from_end);
|
to.append(from, from_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void convert(const char* from, std::string& to)
|
||||||
void convert(const char* from, std::string & to)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
to += from;
|
to += from;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wchar_t without codecvt
|
// wchar_t without codecvt
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to)
|
||||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
BOOST_ASSERT(from_end);
|
BOOST_ASSERT(from_end);
|
||||||
to.append(from, from_end);
|
to.append(from, from_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void convert(const wchar_t* from, std::wstring& to)
|
||||||
void convert(const wchar_t* from, std::wstring & to)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
to += from;
|
to += from;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source dispatch -----------------------------------------------------------------//
|
// Source dispatch -----------------------------------------------------------------//
|
||||||
|
|
||||||
// contiguous containers with codecvt
|
// contiguous containers with codecvt
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::string& c, U& to, const codecvt_type& cvt)
|
inline void dispatch(std::string const& c, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::wstring& c, U& to, const codecvt_type& cvt)
|
inline void dispatch(std::wstring const& c, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::vector<char>& c, U& to, const codecvt_type& cvt)
|
inline void dispatch(std::vector< char > const& c, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::vector<wchar_t>& c, U& to, const codecvt_type& cvt)
|
inline void dispatch(std::vector< wchar_t > const& c, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// contiguous containers without codecvt
|
// contiguous containers without codecvt
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::string& c, U& to)
|
inline void dispatch(std::string const& c, U& to)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::wstring& c, U& to)
|
inline void dispatch(std::wstring const& c, U& to)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::vector<char>& c, U& to)
|
inline void dispatch(std::vector< char > const& c, U& to)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||||
}
|
}
|
||||||
template <class U> inline
|
template< class U >
|
||||||
void dispatch(const std::vector<wchar_t>& c, U& to)
|
inline void dispatch(std::vector< wchar_t > const& c, U& to)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||||
}
|
}
|
||||||
|
|
||||||
// non-contiguous containers with codecvt
|
// non-contiguous containers with codecvt
|
||||||
template <class Container, class U> inline
|
template< class Container, class U >
|
||||||
|
inline
|
||||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||||
typename boost::disable_if<boost::is_array<Container>, void>::type
|
typename boost::disable_if< boost::is_array< Container >, void >::type
|
||||||
dispatch(const Container & c, U& to, const codecvt_type& cvt)
|
dispatch(Container const& c, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
{
|
{
|
||||||
std::basic_string<typename Container::value_type> s(c.begin(), c.end());
|
std::basic_string< typename Container::value_type > s(c.begin(), c.end());
|
||||||
convert(s.c_str(), s.c_str()+s.size(), to, cvt);
|
convert(s.c_str(), s.c_str() + s.size(), to, cvt);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// c_str
|
// c_str
|
||||||
template <class T, class U> inline
|
template< class T, class U >
|
||||||
void dispatch(T * const & c_str, U& to, const codecvt_type& cvt)
|
inline void dispatch(T* const& c_str, U& to, codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
// std::cout << "dispatch() const T *\n";
|
// std::cout << "dispatch() const T *\n";
|
||||||
BOOST_ASSERT(c_str);
|
BOOST_ASSERT(c_str);
|
||||||
convert(c_str, to, cvt);
|
convert(c_str, to, cvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: there is no dispatch on C-style arrays because the array may
|
// Note: there is no dispatch on C-style arrays because the array may
|
||||||
// contain a string smaller than the array size.
|
// contain a string smaller than the array size.
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void dispatch(const directory_entry & de,
|
void dispatch(directory_entry const& de,
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
std::wstring & to,
|
std::wstring& to,
|
||||||
# else
|
#else
|
||||||
std::string & to,
|
std::string& to,
|
||||||
# endif
|
#endif
|
||||||
const codecvt_type&);
|
codecvt_type const&);
|
||||||
|
|
||||||
// non-contiguous containers without codecvt
|
// non-contiguous containers without codecvt
|
||||||
template <class Container, class U> inline
|
template< class Container, class U >
|
||||||
|
inline
|
||||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||||
typename boost::disable_if<boost::is_array<Container>, void>::type
|
typename boost::disable_if< boost::is_array< Container >, void >::type
|
||||||
dispatch(const Container & c, U& to)
|
dispatch(Container const& c, U& to)
|
||||||
{
|
{
|
||||||
if (!c.empty())
|
if (!c.empty())
|
||||||
{
|
{
|
||||||
std::basic_string<typename Container::value_type> seq(c.begin(), c.end());
|
std::basic_string< typename Container::value_type > seq(c.begin(), c.end());
|
||||||
convert(seq.c_str(), seq.c_str()+seq.size(), to);
|
convert(seq.c_str(), seq.c_str() + seq.size(), to);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// c_str
|
// c_str
|
||||||
template <class T, class U> inline
|
template< class T, class U >
|
||||||
void dispatch(T * const & c_str, U& to)
|
inline void dispatch(T* const& c_str, U& to)
|
||||||
{
|
{
|
||||||
// std::cout << "dispatch() const T *\n";
|
// std::cout << "dispatch() const T *\n";
|
||||||
BOOST_ASSERT(c_str);
|
BOOST_ASSERT(c_str);
|
||||||
convert(c_str, to);
|
convert(c_str, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: there is no dispatch on C-style arrays because the array may
|
// Note: there is no dispatch on C-style arrays because the array may
|
||||||
// contain a string smaller than the array size.
|
// contain a string smaller than the array size.
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void dispatch(const directory_entry & de,
|
void dispatch(directory_entry const& de,
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
std::wstring & to
|
std::wstring& to
|
||||||
# else
|
#else
|
||||||
std::string & to
|
std::string& to
|
||||||
# endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
} // namespace path_traits
|
||||||
}}} // namespace boost::filesystem::path_traits
|
} // namespace filesystem
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||||
|
|
||||||
|
@ -10,34 +10,35 @@
|
|||||||
#ifndef BOOST_FILESYSTEM_STRING_FILE_HPP
|
#ifndef BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||||
#define BOOST_FILESYSTEM_STRING_FILE_HPP
|
#define BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <ios>
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
{
|
namespace filesystem {
|
||||||
namespace filesystem
|
|
||||||
{
|
inline void save_string_file(path const& p, std::string const& str)
|
||||||
inline
|
|
||||||
void save_string_file(const path& p, const std::string& str)
|
|
||||||
{
|
{
|
||||||
filesystem::ofstream file;
|
filesystem::ofstream file;
|
||||||
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||||
file.open(p, std::ios_base::binary);
|
file.open(p, std::ios_base::binary);
|
||||||
file.write(str.c_str(), str.size());
|
file.write(str.c_str(), str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void load_string_file(path const& p, std::string& str)
|
||||||
void load_string_file(const path& p, std::string& str)
|
|
||||||
{
|
{
|
||||||
filesystem::ifstream file;
|
filesystem::ifstream file;
|
||||||
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||||
file.open(p, std::ios_base::binary);
|
file.open(p, std::ios_base::binary);
|
||||||
std::size_t sz = static_cast<std::size_t>(filesystem::file_size(p));
|
std::size_t sz = static_cast< std::size_t >(filesystem::file_size(p));
|
||||||
str.resize(sz, '\0');
|
str.resize(sz, '\0');
|
||||||
file.read(&str[0], sz);
|
file.read(&str[0], sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // include guard
|
#endif // BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||||
|
@ -13,32 +13,38 @@
|
|||||||
|
|
||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
|
|
||||||
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path_traits.hpp>
|
#include <boost/filesystem/path_traits.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
namespace
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class codecvt_error_cat BOOST_FINAL :
|
||||||
|
public boost::system::error_category
|
||||||
{
|
{
|
||||||
class codecvt_error_cat : public boost::system::error_category
|
public:
|
||||||
{
|
BOOST_DEFAULTED_FUNCTION(codecvt_error_cat(), {})
|
||||||
public:
|
|
||||||
codecvt_error_cat(){}
|
|
||||||
const char* name() const BOOST_SYSTEM_NOEXCEPT BOOST_OVERRIDE;
|
const char* name() const BOOST_SYSTEM_NOEXCEPT BOOST_OVERRIDE;
|
||||||
std::string message(int ev) const BOOST_OVERRIDE;
|
std::string message(int ev) const BOOST_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
|
const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
|
||||||
{
|
{
|
||||||
return "codecvt";
|
return "codecvt";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string codecvt_error_cat::message(int ev) const
|
std::string codecvt_error_cat::message(int ev) const
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
switch (ev)
|
switch (ev)
|
||||||
{
|
{
|
||||||
@ -56,22 +62,18 @@ namespace
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
str = "unknown error";
|
str = "unknown error";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
namespace boost
|
BOOST_FILESYSTEM_DECL boost::system::error_category const& codecvt_error_category()
|
||||||
{
|
{
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
|
|
||||||
{
|
|
||||||
static const codecvt_error_cat codecvt_error_cat_const;
|
static const codecvt_error_cat codecvt_error_cat_const;
|
||||||
return codecvt_error_cat_const;
|
return codecvt_error_cat_const;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "platform_config.hpp"
|
#include "platform_config.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/directory.hpp>
|
#include <boost/filesystem/directory.hpp>
|
||||||
#include <boost/filesystem/exception.hpp>
|
#include <boost/filesystem/exception.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
@ -36,14 +37,13 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0)\
|
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS + 0 >= 0) && defined(_SC_THREAD_SAFE_FUNCTIONS) && \
|
||||||
&& defined(_SC_THREAD_SAFE_FUNCTIONS)\
|
!defined(__CYGWIN__) && \
|
||||||
&& !defined(__CYGWIN__)\
|
!(defined(linux) || defined(__linux) || defined(__linux__)) && \
|
||||||
&& !(defined(linux) || defined(__linux) || defined(__linux__))\
|
!defined(__ANDROID__) && \
|
||||||
&& !defined(__ANDROID__)\
|
(!defined(__hpux) || defined(_REENTRANT)) && \
|
||||||
&& (!defined(__hpux) || defined(_REENTRANT)) \
|
(!defined(_AIX) || defined(__THREAD_SAFE)) && \
|
||||||
&& (!defined(_AIX) || defined(__THREAD_SAFE))\
|
!defined(__wasm)
|
||||||
&& !defined(__wasm)
|
|
||||||
#define BOOST_FILESYSTEM_USE_READDIR_R
|
#define BOOST_FILESYSTEM_USE_READDIR_R
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -63,8 +63,7 @@
|
|||||||
// macros being tested come from dirent.h.
|
// macros being tested come from dirent.h.
|
||||||
//
|
//
|
||||||
// TODO: find out what macros indicate dirent::d_type present in more libraries
|
// TODO: find out what macros indicate dirent::d_type present in more libraries
|
||||||
#if defined(BOOST_WINDOWS_API)\
|
#if defined(BOOST_WINDOWS_API) || defined(_DIRENT_HAVE_D_TYPE) // defined by GNU C library if d_type present
|
||||||
|| defined(_DIRENT_HAVE_D_TYPE)// defined by GNU C library if d_type present
|
|
||||||
#define BOOST_FILESYSTEM_STATUS_CACHE
|
#define BOOST_FILESYSTEM_STATUS_CACHE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -125,24 +124,26 @@ file_status directory_entry::get_symlink_status(system::error_code* ec) const
|
|||||||
|
|
||||||
namespace path_traits {
|
namespace path_traits {
|
||||||
|
|
||||||
void dispatch(const directory_entry& de,
|
BOOST_FILESYSTEM_DECL
|
||||||
|
void dispatch(directory_entry const& de,
|
||||||
#ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
std::wstring& to,
|
std::wstring& to,
|
||||||
#else
|
#else
|
||||||
std::string& to,
|
std::string& to,
|
||||||
#endif
|
#endif
|
||||||
const codecvt_type&)
|
codecvt_type const&)
|
||||||
{
|
{
|
||||||
to = de.path().native();
|
to = de.path().native();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch(const directory_entry& de,
|
BOOST_FILESYSTEM_DECL
|
||||||
|
void dispatch(directory_entry const& de,
|
||||||
#ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
std::wstring& to
|
std::wstring& to
|
||||||
#else
|
#else
|
||||||
std::string& to
|
std::string& to
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
to = de.path().native();
|
to = de.path().native();
|
||||||
}
|
}
|
||||||
@ -203,9 +204,7 @@ inline std::size_t path_max()
|
|||||||
|
|
||||||
#endif // BOOST_FILESYSTEM_USE_READDIR_R
|
#endif // BOOST_FILESYSTEM_USE_READDIR_R
|
||||||
|
|
||||||
error_code dir_itr_first(void*& handle, void*& buffer,
|
error_code dir_itr_first(void*& handle, void*& buffer, const char* dir, std::string& target, fs::file_status&, fs::file_status&)
|
||||||
const char* dir, std::string& target,
|
|
||||||
fs::file_status&, fs::file_status&)
|
|
||||||
{
|
{
|
||||||
if ((handle = ::opendir(dir)) == 0)
|
if ((handle = ::opendir(dir)) == 0)
|
||||||
{
|
{
|
||||||
@ -255,11 +254,10 @@ inline int readdir_r_simulator(DIR* dirp, void*& buffer, struct dirent** result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code dir_itr_increment(void*& handle, void*& buffer,
|
error_code dir_itr_increment(void*& handle, void*& buffer, std::string& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||||
std::string& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
|
||||||
{
|
{
|
||||||
dirent* result = NULL;
|
dirent* result = NULL;
|
||||||
int err = readdir_r_simulator(static_cast<DIR*>(handle), buffer, &result);
|
int err = readdir_r_simulator(static_cast< DIR* >(handle), buffer, &result);
|
||||||
if (BOOST_UNLIKELY(err != 0))
|
if (BOOST_UNLIKELY(err != 0))
|
||||||
return error_code(err, system_category());
|
return error_code(err, system_category());
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
@ -294,29 +292,26 @@ error_code dir_itr_increment(void*& handle, void*& buffer,
|
|||||||
|
|
||||||
#else // BOOST_WINDOWS_API
|
#else // BOOST_WINDOWS_API
|
||||||
|
|
||||||
error_code dir_itr_first(void*& handle, const fs::path& dir,
|
error_code dir_itr_first(void*& handle, fs::path const& dir, std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||||
std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
|
||||||
// Note: an empty root directory has no "." or ".." entries, so this
|
// Note: an empty root directory has no "." or ".." entries, so this
|
||||||
// causes a ERROR_FILE_NOT_FOUND error which we do not considered an
|
// causes a ERROR_FILE_NOT_FOUND error which we do not considered an
|
||||||
// error. It is treated as eof instead.
|
// error. It is treated as eof instead.
|
||||||
{
|
{
|
||||||
// use a form of search Sebastian Martel reports will work with Win98
|
// use a form of search Sebastian Martel reports will work with Win98
|
||||||
std::wstring dirpath(dir.wstring());
|
std::wstring dirpath(dir.wstring());
|
||||||
dirpath += (dirpath.empty()
|
dirpath += (dirpath.empty() || (dirpath[dirpath.size() - 1] != L'\\' && dirpath[dirpath.size() - 1] != L'/' && dirpath[dirpath.size() - 1] != L':')) ? L"\\*" : L"*";
|
||||||
|| (dirpath[dirpath.size()-1] != L'\\'
|
|
||||||
&& dirpath[dirpath.size()-1] != L'/'
|
|
||||||
&& dirpath[dirpath.size()-1] != L':'))? L"\\*" : L"*";
|
|
||||||
|
|
||||||
WIN32_FIND_DATAW data;
|
WIN32_FIND_DATAW data;
|
||||||
if ((handle = ::FindFirstFileW(dirpath.c_str(), &data))
|
if ((handle = ::FindFirstFileW(dirpath.c_str(), &data)) == INVALID_HANDLE_VALUE)
|
||||||
== INVALID_HANDLE_VALUE)
|
|
||||||
{
|
{
|
||||||
handle = 0; // signal eof
|
handle = 0; // signal eof
|
||||||
DWORD error = ::GetLastError();
|
DWORD error = ::GetLastError();
|
||||||
return error_code( (error == ERROR_FILE_NOT_FOUND
|
return error_code((error == ERROR_FILE_NOT_FOUND
|
||||||
// Windows Mobile returns ERROR_NO_MORE_FILES; see ticket #3551
|
// Windows Mobile returns ERROR_NO_MORE_FILES; see ticket #3551
|
||||||
|| error == ERROR_NO_MORE_FILES)
|
|| error == ERROR_NO_MORE_FILES) ?
|
||||||
? 0 : error, system_category() );
|
0 :
|
||||||
|
error,
|
||||||
|
system_category());
|
||||||
}
|
}
|
||||||
target = data.cFileName;
|
target = data.cFileName;
|
||||||
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||||
@ -348,7 +343,7 @@ error_code dir_itr_first(void*& handle, const fs::path& dir,
|
|||||||
error_code dir_itr_increment(void*& handle, std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
error_code dir_itr_increment(void*& handle, std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATAW data;
|
WIN32_FIND_DATAW data;
|
||||||
if (::FindNextFileW(handle, &data)== 0)// fails
|
if (::FindNextFileW(handle, &data) == 0) // fails
|
||||||
{
|
{
|
||||||
DWORD error = ::GetLastError();
|
DWORD error = ::GetLastError();
|
||||||
fs::detail::dir_itr_close(handle);
|
fs::detail::dir_itr_close(handle);
|
||||||
@ -388,7 +383,7 @@ BOOST_CONSTEXPR_OR_CONST err_t not_found_error_code =
|
|||||||
#else
|
#else
|
||||||
ENOENT
|
ENOENT
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -412,7 +407,7 @@ system::error_code dir_itr_close( // never throws
|
|||||||
|
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
{
|
{
|
||||||
DIR* h = static_cast<DIR*>(handle);
|
DIR* h = static_cast< DIR* >(handle);
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if (BOOST_UNLIKELY(::closedir(h) != 0))
|
if (BOOST_UNLIKELY(::closedir(h) != 0))
|
||||||
@ -437,10 +432,9 @@ system::error_code dir_itr_close( // never throws
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void directory_iterator_construct(directory_iterator& it, const path& p, unsigned int opts, system::error_code* ec)
|
void directory_iterator_construct(directory_iterator& it, path const& p, unsigned int opts, system::error_code* ec)
|
||||||
{
|
{
|
||||||
if (error(p.empty() ? not_found_error_code : 0, p, ec,
|
if (error(p.empty() ? not_found_error_code : 0, p, ec, "boost::filesystem::directory_iterator::construct"))
|
||||||
"boost::filesystem::directory_iterator::construct"))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -465,9 +459,9 @@ void directory_iterator_construct(directory_iterator& it, const path& p, unsigne
|
|||||||
path::string_type filename;
|
path::string_type filename;
|
||||||
file_status file_stat, symlink_file_stat;
|
file_status file_stat, symlink_file_stat;
|
||||||
error_code result = dir_itr_first(imp->handle,
|
error_code result = dir_itr_first(imp->handle,
|
||||||
# if defined(BOOST_POSIX_API)
|
#if defined(BOOST_POSIX_API)
|
||||||
imp->buffer,
|
imp->buffer,
|
||||||
# endif
|
#endif
|
||||||
p.c_str(), filename, file_stat, symlink_file_stat);
|
p.c_str(), filename, file_stat, symlink_file_stat);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
@ -475,8 +469,7 @@ void directory_iterator_construct(directory_iterator& it, const path& p, unsigne
|
|||||||
if (result != make_error_condition(system::errc::permission_denied) ||
|
if (result != make_error_condition(system::errc::permission_denied) ||
|
||||||
(opts & static_cast< unsigned int >(directory_options::skip_permission_denied)) == 0u)
|
(opts & static_cast< unsigned int >(directory_options::skip_permission_denied)) == 0u)
|
||||||
{
|
{
|
||||||
error(result.value(), p,
|
error(result.value(), p, ec, "boost::filesystem::directory_iterator::construct");
|
||||||
ec, "boost::filesystem::directory_iterator::construct");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -523,9 +516,9 @@ void directory_iterator_increment(directory_iterator& it, system::error_code* ec
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
increment_ec = dir_itr_increment(it.m_imp->handle,
|
increment_ec = dir_itr_increment(it.m_imp->handle,
|
||||||
# if defined(BOOST_POSIX_API)
|
#if defined(BOOST_POSIX_API)
|
||||||
it.m_imp->buffer,
|
it.m_imp->buffer,
|
||||||
# endif
|
#endif
|
||||||
filename, file_stat, symlink_file_stat);
|
filename, file_stat, symlink_file_stat);
|
||||||
|
|
||||||
if (BOOST_UNLIKELY(!!increment_ec)) // happens if filesystem is corrupt, such as on a damaged optical disc
|
if (BOOST_UNLIKELY(!!increment_ec)) // happens if filesystem is corrupt, such as on a damaged optical disc
|
||||||
@ -536,9 +529,7 @@ void directory_iterator_increment(directory_iterator& it, system::error_code* ec
|
|||||||
if (ec == NULL)
|
if (ec == NULL)
|
||||||
{
|
{
|
||||||
BOOST_FILESYSTEM_THROW(
|
BOOST_FILESYSTEM_THROW(
|
||||||
filesystem_error("boost::filesystem::directory_iterator::operator++",
|
filesystem_error("boost::filesystem::directory_iterator::operator++", error_path, increment_ec));
|
||||||
error_path,
|
|
||||||
increment_ec));
|
|
||||||
}
|
}
|
||||||
*ec = increment_ec;
|
*ec = increment_ec;
|
||||||
return;
|
return;
|
||||||
@ -577,7 +568,7 @@ void directory_iterator_increment(directory_iterator& it, system::error_code* ec
|
|||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void recursive_directory_iterator_construct(recursive_directory_iterator& it, const path& dir_path, unsigned int opts, system::error_code* ec)
|
void recursive_directory_iterator_construct(recursive_directory_iterator& it, path const& dir_path, unsigned int opts, system::error_code* ec)
|
||||||
{
|
{
|
||||||
if (ec)
|
if (ec)
|
||||||
ec->clear();
|
ec->clear();
|
||||||
@ -748,8 +739,7 @@ inline push_directory_result recursive_directory_iterator_push_directory(detail:
|
|||||||
if (BOOST_UNLIKELY(!!ec))
|
if (BOOST_UNLIKELY(!!ec))
|
||||||
{
|
{
|
||||||
if (ec == make_error_condition(system::errc::no_such_file_or_directory) && fs::is_symlink(symlink_stat) &&
|
if (ec == make_error_condition(system::errc::no_such_file_or_directory) && fs::is_symlink(symlink_stat) &&
|
||||||
(imp->m_options & static_cast< unsigned int >(directory_options::follow_directory_symlink | directory_options::skip_dangling_symlinks))
|
(imp->m_options & static_cast< unsigned int >(directory_options::follow_directory_symlink | directory_options::skip_dangling_symlinks)) == static_cast< unsigned int >(directory_options::follow_directory_symlink | directory_options::skip_dangling_symlinks))
|
||||||
== static_cast< unsigned int >(directory_options::follow_directory_symlink | directory_options::skip_dangling_symlinks))
|
|
||||||
{
|
{
|
||||||
// Skip dangling symlink and continue iteration on the current depth level
|
// Skip dangling symlink and continue iteration on the current depth level
|
||||||
ec = error_code();
|
ec = error_code();
|
||||||
|
@ -55,8 +55,8 @@ typedef boost::winapi::DWORD_ err_t;
|
|||||||
|
|
||||||
// Implemented in exception.cpp
|
// Implemented in exception.cpp
|
||||||
void emit_error(err_t error_num, system::error_code* ec, const char* message);
|
void emit_error(err_t error_num, system::error_code* ec, const char* message);
|
||||||
void emit_error(err_t error_num, const path& p, system::error_code* ec, const char* message);
|
void emit_error(err_t error_num, path const& p, system::error_code* ec, const char* message);
|
||||||
void emit_error(err_t error_num, const path& p1, const path& p2, system::error_code* ec, const char* message);
|
void emit_error(err_t error_num, path const& p1, path const& p2, system::error_code* ec, const char* message);
|
||||||
|
|
||||||
inline bool error(err_t error_num, system::error_code* ec, const char* message)
|
inline bool error(err_t error_num, system::error_code* ec, const char* message)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ inline bool error(err_t error_num, system::error_code* ec, const char* message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool error(err_t error_num, const path& p, system::error_code* ec, const char* message)
|
inline bool error(err_t error_num, path const& p, system::error_code* ec, const char* message)
|
||||||
{
|
{
|
||||||
if (BOOST_LIKELY(!error_num))
|
if (BOOST_LIKELY(!error_num))
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ inline bool error(err_t error_num, const path& p, system::error_code* ec, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool error(err_t error_num, const path& p1, const path& p2, system::error_code* ec, const char* message)
|
inline bool error(err_t error_num, path const& p1, path const& p2, system::error_code* ec, const char* message)
|
||||||
{
|
{
|
||||||
if (BOOST_LIKELY(!error_num))
|
if (BOOST_LIKELY(!error_num))
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what_arg, const path& path1_arg, system::error_code ec) :
|
BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what_arg, path const& path1_arg, system::error_code ec) :
|
||||||
system::system_error(ec, what_arg)
|
system::system_error(ec, what_arg)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -48,7 +48,7 @@ BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec) :
|
BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(const std::string& what_arg, path const& path1_arg, path const& path2_arg, system::error_code ec) :
|
||||||
system::system_error(ec, what_arg)
|
system::system_error(ec, what_arg)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -67,7 +67,7 @@ BOOST_FILESYSTEM_DECL filesystem_error::filesystem_error(filesystem_error const&
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL filesystem_error& filesystem_error::operator= (filesystem_error const& that)
|
BOOST_FILESYSTEM_DECL filesystem_error& filesystem_error::operator=(filesystem_error const& that)
|
||||||
{
|
{
|
||||||
static_cast< system::system_error& >(*this) = static_cast< system::system_error const& >(that);
|
static_cast< system::system_error& >(*this) = static_cast< system::system_error const& >(that);
|
||||||
m_imp_ptr = that.m_imp_ptr;
|
m_imp_ptr = that.m_imp_ptr;
|
||||||
@ -80,7 +80,8 @@ BOOST_FILESYSTEM_DECL filesystem_error::~filesystem_error() BOOST_NOEXCEPT_OR_NO
|
|||||||
|
|
||||||
BOOST_FILESYSTEM_DECL const char* filesystem_error::what() const BOOST_NOEXCEPT_OR_NOTHROW
|
BOOST_FILESYSTEM_DECL const char* filesystem_error::what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||||
{
|
{
|
||||||
if (m_imp_ptr.get()) try
|
if (m_imp_ptr.get())
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (m_imp_ptr->m_what.empty())
|
if (m_imp_ptr->m_what.empty())
|
||||||
{
|
{
|
||||||
@ -109,7 +110,7 @@ BOOST_FILESYSTEM_DECL const char* filesystem_error::what() const BOOST_NOEXCEPT_
|
|||||||
return system::system_error::what();
|
return system::system_error::what();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL const path& filesystem_error::get_empty_path() BOOST_NOEXCEPT
|
BOOST_FILESYSTEM_DECL path const& filesystem_error::get_empty_path() BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
static const path empty_path;
|
static const path empty_path;
|
||||||
return empty_path;
|
return empty_path;
|
||||||
@ -125,7 +126,7 @@ void emit_error(err_t error_num, system::error_code* ec, const char* message)
|
|||||||
ec->assign(error_num, system::system_category());
|
ec->assign(error_num, system::system_category());
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit_error(err_t error_num, const path& p, system::error_code* ec, const char* message)
|
void emit_error(err_t error_num, path const& p, system::error_code* ec, const char* message)
|
||||||
{
|
{
|
||||||
if (!ec)
|
if (!ec)
|
||||||
BOOST_FILESYSTEM_THROW(filesystem_error(message, p, system::error_code(error_num, system::system_category())));
|
BOOST_FILESYSTEM_THROW(filesystem_error(message, p, system::error_code(error_num, system::system_category())));
|
||||||
@ -133,7 +134,7 @@ void emit_error(err_t error_num, const path& p, system::error_code* ec, const ch
|
|||||||
ec->assign(error_num, system::system_category());
|
ec->assign(error_num, system::system_category());
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit_error(err_t error_num, const path& p1, const path& p2, system::error_code* ec, const char* message)
|
void emit_error(err_t error_num, path const& p1, path const& p2, system::error_code* ec, const char* message)
|
||||||
{
|
{
|
||||||
if (ec == 0)
|
if (ec == 0)
|
||||||
BOOST_FILESYSTEM_THROW(filesystem_error(message, p1, p2, system::error_code(error_num, system::system_category())));
|
BOOST_FILESYSTEM_THROW(filesystem_error(message, p1, p2, system::error_code(error_num, system::system_category())));
|
||||||
|
File diff suppressed because it is too large
Load Diff
792
src/path.cpp
792
src/path.cpp
File diff suppressed because it is too large
Load Diff
@ -11,12 +11,16 @@
|
|||||||
|
|
||||||
#include "platform_config.hpp"
|
#include "platform_config.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path_traits.hpp>
|
#include <boost/filesystem/path_traits.hpp>
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/scoped_array.hpp>
|
#include <boost/smart_ptr/scoped_array.hpp>
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
#include <string>
|
||||||
#include <locale> // for codecvt_base::result
|
#include <locale> // for codecvt_base::result
|
||||||
#include <cstring> // for strlen
|
#include <cstring> // for strlen
|
||||||
#include <cwchar> // for wcslen
|
#include <cwchar> // for wcslen
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace pt = boost::filesystem::path_traits;
|
namespace pt = boost::filesystem::path_traits;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@ -27,13 +31,12 @@ namespace bs = boost::system;
|
|||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_CODECVT_BUF_SIZE
|
#ifndef BOOST_FILESYSTEM_CODECVT_BUF_SIZE
|
||||||
# define BOOST_FILESYSTEM_CODECVT_BUF_SIZE 256
|
#define BOOST_FILESYSTEM_CODECVT_BUF_SIZE 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const std::size_t default_codecvt_buf_size = BOOST_FILESYSTEM_CODECVT_BUF_SIZE;
|
BOOST_CONSTEXPR_OR_CONST std::size_t default_codecvt_buf_size = BOOST_FILESYSTEM_CODECVT_BUF_SIZE;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// //
|
// //
|
||||||
@ -46,13 +49,13 @@ namespace {
|
|||||||
// convert_aux const char* to wstring //
|
// convert_aux const char* to wstring //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
void convert_aux(
|
void convert_aux(
|
||||||
const char* from,
|
const char* from,
|
||||||
const char* from_end,
|
const char* from_end,
|
||||||
wchar_t* to, wchar_t* to_end,
|
wchar_t* to, wchar_t* to_end,
|
||||||
std::wstring & target,
|
std::wstring& target,
|
||||||
const pt::codecvt_type & cvt)
|
pt::codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
//std::cout << std::hex
|
//std::cout << std::hex
|
||||||
// << " from=" << std::size_t(from)
|
// << " from=" << std::size_t(from)
|
||||||
// << " from_end=" << std::size_t(from_end)
|
// << " from_end=" << std::size_t(from_end)
|
||||||
@ -66,27 +69,25 @@ namespace {
|
|||||||
|
|
||||||
std::codecvt_base::result res;
|
std::codecvt_base::result res;
|
||||||
|
|
||||||
if ((res=cvt.in(state, from, from_end, from_next,
|
if ((res = cvt.in(state, from, from_end, from_next, to, to_end, to_next)) != std::codecvt_base::ok)
|
||||||
to, to_end, to_next)) != std::codecvt_base::ok)
|
|
||||||
{
|
{
|
||||||
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
||||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(),
|
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(), "boost::filesystem::path codecvt to wstring"));
|
||||||
"boost::filesystem::path codecvt to wstring"));
|
|
||||||
}
|
}
|
||||||
target.append(to, to_next);
|
target.append(to, to_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// convert_aux const wchar_t* to string //
|
// convert_aux const wchar_t* to string //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
void convert_aux(
|
void convert_aux(
|
||||||
const wchar_t* from,
|
const wchar_t* from,
|
||||||
const wchar_t* from_end,
|
const wchar_t* from_end,
|
||||||
char* to, char* to_end,
|
char* to, char* to_end,
|
||||||
std::string & target,
|
std::string& target,
|
||||||
const pt::codecvt_type & cvt)
|
pt::codecvt_type const& cvt)
|
||||||
{
|
{
|
||||||
//std::cout << std::hex
|
//std::cout << std::hex
|
||||||
// << " from=" << std::size_t(from)
|
// << " from=" << std::size_t(from)
|
||||||
// << " from_end=" << std::size_t(from_end)
|
// << " from_end=" << std::size_t(from_end)
|
||||||
@ -100,15 +101,13 @@ namespace {
|
|||||||
|
|
||||||
std::codecvt_base::result res;
|
std::codecvt_base::result res;
|
||||||
|
|
||||||
if ((res=cvt.out(state, from, from_end, from_next,
|
if ((res = cvt.out(state, from, from_end, from_next, to, to_end, to_next)) != std::codecvt_base::ok)
|
||||||
to, to_end, to_next)) != std::codecvt_base::ok)
|
|
||||||
{
|
{
|
||||||
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
||||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(),
|
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(), "boost::filesystem::path codecvt to string"));
|
||||||
"boost::filesystem::path codecvt to string"));
|
|
||||||
}
|
}
|
||||||
target.append(to, to_next);
|
target.append(to, to_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
@ -116,18 +115,19 @@ namespace {
|
|||||||
// path_traits //
|
// path_traits //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
namespace boost { namespace filesystem { namespace path_traits {
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
namespace path_traits {
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// convert const char* to wstring //
|
// convert const char* to wstring //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void convert(const char* from,
|
void convert(const char* from,
|
||||||
const char* from_end, // 0 for null terminated MBCS
|
const char* from_end, // 0 for null terminated MBCS
|
||||||
std::wstring & to,
|
std::wstring& to, codecvt_type const& cvt)
|
||||||
const codecvt_type & cvt)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
|
|
||||||
if (!from_end) // null terminated
|
if (!from_end) // null terminated
|
||||||
@ -135,33 +135,33 @@ namespace boost { namespace filesystem { namespace path_traits {
|
|||||||
from_end = from + std::strlen(from);
|
from_end = from + std::strlen(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from == from_end) return;
|
if (from == from_end)
|
||||||
|
return;
|
||||||
|
|
||||||
std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK
|
std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK
|
||||||
|
|
||||||
// dynamically allocate a buffer only if source is unusually large
|
// dynamically allocate a buffer only if source is unusually large
|
||||||
if (buf_size > default_codecvt_buf_size)
|
if (buf_size > default_codecvt_buf_size)
|
||||||
{
|
{
|
||||||
boost::scoped_array< wchar_t > buf(new wchar_t [buf_size]);
|
boost::scoped_array< wchar_t > buf(new wchar_t[buf_size]);
|
||||||
convert_aux(from, from_end, buf.get(), buf.get()+buf_size, to, cvt);
|
convert_aux(from, from_end, buf.get(), buf.get() + buf_size, to, cvt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wchar_t buf[default_codecvt_buf_size];
|
wchar_t buf[default_codecvt_buf_size];
|
||||||
convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
|
convert_aux(from, from_end, buf, buf + default_codecvt_buf_size, to, cvt);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
// convert const wchar_t* to string //
|
// convert const wchar_t* to string //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL
|
BOOST_FILESYSTEM_DECL
|
||||||
void convert(const wchar_t* from,
|
void convert(const wchar_t* from,
|
||||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||||
std::string & to,
|
std::string& to, codecvt_type const& cvt)
|
||||||
const codecvt_type & cvt)
|
{
|
||||||
{
|
|
||||||
BOOST_ASSERT(from);
|
BOOST_ASSERT(from);
|
||||||
|
|
||||||
if (!from_end) // null terminated
|
if (!from_end) // null terminated
|
||||||
@ -169,7 +169,8 @@ namespace boost { namespace filesystem { namespace path_traits {
|
|||||||
from_end = from + std::wcslen(from);
|
from_end = from + std::wcslen(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from == from_end) return;
|
if (from == from_end)
|
||||||
|
return;
|
||||||
|
|
||||||
// The codecvt length functions may not be implemented, and I don't really
|
// The codecvt length functions may not be implemented, and I don't really
|
||||||
// understand them either. Thus this code is just a guess; if it turns
|
// understand them either. Thus this code is just a guess; if it turns
|
||||||
@ -181,13 +182,16 @@ namespace boost { namespace filesystem { namespace path_traits {
|
|||||||
// dynamically allocate a buffer only if source is unusually large
|
// dynamically allocate a buffer only if source is unusually large
|
||||||
if (buf_size > default_codecvt_buf_size)
|
if (buf_size > default_codecvt_buf_size)
|
||||||
{
|
{
|
||||||
boost::scoped_array< char > buf(new char [buf_size]);
|
boost::scoped_array< char > buf(new char[buf_size]);
|
||||||
convert_aux(from, from_end, buf.get(), buf.get()+buf_size, to, cvt);
|
convert_aux(from, from_end, buf.get(), buf.get() + buf_size, to, cvt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf[default_codecvt_buf_size];
|
char buf[default_codecvt_buf_size];
|
||||||
convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
|
convert_aux(from, from_end, buf, buf + default_codecvt_buf_size, to, cvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}} // namespace boost::filesystem::path_traits
|
|
||||||
|
} // namespace path_traits
|
||||||
|
} // namespace filesystem
|
||||||
|
} // namespace boost
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
#define _INCLUDE_STDCSOURCE_199901
|
#define _INCLUDE_STDCSOURCE_199901
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) ||\
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) || \
|
||||||
defined(__CYGWIN__)
|
defined(__CYGWIN__)
|
||||||
// Define target Windows version macros before including any other headers
|
// Define target Windows version macros before including any other headers
|
||||||
#include <boost/winapi/config.hpp>
|
#include <boost/winapi/config.hpp>
|
||||||
|
@ -11,100 +11,79 @@
|
|||||||
|
|
||||||
#include "platform_config.hpp"
|
#include "platform_config.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
#include <cstring> // SGI MIPSpro compilers need this
|
#include <cstring> // SGI MIPSpro compilers need this
|
||||||
|
#include <string>
|
||||||
|
|
||||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||||
namespace std { using ::strerror; }
|
namespace std {
|
||||||
# endif
|
using ::strerror;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const char invalid_chars[] =
|
BOOST_CONSTEXPR_OR_CONST char invalid_chars[] =
|
||||||
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
|
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
|
||||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
|
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
|
||||||
"<>:\"/\\|";
|
"<>:\"/\\|";
|
||||||
// note that the terminating '\0' is part of the string - thus the size below
|
// note that the terminating '\0' is part of the string - thus the size below
|
||||||
// is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I
|
// is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I
|
||||||
const std::string windows_invalid_chars(invalid_chars, sizeof(invalid_chars));
|
const std::string windows_invalid_chars(invalid_chars, sizeof(invalid_chars));
|
||||||
|
|
||||||
const std::string valid_posix(
|
const std::string valid_posix(
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
// name_check functions ----------------------------------------------//
|
||||||
|
|
||||||
|
#ifdef BOOST_WINDOWS
|
||||||
|
BOOST_FILESYSTEM_DECL bool native(const std::string& name)
|
||||||
{
|
{
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
|
|
||||||
// name_check functions ----------------------------------------------//
|
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS
|
|
||||||
BOOST_FILESYSTEM_DECL bool native(const std::string & name)
|
|
||||||
{
|
|
||||||
return windows_name(name);
|
return windows_name(name);
|
||||||
}
|
}
|
||||||
# else
|
#else
|
||||||
BOOST_FILESYSTEM_DECL bool native(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool native(const std::string& name)
|
||||||
{
|
{
|
||||||
return !name.empty()
|
return !name.empty() && name[0] != ' ' && name.find('/') == std::string::npos;
|
||||||
&& name[0] != ' '
|
}
|
||||||
&& name.find('/') == std::string::npos;
|
#endif
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string& name)
|
||||||
{
|
{
|
||||||
return !name.empty()
|
return !name.empty() && name.find_first_not_of(valid_posix) == std::string::npos;
|
||||||
&& name.find_first_not_of(valid_posix) == std::string::npos;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL bool windows_name(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool windows_name(const std::string& name)
|
||||||
{
|
{
|
||||||
return !name.empty()
|
return !name.empty() && name[0] != ' ' && name.find_first_of(windows_invalid_chars) == std::string::npos && *(name.end() - 1) != ' ' && (*(name.end() - 1) != '.' || name.size() == 1 || name == "..");
|
||||||
&& name[0] != ' '
|
}
|
||||||
&& name.find_first_of(windows_invalid_chars) == std::string::npos
|
|
||||||
&& *(name.end()-1) != ' '
|
|
||||||
&& (*(name.end()-1) != '.'
|
|
||||||
|| name.size() == 1 || name == "..");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL bool portable_name(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool portable_name(const std::string& name)
|
||||||
{
|
{
|
||||||
return !name.empty()
|
return !name.empty() && (name == "." || name == ".." || (windows_name(name) && portable_posix_name(name) && name[0] != '.' && name[0] != '-'));
|
||||||
&& (name == "."
|
}
|
||||||
|| name == ".."
|
|
||||||
|| (windows_name(name)
|
|
||||||
&& portable_posix_name(name)
|
|
||||||
&& name[0] != '.' && name[0] != '-'));
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string& name)
|
||||||
{
|
{
|
||||||
return
|
return name == "." || name == ".." || (portable_name(name) && name.find('.') == std::string::npos);
|
||||||
name == "."
|
}
|
||||||
|| name == ".."
|
|
||||||
|| (portable_name(name)
|
|
||||||
&& name.find('.') == std::string::npos);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string & name)
|
BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string& name)
|
||||||
{
|
{
|
||||||
std::string::size_type pos;
|
std::string::size_type pos;
|
||||||
return
|
return portable_name(name) && name != "." && name != ".." && ((pos = name.find('.')) == std::string::npos || (name.find('.', pos + 1) == std::string::npos && (pos + 5) > name.size()));
|
||||||
portable_name(name)
|
}
|
||||||
&& name != "."
|
|
||||||
&& name != ".."
|
|
||||||
&& ((pos = name.find('.')) == std::string::npos
|
|
||||||
|| (name.find('.', pos+1) == std::string::npos
|
|
||||||
&& (pos + 5) > name.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -17,62 +17,73 @@
|
|||||||
#include <boost/predef/os/bsd/free.h>
|
#include <boost/predef/os/bsd/free.h>
|
||||||
|
|
||||||
#ifdef BOOST_POSIX_API
|
#ifdef BOOST_POSIX_API
|
||||||
# include <cerrno>
|
|
||||||
# include <stddef.h>
|
#include <cerrno>
|
||||||
# include <fcntl.h>
|
#include <stddef.h>
|
||||||
# ifdef BOOST_HAS_UNISTD_H
|
#include <fcntl.h>
|
||||||
# include <unistd.h>
|
#ifdef BOOST_HAS_UNISTD_H
|
||||||
# endif
|
#include <unistd.h>
|
||||||
# if BOOST_OS_BSD_OPEN >= BOOST_VERSION_NUMBER(2, 1, 0) || BOOST_OS_BSD_FREE >= BOOST_VERSION_NUMBER(8, 0, 0) || BOOST_LIB_C_CLOUDABI
|
|
||||||
# include <stdlib.h>
|
|
||||||
# define BOOST_FILESYSTEM_HAS_ARC4RANDOM
|
|
||||||
# endif
|
|
||||||
# if (defined(__linux__) || defined(__linux) || defined(linux)) && (!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
|
||||||
# include <sys/syscall.h>
|
|
||||||
# if defined(SYS_getrandom)
|
|
||||||
# define BOOST_FILESYSTEM_HAS_SYS_GETRANDOM
|
|
||||||
# endif // defined(SYS_getrandom)
|
|
||||||
# if defined(__has_include)
|
|
||||||
# if __has_include(<sys/random.h>)
|
|
||||||
# define BOOST_FILESYSTEM_HAS_GETRANDOM
|
|
||||||
# endif
|
|
||||||
# elif defined(__GLIBC__)
|
|
||||||
# if __GLIBC_PREREQ(2, 25)
|
|
||||||
# define BOOST_FILESYSTEM_HAS_GETRANDOM
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if defined(BOOST_FILESYSTEM_HAS_GETRANDOM)
|
|
||||||
# include <sys/random.h>
|
|
||||||
# endif
|
|
||||||
# endif // (defined(__linux__) || defined(__linux) || defined(linux)) && (!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
|
||||||
#else // BOOST_WINDOWS_API
|
|
||||||
// We use auto-linking below to help users of static builds of Boost.Filesystem to link to whatever Windows SDK library we selected.
|
|
||||||
// The dependency information is currently not exposed in CMake config files generated by Boost.Build (https://github.com/boostorg/boost_install/issues/18),
|
|
||||||
// which makes it non-trivial for users to discover the libraries they need. This feature is deprecated and may be removed in the future,
|
|
||||||
// when the situation with CMake config files improves.
|
|
||||||
// Note that the library build system is the principal source of linking the library, which must work regardless of auto-linking.
|
|
||||||
# include <boost/predef/platform.h>
|
|
||||||
# include <boost/winapi/basic_types.hpp>
|
|
||||||
# if defined(BOOST_FILESYSTEM_HAS_BCRYPT) // defined on the command line by the project
|
|
||||||
# include <boost/winapi/error_codes.hpp>
|
|
||||||
# include <boost/winapi/bcrypt.hpp>
|
|
||||||
# if !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
|
||||||
# pragma comment(lib, "bcrypt.lib")
|
|
||||||
# endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
|
||||||
# else // defined(BOOST_FILESYSTEM_HAS_BCRYPT)
|
|
||||||
# include <boost/winapi/crypt.hpp>
|
|
||||||
# include <boost/winapi/get_last_error.hpp>
|
|
||||||
# if !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
|
||||||
# if !defined(_WIN32_WCE)
|
|
||||||
# pragma comment(lib, "advapi32.lib")
|
|
||||||
# else
|
|
||||||
# pragma comment(lib, "coredll.lib")
|
|
||||||
# endif
|
|
||||||
# endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
|
||||||
# endif // defined(BOOST_FILESYSTEM_HAS_BCRYPT)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_OS_BSD_OPEN >= BOOST_VERSION_NUMBER(2, 1, 0) || \
|
||||||
|
BOOST_OS_BSD_FREE >= BOOST_VERSION_NUMBER(8, 0, 0) || \
|
||||||
|
BOOST_LIB_C_CLOUDABI
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define BOOST_FILESYSTEM_HAS_ARC4RANDOM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__linux__) || defined(__linux) || defined(linux)) && \
|
||||||
|
(!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#if defined(SYS_getrandom)
|
||||||
|
#define BOOST_FILESYSTEM_HAS_SYS_GETRANDOM
|
||||||
|
#endif // defined(SYS_getrandom)
|
||||||
|
#if defined(__has_include)
|
||||||
|
#if __has_include(<sys/random.h>)
|
||||||
|
#define BOOST_FILESYSTEM_HAS_GETRANDOM
|
||||||
|
#endif
|
||||||
|
#elif defined(__GLIBC__)
|
||||||
|
#if __GLIBC_PREREQ(2, 25)
|
||||||
|
#define BOOST_FILESYSTEM_HAS_GETRANDOM
|
||||||
|
#endif
|
||||||
|
#endif // BOOST_FILESYSTEM_HAS_GETRANDOM definition
|
||||||
|
#if defined(BOOST_FILESYSTEM_HAS_GETRANDOM)
|
||||||
|
#include <sys/random.h>
|
||||||
|
#endif
|
||||||
|
#endif // (defined(__linux__) || defined(__linux) || defined(linux)) && (!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
||||||
|
|
||||||
|
#else // BOOST_WINDOWS_API
|
||||||
|
|
||||||
|
// We use auto-linking below to help users of static builds of Boost.Filesystem to link to whatever Windows SDK library we selected.
|
||||||
|
// The dependency information is currently not exposed in CMake config files generated by Boost.Build (https://github.com/boostorg/boost_install/issues/18),
|
||||||
|
// which makes it non-trivial for users to discover the libraries they need. This feature is deprecated and may be removed in the future,
|
||||||
|
// when the situation with CMake config files improves.
|
||||||
|
// Note that the library build system is the principal source of linking the library, which must work regardless of auto-linking.
|
||||||
|
#include <boost/predef/platform.h>
|
||||||
|
#include <boost/winapi/basic_types.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_FILESYSTEM_HAS_BCRYPT) // defined on the command line by the project
|
||||||
|
#include <boost/winapi/error_codes.hpp>
|
||||||
|
#include <boost/winapi/bcrypt.hpp>
|
||||||
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
||||||
|
#pragma comment(lib, "bcrypt.lib")
|
||||||
|
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
||||||
|
#else // defined(BOOST_FILESYSTEM_HAS_BCRYPT)
|
||||||
|
#include <boost/winapi/crypt.hpp>
|
||||||
|
#include <boost/winapi/get_last_error.hpp>
|
||||||
|
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
||||||
|
#if !defined(_WIN32_WCE)
|
||||||
|
#pragma comment(lib, "advapi32.lib")
|
||||||
|
#else
|
||||||
|
#pragma comment(lib, "coredll.lib")
|
||||||
|
#endif
|
||||||
|
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
||||||
|
#endif // defined(BOOST_FILESYSTEM_HAS_BCRYPT)
|
||||||
|
|
||||||
|
#endif // BOOST_POSIX_API
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include "error_handling.hpp"
|
#include "error_handling.hpp"
|
||||||
|
|
||||||
@ -83,7 +94,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif // defined(BOOST_POSIX_API)
|
#endif // defined(BOOST_POSIX_API)
|
||||||
|
|
||||||
namespace boost { namespace filesystem { namespace detail {
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -132,7 +145,7 @@ void system_crypt_random(void* buf, std::size_t len, boost::system::error_code*
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes_read += n;
|
bytes_read += n;
|
||||||
buf = static_cast<char*>(buf) + n;
|
buf = static_cast< char* >(buf) + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(BOOST_FILESYSTEM_HAS_ARC4RANDOM)
|
#elif defined(BOOST_FILESYSTEM_HAS_ARC4RANDOM)
|
||||||
@ -166,7 +179,7 @@ void system_crypt_random(void* buf, std::size_t len, boost::system::error_code*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bytes_read += n;
|
bytes_read += n;
|
||||||
buf = static_cast<char*>(buf) + n;
|
buf = static_cast< char* >(buf) + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(file);
|
close(file);
|
||||||
@ -186,7 +199,7 @@ void system_crypt_random(void* buf, std::size_t len, boost::system::error_code*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = boost::winapi::BCryptGenRandom(handle, static_cast<boost::winapi::PUCHAR_>(buf), static_cast<boost::winapi::ULONG_>(len), 0);
|
status = boost::winapi::BCryptGenRandom(handle, static_cast< boost::winapi::PUCHAR_ >(buf), static_cast< boost::winapi::ULONG_ >(len), 0);
|
||||||
|
|
||||||
boost::winapi::BCryptCloseAlgorithmProvider(handle, 0);
|
boost::winapi::BCryptCloseAlgorithmProvider(handle, 0);
|
||||||
|
|
||||||
@ -206,7 +219,7 @@ void system_crypt_random(void* buf, std::size_t len, boost::system::error_code*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::winapi::BOOL_ gen_ok = boost::winapi::CryptGenRandom(handle, static_cast<boost::winapi::DWORD_>(len), static_cast<boost::winapi::BYTE_*>(buf));
|
boost::winapi::BOOL_ gen_ok = boost::winapi::CryptGenRandom(handle, static_cast< boost::winapi::DWORD_ >(len), static_cast< boost::winapi::BYTE_* >(buf));
|
||||||
|
|
||||||
if (BOOST_UNLIKELY(!gen_ok))
|
if (BOOST_UNLIKELY(!gen_ok))
|
||||||
err = boost::winapi::GetLastError();
|
err = boost::winapi::GetLastError();
|
||||||
@ -240,7 +253,7 @@ path unique_path(const path& model, system::error_code* ec)
|
|||||||
// bytes and 40-7F as trailing bytes, whereas % is 25.
|
// bytes and 40-7F as trailing bytes, whereas % is 25.
|
||||||
// So, use string on POSIX and avoid conversions.
|
// So, use string on POSIX and avoid conversions.
|
||||||
|
|
||||||
path::string_type s( model.native() );
|
path::string_type s(model.native());
|
||||||
|
|
||||||
char ran[16] = {}; // init to avoid clang static analyzer message
|
char ran[16] = {}; // init to avoid clang static analyzer message
|
||||||
// see ticket #8954
|
// see ticket #8954
|
||||||
@ -264,9 +277,12 @@ path unique_path(const path& model, system::error_code* ec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec != 0) ec->clear();
|
if (ec != 0)
|
||||||
|
ec->clear();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}}}
|
} // namespace detail
|
||||||
|
} // namespace filesystem
|
||||||
|
} // namespace boost
|
||||||
|
@ -5,10 +5,17 @@
|
|||||||
|
|
||||||
#include "platform_config.hpp"
|
#include "platform_config.hpp"
|
||||||
|
|
||||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
#include <boost/filesystem/config.hpp>
|
||||||
namespace boost { namespace filesystem { namespace detail {
|
|
||||||
|
|
||||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||||
|
namespace boost { \
|
||||||
|
namespace filesystem { \
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
#define BOOST_UTF8_END_NAMESPACE \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
||||||
|
|
||||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||||
|
@ -20,15 +20,14 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
std::codecvt_base::result windows_file_codecvt::do_in(
|
std::codecvt_base::result windows_file_codecvt::do_in(
|
||||||
std::mbstate_t &,
|
std::mbstate_t&,
|
||||||
const char* from, const char* from_end, const char*& from_next,
|
const char* from, const char* from_end, const char*& from_next,
|
||||||
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
|
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
|
||||||
{
|
{
|
||||||
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
|
if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from, static_cast< int >(from_end - from), to, static_cast< int >(to_end - to))) == 0)
|
||||||
static_cast<int>(from_end - from), to, static_cast<int>(to_end - to))) == 0)
|
|
||||||
{
|
{
|
||||||
return error; // conversion failed
|
return error; // conversion failed
|
||||||
}
|
}
|
||||||
@ -40,15 +39,14 @@ std::codecvt_base::result windows_file_codecvt::do_in(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::codecvt_base::result windows_file_codecvt::do_out(
|
std::codecvt_base::result windows_file_codecvt::do_out(
|
||||||
std::mbstate_t &,
|
std::mbstate_t&,
|
||||||
const wchar_t* from, const wchar_t* from_end, const wchar_t* & from_next,
|
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||||
char* to, char* to_end, char* & to_next) const
|
char* to, char* to_end, char*& to_next) const
|
||||||
{
|
{
|
||||||
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from,
|
if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from, static_cast< int >(from_end - from), to, static_cast< int >(to_end - to), 0, 0)) == 0)
|
||||||
static_cast<int>(from_end - from), to, static_cast<int>(to_end - to), 0, 0)) == 0)
|
|
||||||
{
|
{
|
||||||
return error; // conversion failed
|
return error; // conversion failed
|
||||||
}
|
}
|
||||||
|
@ -23,35 +23,26 @@
|
|||||||
// //
|
// //
|
||||||
//------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
class BOOST_SYMBOL_VISIBLE windows_file_codecvt
|
class BOOST_SYMBOL_VISIBLE windows_file_codecvt :
|
||||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit windows_file_codecvt(std::size_t refs = 0)
|
explicit windows_file_codecvt(std::size_t refs = 0) :
|
||||||
: std::codecvt<wchar_t, char, std::mbstate_t>(refs) {}
|
std::codecvt< wchar_t, char, std::mbstate_t >(refs)
|
||||||
protected:
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual bool do_always_noconv() const throw() { return false; }
|
virtual bool do_always_noconv() const throw() { return false; }
|
||||||
|
|
||||||
// seems safest to assume variable number of characters since we don't
|
// seems safest to assume variable number of characters since we don't
|
||||||
// actually know what codepage is active
|
// actually know what codepage is active
|
||||||
virtual int do_encoding() const throw() { return 0; }
|
virtual int do_encoding() const throw() { return 0; }
|
||||||
|
virtual std::codecvt_base::result do_in(std::mbstate_t& state, const char* from, const char* from_end, const char*& from_next, wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const;
|
||||||
virtual std::codecvt_base::result do_in(std::mbstate_t& state,
|
virtual std::codecvt_base::result do_out(std::mbstate_t& state, const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next, char* to, char* to_end, char*& to_next) const;
|
||||||
const char* from, const char* from_end, const char*& from_next,
|
virtual std::codecvt_base::result do_unshift(std::mbstate_t&, char* /*from*/, char* /*to*/, char*& /*next*/) const { return ok; }
|
||||||
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const;
|
virtual int do_length(std::mbstate_t&, const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; }
|
||||||
|
virtual int do_max_length() const throw() { return 0; }
|
||||||
virtual std::codecvt_base::result do_out(std::mbstate_t & state,
|
|
||||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
|
||||||
char* to, char* to_end, char*& to_next) const;
|
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_unshift(std::mbstate_t&,
|
|
||||||
char* /*from*/, char* /*to*/, char* & /*next*/) const { return ok; }
|
|
||||||
|
|
||||||
virtual int do_length(std::mbstate_t&,
|
|
||||||
const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; }
|
|
||||||
|
|
||||||
virtual int do_max_length() const throw () { return 0; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP
|
#endif // BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP
|
||||||
|
@ -24,8 +24,7 @@ namespace detail {
|
|||||||
|
|
||||||
inline bool equal_extension(wchar_t const* p, wchar_t const (&x1)[5], wchar_t const (&x2)[5])
|
inline bool equal_extension(wchar_t const* p, wchar_t const (&x1)[5], wchar_t const (&x2)[5])
|
||||||
{
|
{
|
||||||
return
|
return (p[0] == x1[0] || p[0] == x2[0]) &&
|
||||||
(p[0] == x1[0] || p[0] == x2[0]) &&
|
|
||||||
(p[1] == x1[1] || p[1] == x2[1]) &&
|
(p[1] == x1[1] || p[1] == x2[1]) &&
|
||||||
(p[2] == x1[2] || p[2] == x2[2]) &&
|
(p[2] == x1[2] || p[2] == x2[2]) &&
|
||||||
(p[3] == x1[3] || p[3] == x2[3]) &&
|
(p[3] == x1[3] || p[3] == x2[3]) &&
|
||||||
@ -39,10 +38,7 @@ inline boost::filesystem::perms make_permissions(const boost::filesystem::path&
|
|||||||
prms |= boost::filesystem::owner_write | boost::filesystem::group_write | boost::filesystem::others_write;
|
prms |= boost::filesystem::owner_write | boost::filesystem::group_write | boost::filesystem::others_write;
|
||||||
boost::filesystem::path ext = p.extension();
|
boost::filesystem::path ext = p.extension();
|
||||||
wchar_t const* q = ext.c_str();
|
wchar_t const* q = ext.c_str();
|
||||||
if (equal_extension(q, L".exe", L".EXE")
|
if (equal_extension(q, L".exe", L".EXE") || equal_extension(q, L".com", L".COM") || equal_extension(q, L".bat", L".BAT") || equal_extension(q, L".cmd", L".CMD"))
|
||||||
|| equal_extension(q, L".com", L".COM")
|
|
||||||
|| equal_extension(q, L".bat", L".BAT")
|
|
||||||
|| equal_extension(q, L".cmd", L".CMD"))
|
|
||||||
prms |= boost::filesystem::owner_exe | boost::filesystem::group_exe | boost::filesystem::others_exe;
|
prms |= boost::filesystem::owner_exe | boost::filesystem::group_exe | boost::filesystem::others_exe;
|
||||||
return prms;
|
return prms;
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
cout << "Verify macro reporting works correctly\n";
|
cout << "Verify macro reporting works correctly\n";
|
||||||
cout << " NOSUCHMACRO: " << BOOST_MACRO_VALUE(NOSUCHMACRO) << endl;
|
cout << " NOSUCHMACRO: " << BOOST_MACRO_VALUE(NOSUCHMACRO) << endl;
|
||||||
# define SUCHAMACRO
|
#define SUCHAMACRO
|
||||||
cout << " SUCHAMACRO: " << BOOST_MACRO_VALUE(SUCHAMACRO) << endl;
|
cout << " SUCHAMACRO: " << BOOST_MACRO_VALUE(SUCHAMACRO) << endl;
|
||||||
cout << " BOOST_VERSION: " << BOOST_MACRO_VALUE(BOOST_VERSION) << endl;
|
cout << " BOOST_VERSION: " << BOOST_MACRO_VALUE(BOOST_VERSION) << endl;
|
||||||
|
|
||||||
@ -47,6 +46,5 @@ int main()
|
|||||||
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
||||||
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/convenience.hpp>
|
#include <boost/filesystem/convenience.hpp>
|
||||||
@ -23,9 +23,9 @@
|
|||||||
#include <boost/filesystem/exception.hpp>
|
#include <boost/filesystem/exception.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
@ -37,32 +37,34 @@ namespace fs = boost::filesystem;
|
|||||||
using fs::path;
|
using fs::path;
|
||||||
namespace sys = boost::system;
|
namespace sys = boost::system;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
template< typename F >
|
||||||
|
bool throws_fs_error(F func)
|
||||||
{
|
{
|
||||||
template< typename F >
|
try
|
||||||
bool throws_fs_error(F func)
|
|
||||||
{
|
{
|
||||||
try { func(); }
|
func();
|
||||||
|
}
|
||||||
|
|
||||||
catch (const fs::filesystem_error &)
|
catch (const fs::filesystem_error&)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
void create_recursive_iterator(const fs::path & ph)
|
|
||||||
{
|
|
||||||
fs::recursive_directory_iterator it(ph);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void create_recursive_iterator(const fs::path& ph)
|
||||||
|
{
|
||||||
|
fs::recursive_directory_iterator it(ph);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------//
|
// ------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
int cpp_main(int, char*[])
|
int cpp_main(int, char*[])
|
||||||
{
|
{
|
||||||
|
|
||||||
// create_directories() tests --------------------------------------------------------//
|
// create_directories() tests --------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_TEST(!fs::create_directories("/")); // should be harmless
|
BOOST_TEST(!fs::create_directories("/")); // should be harmless
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ int cpp_main(int, char*[])
|
|||||||
BOOST_TEST(throws_fs_error(
|
BOOST_TEST(throws_fs_error(
|
||||||
boost::bind(fs::create_directories, is_a_file / "aa")));
|
boost::bind(fs::create_directories, is_a_file / "aa")));
|
||||||
|
|
||||||
// recursive_directory_iterator tests ----------------------------------------//
|
// recursive_directory_iterator tests ----------------------------------------//
|
||||||
|
|
||||||
sys::error_code ec;
|
sys::error_code ec;
|
||||||
fs::recursive_directory_iterator it("/no-such-path", ec);
|
fs::recursive_directory_iterator it("/no-such-path", ec);
|
||||||
@ -117,7 +119,9 @@ int cpp_main(int, char*[])
|
|||||||
|
|
||||||
for (it = fs::recursive_directory_iterator(unique_dir);
|
for (it = fs::recursive_directory_iterator(unique_dir);
|
||||||
it != fs::recursive_directory_iterator(); ++it)
|
it != fs::recursive_directory_iterator(); ++it)
|
||||||
{ std::cout << it->path() << '\n'; }
|
{
|
||||||
|
std::cout << it->path() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
it = fs::recursive_directory_iterator(unique_dir);
|
it = fs::recursive_directory_iterator(unique_dir);
|
||||||
BOOST_TEST(it->path() == unique_yy);
|
BOOST_TEST(it->path() == unique_yy);
|
||||||
@ -169,8 +173,7 @@ int cpp_main(int, char*[])
|
|||||||
ec.clear();
|
ec.clear();
|
||||||
BOOST_TEST(!ec);
|
BOOST_TEST(!ec);
|
||||||
// check that two argument failed constructor creates the end iterator
|
// check that two argument failed constructor creates the end iterator
|
||||||
BOOST_TEST(fs::recursive_directory_iterator("nosuchdir", ec)
|
BOOST_TEST(fs::recursive_directory_iterator("nosuchdir", ec) == fs::recursive_directory_iterator());
|
||||||
== fs::recursive_directory_iterator());
|
|
||||||
BOOST_TEST(ec);
|
BOOST_TEST(ec);
|
||||||
|
|
||||||
fs::remove_all(unique_dir); // clean up behind ourselves
|
fs::remove_all(unique_dir); // clean up behind ourselves
|
||||||
|
@ -25,11 +25,10 @@
|
|||||||
|
|
||||||
// on Windows, except for standard libaries known to have wchar_t overloads for
|
// on Windows, except for standard libaries known to have wchar_t overloads for
|
||||||
// file stream I/O, use path::string() to get a narrow character c_str()
|
// file stream I/O, use path::string() to get a narrow character c_str()
|
||||||
#if defined(BOOST_WINDOWS_API) \
|
#if defined(BOOST_WINDOWS_API) && (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405) // not Dinkumware || no wide overloads
|
||||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405) // not Dinkumware || no wide overloads
|
#define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
|
||||||
# define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
|
|
||||||
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
||||||
# define BOOST_FILESYSTEM_C_STR c_str()
|
#define BOOST_FILESYSTEM_C_STR c_str()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@ -88,7 +87,9 @@ directory_tree collect_directory_tree(fs::path const& root_dir)
|
|||||||
std::cout << "Collecting directory tree in: " << root_dir << '\n';
|
std::cout << "Collecting directory tree in: " << root_dir << '\n';
|
||||||
|
|
||||||
directory_tree tree;
|
directory_tree tree;
|
||||||
fs::recursive_directory_iterator it(root_dir, fs::directory_options::skip_permission_denied | fs::directory_options::follow_directory_symlink | fs::directory_options::skip_dangling_symlinks), end;
|
fs::recursive_directory_iterator it(root_dir, fs::directory_options::skip_permission_denied |
|
||||||
|
fs::directory_options::follow_directory_symlink | fs::directory_options::skip_dangling_symlinks);
|
||||||
|
fs::recursive_directory_iterator end;
|
||||||
while (it != end)
|
while (it != end)
|
||||||
{
|
{
|
||||||
fs::path p = fs::relative(it->path(), root_dir);
|
fs::path p = fs::relative(it->path(), root_dir);
|
||||||
@ -312,17 +313,18 @@ int main()
|
|||||||
{
|
{
|
||||||
fs::create_symlink("f1", root_dir / "s1");
|
fs::create_symlink("f1", root_dir / "s1");
|
||||||
symlinks_supported = true;
|
symlinks_supported = true;
|
||||||
std::cout <<
|
std::cout << " *** For information only ***\n"
|
||||||
" *** For information only ***\n"
|
" create_symlink() attempt succeeded"
|
||||||
" create_symlink() attempt succeeded" << std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
catch (fs::filesystem_error& e)
|
catch (fs::filesystem_error& e)
|
||||||
{
|
{
|
||||||
std::cout <<
|
std::cout << " *** For information only ***\n"
|
||||||
" *** For information only ***\n"
|
|
||||||
" create_symlink() attempt failed\n"
|
" create_symlink() attempt failed\n"
|
||||||
" filesystem_error.what() reports: " << e.what() << "\n"
|
" filesystem_error.what() reports: "
|
||||||
" create_symlink() may not be supported on this operating system or file system" << std::endl;
|
<< e.what() << "\n"
|
||||||
|
" create_symlink() may not be supported on this operating system or file system"
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symlinks_supported)
|
if (symlinks_supported)
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
@ -28,24 +28,23 @@ using boost::filesystem::path;
|
|||||||
|
|
||||||
#define PATH_CHECK(a, b) check(a, b, __LINE__)
|
#define PATH_CHECK(a, b) check(a, b, __LINE__)
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
std::string platform(BOOST_PLATFORM);
|
||||||
std::string platform(BOOST_PLATFORM);
|
|
||||||
|
|
||||||
void check(const fs::path & source,
|
void check(const fs::path& source, const std::string& expected, int line)
|
||||||
const std::string & expected, int line)
|
{
|
||||||
{
|
if (source.generic_string() == expected)
|
||||||
if (source.generic_string()== expected) return;
|
return;
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
std::cout << '(' << line << ") source.string(): \"" << source.string()
|
std::cout << '(' << line << ") source.string(): \"" << source.string()
|
||||||
<< "\" != expected: \"" << expected
|
<< "\" != expected: \"" << expected
|
||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void normalize_test()
|
void normalize_test()
|
||||||
{
|
{
|
||||||
PATH_CHECK(path("").normalize(), "");
|
PATH_CHECK(path("").normalize(), "");
|
||||||
PATH_CHECK(path("/").normalize(), "/");
|
PATH_CHECK(path("/").normalize(), "/");
|
||||||
PATH_CHECK(path("//").normalize(), "//");
|
PATH_CHECK(path("//").normalize(), "//");
|
||||||
@ -63,14 +62,14 @@ namespace
|
|||||||
PATH_CHECK(path("../foo").normalize(), "../foo");
|
PATH_CHECK(path("../foo").normalize(), "../foo");
|
||||||
PATH_CHECK(path("foo/..").normalize(), ".");
|
PATH_CHECK(path("foo/..").normalize(), ".");
|
||||||
PATH_CHECK(path("foo/../").normalize(), "./.");
|
PATH_CHECK(path("foo/../").normalize(), "./.");
|
||||||
PATH_CHECK((path("foo") / "..").normalize() , ".");
|
PATH_CHECK((path("foo") / "..").normalize(), ".");
|
||||||
PATH_CHECK(path("foo/...").normalize(), "foo/...");
|
PATH_CHECK(path("foo/...").normalize(), "foo/...");
|
||||||
PATH_CHECK(path("foo/.../").normalize(), "foo/.../.");
|
PATH_CHECK(path("foo/.../").normalize(), "foo/.../.");
|
||||||
PATH_CHECK(path("foo/..bar").normalize(), "foo/..bar");
|
PATH_CHECK(path("foo/..bar").normalize(), "foo/..bar");
|
||||||
PATH_CHECK(path("../f").normalize(), "../f");
|
PATH_CHECK(path("../f").normalize(), "../f");
|
||||||
PATH_CHECK(path("/../f").normalize(), "/../f");
|
PATH_CHECK(path("/../f").normalize(), "/../f");
|
||||||
PATH_CHECK(path("f/..").normalize(), ".");
|
PATH_CHECK(path("f/..").normalize(), ".");
|
||||||
PATH_CHECK((path("f") / "..").normalize() , ".");
|
PATH_CHECK((path("f") / "..").normalize(), ".");
|
||||||
PATH_CHECK(path("foo/../..").normalize(), "..");
|
PATH_CHECK(path("foo/../..").normalize(), "..");
|
||||||
PATH_CHECK(path("foo/../../").normalize(), "../.");
|
PATH_CHECK(path("foo/../../").normalize(), "../.");
|
||||||
PATH_CHECK(path("foo/../../..").normalize(), "../..");
|
PATH_CHECK(path("foo/../../..").normalize(), "../..");
|
||||||
@ -148,25 +147,25 @@ namespace
|
|||||||
PATH_CHECK(path("c:/../../foo/").normalize(), "../foo/.");
|
PATH_CHECK(path("c:/../../foo/").normalize(), "../foo/.");
|
||||||
PATH_CHECK(path("c:/..foo").normalize(), "c:/..foo");
|
PATH_CHECK(path("c:/..foo").normalize(), "c:/..foo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// misc_test ------------------------------------------------------------------------//
|
// misc_test ------------------------------------------------------------------------//
|
||||||
|
|
||||||
void misc_test()
|
void misc_test()
|
||||||
{
|
{
|
||||||
fs::path p;
|
fs::path p;
|
||||||
|
|
||||||
fs::initial_path<fs::path>();
|
fs::initial_path< fs::path >();
|
||||||
fs::initial_path<fs::wpath>();
|
fs::initial_path< fs::wpath >();
|
||||||
|
|
||||||
p.file_string();
|
p.file_string();
|
||||||
p.directory_string();
|
p.directory_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
// path_rename_test -----------------------------------------------------------------//
|
// path_rename_test -----------------------------------------------------------------//
|
||||||
|
|
||||||
void path_rename_test()
|
void path_rename_test()
|
||||||
{
|
{
|
||||||
fs::path p("foo/bar/blah");
|
fs::path p("foo/bar/blah");
|
||||||
|
|
||||||
BOOST_TEST_EQ(path("foo/bar/blah").remove_leaf(), "foo/bar");
|
BOOST_TEST_EQ(path("foo/bar/blah").remove_leaf(), "foo/bar");
|
||||||
@ -182,11 +181,10 @@ namespace
|
|||||||
p = "foo\\bar\\blah";
|
p = "foo\\bar\\blah";
|
||||||
BOOST_TEST_EQ(p.branch_path(), "foo\\bar");
|
BOOST_TEST_EQ(p.branch_path(), "foo\\bar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
int cpp_main(int /*argc*/, char* /*argv*/[])
|
int cpp_main(int /*argc*/, char* /*argv*/[])
|
||||||
@ -194,9 +192,7 @@ int cpp_main(int /*argc*/, char* /*argv*/[])
|
|||||||
// The choice of platform is make at runtime rather than compile-time
|
// The choice of platform is make at runtime rather than compile-time
|
||||||
// so that compile errors for all platforms will be detected even though
|
// so that compile errors for all platforms will be detected even though
|
||||||
// only the current platform is runtime tested.
|
// only the current platform is runtime tested.
|
||||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
|
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||||
? "Windows"
|
|
||||||
: "POSIX";
|
|
||||||
std::cout << "Platform is " << platform << '\n';
|
std::cout << "Platform is " << platform << '\n';
|
||||||
|
|
||||||
BOOST_TEST(fs::initial_path() == fs::current_path());
|
BOOST_TEST(fs::initial_path() == fs::current_path());
|
||||||
@ -219,7 +215,7 @@ int cpp_main(int /*argc*/, char* /*argv*/[])
|
|||||||
normalize_test();
|
normalize_test();
|
||||||
BOOST_TEST(fs::path("foo/bar").generic() == fs::path("foo/bar"));
|
BOOST_TEST(fs::path("foo/bar").generic() == fs::path("foo/bar"));
|
||||||
|
|
||||||
// extension() tests ---------------------------------------------------------//
|
// extension() tests ---------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_TEST(fs::extension("a/b") == "");
|
BOOST_TEST(fs::extension("a/b") == "");
|
||||||
BOOST_TEST(fs::extension("a/b.txt") == ".txt");
|
BOOST_TEST(fs::extension("a/b.txt") == ".txt");
|
||||||
@ -229,7 +225,7 @@ int cpp_main(int /*argc*/, char* /*argv*/[])
|
|||||||
BOOST_TEST(fs::extension("") == "");
|
BOOST_TEST(fs::extension("") == "");
|
||||||
BOOST_TEST(fs::extension("a/") == "");
|
BOOST_TEST(fs::extension("a/") == "");
|
||||||
|
|
||||||
// basename() tests ----------------------------------------------------------//
|
// basename() tests ----------------------------------------------------------//
|
||||||
|
|
||||||
BOOST_TEST(fs::basename("b") == "b");
|
BOOST_TEST(fs::basename("b") == "b");
|
||||||
BOOST_TEST(fs::basename("a/b.txt") == "b");
|
BOOST_TEST(fs::basename("a/b.txt") == "b");
|
||||||
@ -238,7 +234,7 @@ int cpp_main(int /*argc*/, char* /*argv*/[])
|
|||||||
BOOST_TEST(fs::basename("a.b.c.") == "a.b.c");
|
BOOST_TEST(fs::basename("a.b.c.") == "a.b.c");
|
||||||
BOOST_TEST(fs::basename("") == "");
|
BOOST_TEST(fs::basename("") == "");
|
||||||
|
|
||||||
// change_extension tests ---------------------------------------------------//
|
// change_extension tests ---------------------------------------------------//
|
||||||
|
|
||||||
BOOST_TEST(fs::change_extension("a.txt", ".tex").string() == "a.tex");
|
BOOST_TEST(fs::change_extension("a.txt", ".tex").string() == "a.tex");
|
||||||
BOOST_TEST(fs::change_extension("a.", ".tex").string() == "a.tex");
|
BOOST_TEST(fs::change_extension("a.", ".tex").string() == "a.tex");
|
||||||
|
@ -6,21 +6,21 @@
|
|||||||
class path
|
class path
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
path( const char * )
|
path(const char*)
|
||||||
{
|
{
|
||||||
std::cout << "path( const char * )\n";
|
std::cout << "path( const char * )\n";
|
||||||
}
|
}
|
||||||
path( const std::string & )
|
path(const std::string&)
|
||||||
{
|
{
|
||||||
std::cout << "path( std::string & )\n";
|
std::cout << "path( std::string & )\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// for maximum efficiency, either signature must work
|
// for maximum efficiency, either signature must work
|
||||||
# ifdef BY_VALUE
|
#ifdef BY_VALUE
|
||||||
operator const std::string() const
|
operator const std::string() const
|
||||||
# else
|
#else
|
||||||
operator const std::string&() const
|
operator const std::string&() const
|
||||||
# endif
|
#endif
|
||||||
{
|
{
|
||||||
std::cout << "operator string\n";
|
std::cout << "operator string\n";
|
||||||
return m_path;
|
return m_path;
|
||||||
@ -38,7 +38,7 @@ private:
|
|||||||
std::string m_path;
|
std::string m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==( const path &, const path & )
|
bool operator==(const path&, const path&)
|
||||||
{
|
{
|
||||||
std::cout << "operator==( const path &, const path & )\n";
|
std::cout << "operator==( const path &, const path & )\n";
|
||||||
return true;
|
return true;
|
||||||
@ -47,35 +47,35 @@ bool operator==( const path &, const path & )
|
|||||||
// These are the critical use cases. If any of these don't compile, usability
|
// These are the critical use cases. If any of these don't compile, usability
|
||||||
// is unacceptably degraded.
|
// is unacceptably degraded.
|
||||||
|
|
||||||
void f( const path & )
|
void f(const path&)
|
||||||
{
|
{
|
||||||
std::cout << "f( const path & )\n";
|
std::cout << "f( const path & )\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
f( "foo" );
|
f("foo");
|
||||||
f( std::string( "foo" ) );
|
f(std::string("foo"));
|
||||||
f( path( "foo" ) );
|
f(path("foo"));
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
|
|
||||||
std::string s1( path( "foo" ) );
|
std::string s1(path("foo"));
|
||||||
std::string s2 = path( "foo" );
|
std::string s2 = path("foo");
|
||||||
s2 = path( "foo" );
|
s2 = path("foo");
|
||||||
|
|
||||||
#ifdef NAMED_CONVERSION
|
#ifdef NAMED_CONVERSION
|
||||||
s2 = path( "foo" ).string();
|
s2 = path("foo").string();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
|
|
||||||
// these must call bool path( const path &, const path & );
|
// these must call bool path( const path &, const path & );
|
||||||
path( "foo" ) == path( "foo" );
|
path("foo") == path("foo");
|
||||||
path( "foo" ) == "foo";
|
path("foo") == "foo";
|
||||||
path( "foo" ) == std::string( "foo" );
|
path("foo") == std::string("foo");
|
||||||
"foo" == path( "foo" );
|
"foo" == path("foo");
|
||||||
std::string( "foo" ) == path( "foo" );
|
std::string("foo") == path("foo");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
int main( int argc, char * argv[] )
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
boost::filesystem::path::default_name_check( boost::filesystem::native );
|
boost::filesystem::path::default_name_check(boost::filesystem::native);
|
||||||
if ( argc != 3 )
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
std::cout << "Usage: equivalent path1 path2\n";
|
std::cout << "Usage: equivalent path1 path2\n";
|
||||||
return 2;
|
return 2;
|
||||||
@ -26,9 +26,9 @@ int main( int argc, char * argv[] )
|
|||||||
bool eq;
|
bool eq;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
eq = boost::filesystem::equivalent( argv[1], argv[2] );
|
eq = boost::filesystem::equivalent(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
catch ( const std::exception & ex )
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
std::cout << ex.what() << "\n";
|
std::cout << ex.what() << "\n";
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -19,7 +19,7 @@ int main()
|
|||||||
{
|
{
|
||||||
fs::directory_iterator const it;
|
fs::directory_iterator const it;
|
||||||
|
|
||||||
BOOST_FOREACH( fs::path const& p, it )
|
BOOST_FOREACH(fs::path const& p, it)
|
||||||
{
|
{
|
||||||
p.string();
|
p.string();
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ int main()
|
|||||||
{
|
{
|
||||||
fs::directory_iterator const it;
|
fs::directory_iterator const it;
|
||||||
|
|
||||||
for( fs::path const& p: it )
|
for (fs::path const& p : it)
|
||||||
{
|
{
|
||||||
p.string();
|
p.string();
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ int main()
|
|||||||
{
|
{
|
||||||
fs::recursive_directory_iterator it;
|
fs::recursive_directory_iterator it;
|
||||||
|
|
||||||
BOOST_FOREACH( fs::path const& p, it )
|
BOOST_FOREACH(fs::path const& p, it)
|
||||||
{
|
{
|
||||||
p.string();
|
p.string();
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ int main()
|
|||||||
{
|
{
|
||||||
fs::recursive_directory_iterator const it;
|
fs::recursive_directory_iterator const it;
|
||||||
|
|
||||||
for( fs::path const& p: it )
|
for (fs::path const& p : it)
|
||||||
{
|
{
|
||||||
p.string();
|
p.string();
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,18 @@
|
|||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -35,18 +35,19 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||||
namespace std { using ::remove; }
|
namespace std {
|
||||||
|
using ::remove;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
bool cleanup = true;
|
||||||
bool cleanup = true;
|
|
||||||
|
|
||||||
void test(const fs::path & p)
|
void test(const fs::path& p)
|
||||||
{
|
{
|
||||||
fs::remove(p);
|
fs::remove(p);
|
||||||
{
|
{
|
||||||
std::cout << " in test 1\n";
|
std::cout << " in test 1\n";
|
||||||
@ -116,7 +117,7 @@ namespace
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::cout << " in test 13\n";
|
std::cout << " in test 13\n";
|
||||||
fs::fstream tfs(p, std::ios_base::in|std::ios_base::out);
|
fs::fstream tfs(p, std::ios_base::in | std::ios_base::out);
|
||||||
BOOST_TEST(tfs.is_open());
|
BOOST_TEST(tfs.is_open());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -128,19 +129,20 @@ namespace
|
|||||||
{
|
{
|
||||||
std::cout << " in test 15\n";
|
std::cout << " in test 15\n";
|
||||||
fs::fstream tfs;
|
fs::fstream tfs;
|
||||||
tfs.open(p, std::ios_base::in|std::ios_base::out);
|
tfs.open(p, std::ios_base::in | std::ios_base::out);
|
||||||
BOOST_TEST(tfs.is_open());
|
BOOST_TEST(tfs.is_open());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanup)
|
if (cleanup)
|
||||||
fs::remove(p);
|
fs::remove(p);
|
||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
int cpp_main(int argc, char*[])
|
int cpp_main(int argc, char*[])
|
||||||
{
|
{
|
||||||
if (argc > 1) cleanup = false;
|
if (argc > 1)
|
||||||
|
cleanup = false;
|
||||||
|
|
||||||
std::cout << "BOOST_FILESYSTEM_C_STR defined as \""
|
std::cout << "BOOST_FILESYSTEM_C_STR defined as \""
|
||||||
<< BOOST_STRINGIZE(BOOST_FILESYSTEM_C_STR) << "\"\n";
|
<< BOOST_STRINGIZE(BOOST_FILESYSTEM_C_STR) << "\"\n";
|
||||||
@ -149,7 +151,6 @@ int cpp_main(int argc, char*[])
|
|||||||
std::cout << "narrow character tests:\n";
|
std::cout << "narrow character tests:\n";
|
||||||
test("narrow_fstream_test");
|
test("narrow_fstream_test");
|
||||||
|
|
||||||
|
|
||||||
// So that tests are run with known encoding, use Boost UTF-8 codecvt
|
// So that tests are run with known encoding, use Boost UTF-8 codecvt
|
||||||
std::locale global_loc = std::locale();
|
std::locale global_loc = std::locale();
|
||||||
std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
|
std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
|
||||||
|
@ -5,4 +5,3 @@ int main(void)
|
|||||||
boost::filesystem::copy_file("a", "b");
|
boost::filesystem::copy_file("a", "b");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,12 @@ int main(int argc, char** argv)
|
|||||||
cout << "current path is " << my_path << endl;
|
cout << "current path is " << my_path << endl;
|
||||||
cout << "parent path is " << my_path.parent_path() << endl;
|
cout << "parent path is " << my_path.parent_path() << endl;
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch (std::exception& e)
|
||||||
cerr << endl << "Error during execution: " << e.what() << endl << endl;
|
{
|
||||||
|
cerr << endl
|
||||||
|
<< "Error during execution: " << e.what() << endl
|
||||||
|
<< endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ boost::mutex mut;
|
|||||||
#define FNAME ("remove-test")
|
#define FNAME ("remove-test")
|
||||||
void remover()
|
void remover()
|
||||||
{
|
{
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
boost::filesystem::remove(FNAME);
|
boost::filesystem::remove(FNAME);
|
||||||
}
|
}
|
||||||
@ -16,7 +16,8 @@ void remover()
|
|||||||
|
|
||||||
void creater()
|
void creater()
|
||||||
{
|
{
|
||||||
for(int i=0; i<100000; i++) std::fstream(FNAME, std::fstream::out);
|
for (int i = 0; i < 100000; i++)
|
||||||
|
std::fstream(FNAME, std::fstream::out);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -24,15 +25,16 @@ int main()
|
|||||||
boost::filesystem::remove(FNAME);
|
boost::filesystem::remove(FNAME);
|
||||||
boost::filesystem::remove(FNAME);
|
boost::filesystem::remove(FNAME);
|
||||||
|
|
||||||
std::cout <<
|
std::cout << "If you got this far, it's OK to remove a file that doesn't exist\n"
|
||||||
"If you got this far, it's OK to remove a file that doesn't exist\n"
|
|
||||||
"Now trying with one creator thread and two remover threads.\n"
|
"Now trying with one creator thread and two remover threads.\n"
|
||||||
"This is likely to crash after just a few seconds at most." <<
|
"This is likely to crash after just a few seconds at most."
|
||||||
std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
boost::thread c(creater), r1(remover), r2(remover);
|
boost::thread c(creater), r1(remover), r2(remover);
|
||||||
|
|
||||||
c.join();
|
c.join();
|
||||||
r1.interrupt(); r1.join();
|
r1.interrupt();
|
||||||
r2.interrupt(); r2.join();
|
r1.join();
|
||||||
|
r2.interrupt();
|
||||||
|
r2.join();
|
||||||
}
|
}
|
||||||
|
@ -8,18 +8,17 @@
|
|||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
using namespace boost::adaptors;
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
fs::recursive_directory_iterator beg("."), end;
|
fs::recursive_directory_iterator beg("."), end;
|
||||||
|
|
||||||
auto fileFilter = [](fs::path const & path)
|
auto fileFilter = [](fs::path const& path) {
|
||||||
{
|
|
||||||
return is_regular_file(path);
|
return is_regular_file(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<fs::path> paths;
|
std::vector< fs::path > paths;
|
||||||
copy(boost::make_iterator_range(beg, end) | filtered(fileFilter),
|
copy(boost::make_iterator_range(beg, end) | filtered(fileFilter), std::back_inserter(paths));
|
||||||
std::back_inserter(paths));
|
|
||||||
|
|
||||||
for(auto& p : paths)
|
for (auto& p : paths)
|
||||||
std::cout << p << "\n";
|
std::cout << p << "\n";
|
||||||
}
|
}
|
@ -6,20 +6,20 @@
|
|||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
int main(void) {
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
std::locale global_loc = std::locale();
|
std::locale global_loc = std::locale();
|
||||||
std::locale loc(global_loc, new stdext::cvt::codecvt_cp950<wchar_t>);
|
std::locale loc(global_loc, new stdext::cvt::codecvt_cp950< wchar_t >);
|
||||||
fs::path::imbue(loc);
|
fs::path::imbue(loc);
|
||||||
|
|
||||||
std::cout <<
|
std::cout << "HEADS UP! PIPE OUTPUT TO FILE AND INSPECT WITH HEX OR CP950 EDITOR.\n"
|
||||||
"HEADS UP! PIPE OUTPUT TO FILE AND INSPECT WITH HEX OR CP950 EDITOR.\n"
|
|
||||||
"WINDOWS COMMAND PROMPT FONTS DON'T SUPPORT CHINESE,\n"
|
"WINDOWS COMMAND PROMPT FONTS DON'T SUPPORT CHINESE,\n"
|
||||||
"EVEN WITH CODEPAGE SET AND EVEN AS OF WIN 10 TECH PREVIEW." << std::endl;
|
"EVEN WITH CODEPAGE SET AND EVEN AS OF WIN 10 TECH PREVIEW."
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
fs::recursive_directory_iterator end;
|
fs::recursive_directory_iterator end;
|
||||||
fs::recursive_directory_iterator iter
|
fs::recursive_directory_iterator iter("C:/boost/test-files/utf-8");
|
||||||
("C:/boost/test-files/utf-8");
|
|
||||||
|
|
||||||
while (iter != end)
|
while (iter != end)
|
||||||
{
|
{
|
||||||
|
@ -16,5 +16,3 @@ int main()
|
|||||||
std::cout << path("a/b/c/d/e/").stem() << std::endl;
|
std::cout << path("a/b/c/d/e/").stem() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
Test test1;
|
Test test1;
|
||||||
Test test2;
|
Test test2;
|
||||||
|
|
||||||
int cpp_main(int, char* [])
|
int cpp_main(int, char*[])
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_THROWS( fs::copy( "/tmp/non-existent-a", "/tmp/non-existent-b" ), std::exception );
|
BOOST_TEST_THROWS(fs::copy("/tmp/non-existent-a", "/tmp/non-existent-b"), std::exception);
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Before running this test: export LANG=foo
|
// Before running this test: export LANG=foo
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
boost::filesystem::path("/abc").root_directory();
|
boost::filesystem::path("/abc").root_directory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "boost/filesystem.hpp"
|
#include "boost/filesystem.hpp"
|
||||||
|
|
||||||
static const boost::filesystem::path::codecvt_type &dummy =
|
static const boost::filesystem::path::codecvt_type& dummy =
|
||||||
boost::filesystem::path::codecvt();
|
boost::filesystem::path::codecvt();
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ int cpp_main(int argc, char* argv[])
|
|||||||
cout << "Hello, 9219" << endl;
|
cout << "Hello, 9219" << endl;
|
||||||
cout << "This is a test for non-Windows systems" << endl;
|
cout << "This is a test for non-Windows systems" << endl;
|
||||||
|
|
||||||
BOOST_TEST(fs::exists(const_cast<char*>(".")));
|
BOOST_TEST(fs::exists(const_cast< char* >(".")));
|
||||||
|
|
||||||
return ::boost::report_errors();
|
return ::boost::report_errors();
|
||||||
} // cpp_main
|
} // cpp_main
|
||||||
|
@ -22,7 +22,8 @@ namespace fs = boost::filesystem;
|
|||||||
struct TmpDir
|
struct TmpDir
|
||||||
{
|
{
|
||||||
fs::path path;
|
fs::path path;
|
||||||
TmpDir(const fs::path& base): path(fs::absolute(base) / fs::unique_path())
|
TmpDir(const fs::path& base) :
|
||||||
|
path(fs::absolute(base) / fs::unique_path())
|
||||||
{
|
{
|
||||||
fs::create_directories(path);
|
fs::create_directories(path);
|
||||||
}
|
}
|
||||||
@ -49,13 +50,13 @@ int main()
|
|||||||
BOOST_TEST(fs::exists(junction));
|
BOOST_TEST(fs::exists(junction));
|
||||||
|
|
||||||
// Due to a bug there was a dependency on the current path so try the below for all:
|
// Due to a bug there was a dependency on the current path so try the below for all:
|
||||||
std::vector<fs::path> paths;
|
std::vector< fs::path > paths;
|
||||||
paths.push_back(cwd);
|
paths.push_back(cwd);
|
||||||
paths.push_back(junction);
|
paths.push_back(junction);
|
||||||
paths.push_back(real);
|
paths.push_back(real);
|
||||||
paths.push_back(junction / subDir);
|
paths.push_back(junction / subDir);
|
||||||
paths.push_back(real / subDir);
|
paths.push_back(real / subDir);
|
||||||
for (std::vector<fs::path>::iterator it = paths.begin(); it != paths.end(); ++it)
|
for (std::vector< fs::path >::iterator it = paths.begin(); it != paths.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << "Testing in " << *it << std::endl;
|
std::cout << "Testing in " << *it << std::endl;
|
||||||
fs::current_path(*it);
|
fs::current_path(*it);
|
||||||
@ -82,4 +83,3 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // defined(BOOST_FILESYSTEM_HAS_MKLINK)
|
#endif // defined(BOOST_FILESYSTEM_HAS_MKLINK)
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ void myFunc()
|
|||||||
|
|
||||||
copy_options opt(copy_options::overwrite_existing);
|
copy_options opt(copy_options::overwrite_existing);
|
||||||
|
|
||||||
copy_file(path("p1"),path("p2"),copy_options::overwrite_existing);
|
copy_file(path("p1"), path("p2"), copy_options::overwrite_existing);
|
||||||
// copy_file(path("p1"),path("p2"),opt);
|
// copy_file(path("p1"),path("p2"),opt);
|
||||||
}
|
}
|
@ -19,12 +19,15 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
# error This program depends on assert() so makes no sense if NDEBUG is defined
|
#error This program depends on assert() so makes no sense if NDEBUG is defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
{ std::ofstream file("out"); file << "contents"; }
|
{
|
||||||
|
std::ofstream file("out");
|
||||||
|
file << "contents";
|
||||||
|
}
|
||||||
|
|
||||||
assert(!::symlink("out", "sym"));
|
assert(!::symlink("out", "sym"));
|
||||||
|
|
||||||
|
@ -11,18 +11,18 @@
|
|||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/cerrno.hpp>
|
#include <boost/cerrno.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
@ -39,16 +39,15 @@ using std::cout;
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
#ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
# include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
namespace
|
namespace {
|
||||||
{
|
typedef int errno_t;
|
||||||
typedef int errno_t;
|
std::string platform(BOOST_PLATFORM);
|
||||||
std::string platform(BOOST_PLATFORM);
|
bool report_throws = false;
|
||||||
bool report_throws = false;
|
bool cleanup = true;
|
||||||
bool cleanup = true;
|
bool skip_long_windows_tests = false;
|
||||||
bool skip_long_windows_tests = false;
|
unsigned short language_id; // 0 except for Windows
|
||||||
unsigned short language_id; // 0 except for Windows
|
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
@ -81,18 +80,18 @@ int cpp_main(int argc, char* argv[])
|
|||||||
// The choice of platform to test is made at runtime rather than compile-time
|
// The choice of platform to test is made at runtime rather than compile-time
|
||||||
// so that compile errors for all platforms will be detected even though
|
// so that compile errors for all platforms will be detected even though
|
||||||
// only the current platform is runtime tested.
|
// only the current platform is runtime tested.
|
||||||
# if defined(BOOST_POSIX_API)
|
#if defined(BOOST_POSIX_API)
|
||||||
platform = "POSIX";
|
platform = "POSIX";
|
||||||
# elif defined(BOOST_WINDOWS_API)
|
#elif defined(BOOST_WINDOWS_API)
|
||||||
platform = "Windows";
|
platform = "Windows";
|
||||||
# if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
#if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||||
language_id = ::GetUserDefaultUILanguage();
|
language_id = ::GetUserDefaultUILanguage();
|
||||||
# else
|
#else
|
||||||
language_id = 0x0409; // Assume US English
|
language_id = 0x0409; // Assume US English
|
||||||
# endif
|
#endif
|
||||||
# else
|
#else
|
||||||
# error neither BOOST_POSIX_API nor BOOST_WINDOWS_API is defined. See boost/system/api_config.hpp
|
#error neither BOOST_POSIX_API nor BOOST_WINDOWS_API is defined. See boost/system/api_config.hpp
|
||||||
# endif
|
#endif
|
||||||
cout << "API is " << platform << endl;
|
cout << "API is " << platform << endl;
|
||||||
cout << "initial_path() is " << fs::initial_path() << endl;
|
cout << "initial_path() is " << fs::initial_path() << endl;
|
||||||
fs::path ip = fs::initial_path();
|
fs::path ip = fs::initial_path();
|
||||||
|
@ -16,23 +16,26 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
# include <windows.h>
|
#include <windows.h>
|
||||||
# include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma comment(lib, "Advapi32.lib")
|
#pragma comment(lib, "Advapi32.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Test correct boost::filesystem::status when reparse point ReparseTag set to IO_REPARSE_TAG_FILE_PLACEHOLDER
|
// Test correct boost::filesystem::status when reparse point ReparseTag set to IO_REPARSE_TAG_FILE_PLACEHOLDER
|
||||||
// https://docs.microsoft.com/en-us/windows/compatibility/placeholder-files?redirectedfrom=MSDN
|
// https://docs.microsoft.com/en-us/windows/compatibility/placeholder-files?redirectedfrom=MSDN
|
||||||
|
|
||||||
#if !defined(__MINGW32__) || defined(__MINGW64__)
|
#if !defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
typedef struct _REPARSE_DATA_BUFFER {
|
typedef struct _REPARSE_DATA_BUFFER
|
||||||
|
{
|
||||||
ULONG ReparseTag;
|
ULONG ReparseTag;
|
||||||
USHORT ReparseDataLength;
|
USHORT ReparseDataLength;
|
||||||
USHORT Reserved;
|
USHORT Reserved;
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
USHORT SubstituteNameOffset;
|
USHORT SubstituteNameOffset;
|
||||||
USHORT SubstituteNameLength;
|
USHORT SubstituteNameLength;
|
||||||
USHORT PrintNameOffset;
|
USHORT PrintNameOffset;
|
||||||
@ -40,14 +43,16 @@ typedef struct _REPARSE_DATA_BUFFER {
|
|||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
WCHAR PathBuffer[1];
|
WCHAR PathBuffer[1];
|
||||||
} SymbolicLinkReparseBuffer;
|
} SymbolicLinkReparseBuffer;
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
USHORT SubstituteNameOffset;
|
USHORT SubstituteNameOffset;
|
||||||
USHORT SubstituteNameLength;
|
USHORT SubstituteNameLength;
|
||||||
USHORT PrintNameOffset;
|
USHORT PrintNameOffset;
|
||||||
USHORT PrintNameLength;
|
USHORT PrintNameLength;
|
||||||
WCHAR PathBuffer[1];
|
WCHAR PathBuffer[1];
|
||||||
} MountPointReparseBuffer;
|
} MountPointReparseBuffer;
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
UCHAR DataBuffer[1];
|
UCHAR DataBuffer[1];
|
||||||
} GenericReparseBuffer;
|
} GenericReparseBuffer;
|
||||||
};
|
};
|
||||||
@ -55,15 +60,15 @@ typedef struct _REPARSE_DATA_BUFFER {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IO_REPARSE_TAG_FILE_PLACEHOLDER
|
#ifndef IO_REPARSE_TAG_FILE_PLACEHOLDER
|
||||||
# define IO_REPARSE_TAG_FILE_PLACEHOLDER (0x80000015L)
|
#define IO_REPARSE_TAG_FILE_PLACEHOLDER (0x80000015L)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FSCTL_SET_REPARSE_POINT
|
#ifndef FSCTL_SET_REPARSE_POINT
|
||||||
# define FSCTL_SET_REPARSE_POINT (0x000900a4)
|
#define FSCTL_SET_REPARSE_POINT (0x000900a4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef REPARSE_DATA_BUFFER_HEADER_SIZE
|
#ifndef REPARSE_DATA_BUFFER_HEADER_SIZE
|
||||||
# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
|
#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool obtain_restore_privilege()
|
bool obtain_restore_privilege()
|
||||||
@ -104,9 +109,7 @@ bool create_io_reparse_file_placeholder(const wchar_t* name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE hHandle = CreateFileW(name, GENERIC_WRITE,
|
HANDLE hHandle = CreateFileW(name, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_FLAG_OPEN_REPARSE_POINT, 0);
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
|
||||||
FILE_FLAG_OPEN_REPARSE_POINT, 0);
|
|
||||||
|
|
||||||
if (hHandle == INVALID_HANDLE_VALUE)
|
if (hHandle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -114,14 +117,12 @@ bool create_io_reparse_file_placeholder(const wchar_t* name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PREPARSE_DATA_BUFFER pReparse = reinterpret_cast<PREPARSE_DATA_BUFFER>(GlobalAlloc(GPTR, MAXIMUM_REPARSE_DATA_BUFFER_SIZE));
|
PREPARSE_DATA_BUFFER pReparse = reinterpret_cast< PREPARSE_DATA_BUFFER >(GlobalAlloc(GPTR, MAXIMUM_REPARSE_DATA_BUFFER_SIZE));
|
||||||
//note: IO_REPARSE_TAG_FILE_PLACEHOLDER - just to show that reparse point could be not only symlink or junction
|
//note: IO_REPARSE_TAG_FILE_PLACEHOLDER - just to show that reparse point could be not only symlink or junction
|
||||||
pReparse->ReparseTag = IO_REPARSE_TAG_FILE_PLACEHOLDER;
|
pReparse->ReparseTag = IO_REPARSE_TAG_FILE_PLACEHOLDER;
|
||||||
|
|
||||||
DWORD dwLen;
|
DWORD dwLen;
|
||||||
bool ret = DeviceIoControl(hHandle, FSCTL_SET_REPARSE_POINT, pReparse,
|
bool ret = DeviceIoControl(hHandle, FSCTL_SET_REPARSE_POINT, pReparse, pReparse->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, NULL, 0, &dwLen, NULL) != 0;
|
||||||
pReparse->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE,
|
|
||||||
NULL, 0, &dwLen, NULL) != 0;
|
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
if ( fs::detail::possible_large_file_size_support() )
|
if (fs::detail::possible_large_file_size_support())
|
||||||
{
|
{
|
||||||
std::cout << "It appears that file sizes greater that 2 gigabytes are possible\n"
|
std::cout << "It appears that file sizes greater that 2 gigabytes are possible\n"
|
||||||
"for this configuration on this platform since the operating system\n"
|
"for this configuration on this platform since the operating system\n"
|
||||||
|
@ -12,23 +12,20 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(push)
|
#pragma warning(push)
|
||||||
# pragma warning(disable: 4996) // ... Function call with parameters that may be unsafe
|
#pragma warning(disable : 4996) // ... Function call with parameters that may be unsafe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
void facet_info(const locale& loc, const char* msg)
|
||||||
{
|
{
|
||||||
void facet_info(const locale& loc, const char* msg)
|
|
||||||
{
|
|
||||||
cout << "has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >("
|
cout << "has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >("
|
||||||
<< msg << ") is "
|
<< msg << ") is "
|
||||||
<< (has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)
|
<< (has_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc) ? "true\n" : "false\n");
|
||||||
? "true\n"
|
}
|
||||||
: "false\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void default_info()
|
void default_info()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
locale loc;
|
locale loc;
|
||||||
@ -39,10 +36,10 @@ namespace
|
|||||||
{
|
{
|
||||||
cout << "\nlocale default construction threw: " << ex.what() << endl;
|
cout << "\nlocale default construction threw: " << ex.what() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void null_string_info()
|
void null_string_info()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
locale loc("");
|
locale loc("");
|
||||||
@ -53,10 +50,10 @@ namespace
|
|||||||
{
|
{
|
||||||
cout << "\nlocale(\"\") construction threw: " << ex.what() << endl;
|
cout << "\nlocale(\"\") construction threw: " << ex.what() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void classic_info()
|
void classic_info()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
locale loc(locale::classic());
|
locale loc(locale::classic());
|
||||||
@ -67,8 +64,8 @@ namespace
|
|||||||
{
|
{
|
||||||
cout << "\nlocale(locale::clasic()) copy construction threw: " << ex.what() << endl;
|
cout << "\nlocale(locale::clasic()) copy construction threw: " << ex.what() << endl;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -84,5 +81,5 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,8 +20,7 @@ using namespace boost::filesystem;
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
int cpp_main(int, char*[])
|
int cpp_main(int, char*[])
|
||||||
@ -30,8 +29,7 @@ int cpp_main(int, char*[])
|
|||||||
std::string prefix("d:\\temp\\");
|
std::string prefix("d:\\temp\\");
|
||||||
std::cout << "prefix is " << prefix << '\n';
|
std::cout << "prefix is " << prefix << '\n';
|
||||||
|
|
||||||
const std::size_t safe_size
|
const std::size_t safe_size = 260 - prefix.size() - 100; // Windows MAX_PATH is 260
|
||||||
= 260 - prefix.size() - 100; // Windows MAX_PATH is 260
|
|
||||||
|
|
||||||
std::string safe_x_string(safe_size, 'x');
|
std::string safe_x_string(safe_size, 'x');
|
||||||
std::string safe_y_string(safe_size, 'y');
|
std::string safe_y_string(safe_size, 'y');
|
||||||
|
@ -15,19 +15,18 @@
|
|||||||
#undef BOOST_SYSTEM_STATIC_LINK
|
#undef BOOST_SYSTEM_STATIC_LINK
|
||||||
|
|
||||||
#ifndef BOOST_ALL_NO_LIB
|
#ifndef BOOST_ALL_NO_LIB
|
||||||
# define BOOST_ALL_NO_LIB
|
#define BOOST_ALL_NO_LIB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/config.hpp>
|
#include <boost/filesystem/config.hpp>
|
||||||
#include <boost/system/config.hpp>
|
#include <boost/system/config.hpp>
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_STATIC_LINK
|
#ifndef BOOST_FILESYSTEM_STATIC_LINK
|
||||||
# error BOOST_FILESYSTEM_STATIC_LINK not set by default
|
#error BOOST_FILESYSTEM_STATIC_LINK not set by default
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_SYSTEM_STATIC_LINK
|
#ifndef BOOST_SYSTEM_STATIC_LINK
|
||||||
# error BOOST_SYSTEM_STATIC_LINK not set by default
|
#error BOOST_SYSTEM_STATIC_LINK not set by default
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -9,13 +9,11 @@
|
|||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
{
|
namespace filesystem {
|
||||||
namespace filesystem
|
void tu2();
|
||||||
{
|
|
||||||
void tu2();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
void tu2()
|
||||||
{
|
{
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
void tu2() {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace filesystem
|
||||||
|
} // namespace boost
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,23 +13,22 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------//
|
// ------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|
||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem.hpp> // make sure filesystem.hpp works
|
#include <boost/filesystem.hpp> // make sure filesystem.hpp works
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
@ -44,23 +43,23 @@ using std::string;
|
|||||||
|
|
||||||
#define CHECK(x) check(x, __FILE__, __LINE__)
|
#define CHECK(x) check(x, __FILE__, __LINE__)
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
bool cleanup = true;
|
||||||
bool cleanup = true;
|
|
||||||
|
|
||||||
void check(bool ok, const char* file, int line)
|
void check(bool ok, const char* file, int line)
|
||||||
{
|
{
|
||||||
if (ok) return;
|
if (ok)
|
||||||
|
return;
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
cout << file << '(' << line << "): test failed\n";
|
cout << file << '(' << line << "): test failed\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// file_status_test ----------------------------------------------------------------//
|
// file_status_test ----------------------------------------------------------------//
|
||||||
|
|
||||||
void file_status_test()
|
void file_status_test()
|
||||||
{
|
{
|
||||||
cout << "file_status test..." << endl;
|
cout << "file_status test..." << endl;
|
||||||
|
|
||||||
file_status s = status(".");
|
file_status s = status(".");
|
||||||
@ -74,17 +73,17 @@ namespace
|
|||||||
cout << " symlink_status(\".\") permissions are "
|
cout << " symlink_status(\".\") permissions are "
|
||||||
<< std::oct << (v & 0777) << std::dec << endl;
|
<< std::oct << (v & 0777) << std::dec << endl;
|
||||||
CHECK((v & 0400) == 0400);
|
CHECK((v & 0400) == 0400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// query_test ----------------------------------------------------------------------//
|
// query_test ----------------------------------------------------------------------//
|
||||||
|
|
||||||
void query_test()
|
void query_test()
|
||||||
{
|
{
|
||||||
cout << "query test..." << endl;
|
cout << "query test..." << endl;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
|
||||||
CHECK(file_size("no-such-file", ec) == static_cast<boost::uintmax_t>(-1));
|
CHECK(file_size("no-such-file", ec) == static_cast< boost::uintmax_t >(-1));
|
||||||
CHECK(ec == errc::no_such_file_or_directory);
|
CHECK(ec == errc::no_such_file_or_directory);
|
||||||
|
|
||||||
CHECK(status("no-such-file") == file_status(file_not_found, no_perms));
|
CHECK(status("no-such-file") == file_status(file_not_found, no_perms));
|
||||||
@ -97,7 +96,7 @@ namespace
|
|||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
cout << "exists(\"/\", ec) resulted in non-zero ec.value()" << endl;
|
cout << "exists(\"/\", ec) resulted in non-zero ec.value()" << endl;
|
||||||
cout << "ec value: " << ec.value() << ", message: "<< ec.message() << endl;
|
cout << "ec value: " << ec.value() << ", message: " << ec.message() << endl;
|
||||||
}
|
}
|
||||||
CHECK(!ec);
|
CHECK(!ec);
|
||||||
|
|
||||||
@ -106,12 +105,12 @@ namespace
|
|||||||
CHECK(!is_regular_file("/"));
|
CHECK(!is_regular_file("/"));
|
||||||
CHECK(!boost::filesystem::is_empty("/"));
|
CHECK(!boost::filesystem::is_empty("/"));
|
||||||
CHECK(!is_other("/"));
|
CHECK(!is_other("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory_iterator_test -----------------------------------------------//
|
// directory_iterator_test -----------------------------------------------//
|
||||||
|
|
||||||
void directory_iterator_test()
|
void directory_iterator_test()
|
||||||
{
|
{
|
||||||
cout << "directory_iterator_test..." << endl;
|
cout << "directory_iterator_test..." << endl;
|
||||||
|
|
||||||
directory_iterator end;
|
directory_iterator end;
|
||||||
@ -167,12 +166,12 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "directory_iterator_test complete" << endl;
|
cout << "directory_iterator_test complete" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursive_directory_iterator_test -----------------------------------------------//
|
// recursive_directory_iterator_test -----------------------------------------------//
|
||||||
|
|
||||||
void recursive_directory_iterator_test()
|
void recursive_directory_iterator_test()
|
||||||
{
|
{
|
||||||
cout << "recursive_directory_iterator_test..." << endl;
|
cout << "recursive_directory_iterator_test..." << endl;
|
||||||
|
|
||||||
recursive_directory_iterator end;
|
recursive_directory_iterator end;
|
||||||
@ -229,12 +228,12 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "recursive_directory_iterator_test complete" << endl;
|
cout << "recursive_directory_iterator_test complete" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// operations_test -------------------------------------------------------//
|
// operations_test -------------------------------------------------------//
|
||||||
|
|
||||||
void operations_test()
|
void operations_test()
|
||||||
{
|
{
|
||||||
cout << "operations test..." << endl;
|
cout << "operations test..." << endl;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
@ -254,16 +253,15 @@ namespace
|
|||||||
std::time_t ft = last_write_time(".");
|
std::time_t ft = last_write_time(".");
|
||||||
ft = -1;
|
ft = -1;
|
||||||
last_write_time(".", ft, ec);
|
last_write_time(".", ft, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory_entry_test ------------------------------------------------------------//
|
// directory_entry_test ------------------------------------------------------------//
|
||||||
|
|
||||||
void directory_entry_test()
|
void directory_entry_test()
|
||||||
{
|
{
|
||||||
cout << "directory_entry test..." << endl;
|
cout << "directory_entry test..." << endl;
|
||||||
|
|
||||||
directory_entry de("foo.bar",
|
directory_entry de("foo.bar", file_status(regular_file, owner_all), file_status(directory_file, group_all));
|
||||||
file_status(regular_file, owner_all), file_status(directory_file, group_all));
|
|
||||||
|
|
||||||
CHECK(de.path() == "foo.bar");
|
CHECK(de.path() == "foo.bar");
|
||||||
CHECK(de.status() == file_status(regular_file, owner_all));
|
CHECK(de.status() == file_status(regular_file, owner_all));
|
||||||
@ -273,22 +271,22 @@ namespace
|
|||||||
CHECK(de != directory_entry("goo.bar"));
|
CHECK(de != directory_entry("goo.bar"));
|
||||||
de.replace_filename("bar.foo");
|
de.replace_filename("bar.foo");
|
||||||
CHECK(de.path() == "bar.foo");
|
CHECK(de.path() == "bar.foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory_entry_overload_test ---------------------------------------------------//
|
// directory_entry_overload_test ---------------------------------------------------//
|
||||||
|
|
||||||
void directory_entry_overload_test()
|
void directory_entry_overload_test()
|
||||||
{
|
{
|
||||||
cout << "directory_entry overload test..." << endl;
|
cout << "directory_entry overload test..." << endl;
|
||||||
|
|
||||||
directory_iterator it(".");
|
directory_iterator it(".");
|
||||||
path p(*it);
|
path p(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// error_handling_test -------------------------------------------------------------//
|
// error_handling_test -------------------------------------------------------------//
|
||||||
|
|
||||||
void error_handling_test()
|
void error_handling_test()
|
||||||
{
|
{
|
||||||
cout << "error handling test..." << endl;
|
cout << "error handling test..." << endl;
|
||||||
|
|
||||||
bool threw(false);
|
bool threw(false);
|
||||||
@ -296,11 +294,12 @@ namespace
|
|||||||
{
|
{
|
||||||
file_size("no-such-file");
|
file_size("no-such-file");
|
||||||
}
|
}
|
||||||
catch (const boost::filesystem::filesystem_error & ex)
|
catch (const boost::filesystem::filesystem_error& ex)
|
||||||
{
|
{
|
||||||
threw = true;
|
threw = true;
|
||||||
cout << "\nas expected, attempt to get size of non-existent file threw a filesystem_error\n"
|
cout << "\nas expected, attempt to get size of non-existent file threw a filesystem_error\n"
|
||||||
"what() returns " << ex.what() << "\n";
|
"what() returns "
|
||||||
|
<< ex.what() << "\n";
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -311,12 +310,12 @@ namespace
|
|||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
CHECK(!create_directory("/", ec));
|
CHECK(!create_directory("/", ec));
|
||||||
}
|
}
|
||||||
|
|
||||||
// string_file_tests ---------------------------------------------------------------//
|
// string_file_tests ---------------------------------------------------------------//
|
||||||
|
|
||||||
void string_file_tests(const path& temp_dir)
|
void string_file_tests(const path& temp_dir)
|
||||||
{
|
{
|
||||||
cout << "string_file_tests..." << endl;
|
cout << "string_file_tests..." << endl;
|
||||||
std::string contents("0123456789");
|
std::string contents("0123456789");
|
||||||
path p(temp_dir / "string_file");
|
path p(temp_dir / "string_file");
|
||||||
@ -326,7 +325,7 @@ namespace
|
|||||||
std::string round_trip;
|
std::string round_trip;
|
||||||
load_string_file(p, round_trip);
|
load_string_file(p, round_trip);
|
||||||
BOOST_TEST_EQ(contents, round_trip);
|
BOOST_TEST_EQ(contents, round_trip);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ int cpp_main(int argc, char* argv[])
|
|||||||
cout << "argv[1] is '" << argv[1] << "', changing current_path() to it" << endl;
|
cout << "argv[1] is '" << argv[1] << "', changing current_path() to it" << endl;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
current_path( argv[1], ec );
|
current_path(argv[1], ec);
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
@ -395,7 +394,7 @@ int cpp_main(int argc, char* argv[])
|
|||||||
// above was added just to simplify testing, but it ended up detecting
|
// above was added just to simplify testing, but it ended up detecting
|
||||||
// a bug (failure to close an internal search handle).
|
// a bug (failure to close an internal search handle).
|
||||||
cout << "post-test removal complete" << endl;
|
cout << "post-test removal complete" << endl;
|
||||||
// BOOST_TEST(!fs::exists(dir)); // nice test, but doesn't play well with TortoiseGit cache
|
// BOOST_TEST(!fs::exists(dir)); // nice test, but doesn't play well with TortoiseGit cache
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::boost::report_errors();
|
return ::boost::report_errors();
|
||||||
|
@ -43,19 +43,19 @@
|
|||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/exception.hpp>
|
#include <boost/filesystem/exception.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
@ -74,20 +74,18 @@ using boost::next;
|
|||||||
using boost::prior;
|
using boost::prior;
|
||||||
|
|
||||||
#ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
# define BOOST_DIR_SEP "\\"
|
#define BOOST_DIR_SEP "\\"
|
||||||
#else
|
#else
|
||||||
# define BOOST_DIR_SEP "/"
|
#define BOOST_DIR_SEP "/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PATH_TEST_EQ(a, b) check(a, b, __FILE__, __LINE__)
|
#define PATH_TEST_EQ(a, b) check(a, b, __FILE__, __LINE__)
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
std::string platform(BOOST_PLATFORM);
|
||||||
std::string platform(BOOST_PLATFORM);
|
|
||||||
|
|
||||||
void check(const fs::path & source,
|
void check(const fs::path& source, const std::string& expected, const char* file, int line)
|
||||||
const std::string & expected, const char* file, int line)
|
{
|
||||||
{
|
|
||||||
if (source.string() == expected)
|
if (source.string() == expected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -97,23 +95,26 @@ namespace
|
|||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
path p1("fe/fi/fo/fum");
|
path p1("fe/fi/fo/fum");
|
||||||
path p2(p1);
|
path p2(p1);
|
||||||
path p3;
|
path p3;
|
||||||
path p4("foobar");
|
path p4("foobar");
|
||||||
path p5;
|
path p5;
|
||||||
|
|
||||||
// exception_tests -----------------------------------------------------------------//
|
// exception_tests -----------------------------------------------------------------//
|
||||||
|
|
||||||
void exception_tests()
|
void exception_tests()
|
||||||
{
|
{
|
||||||
std::cout << "exception_tests..." << std::endl;
|
std::cout << "exception_tests..." << std::endl;
|
||||||
const std::string str_1("string-1");
|
const std::string str_1("string-1");
|
||||||
boost::system::error_code ec(12345, boost::system::system_category());
|
boost::system::error_code ec(12345, boost::system::system_category());
|
||||||
try { throw fs::filesystem_error(str_1, ec); }
|
try
|
||||||
catch (const fs::filesystem_error & ex)
|
{
|
||||||
|
throw fs::filesystem_error(str_1, ec);
|
||||||
|
}
|
||||||
|
catch (const fs::filesystem_error& ex)
|
||||||
{
|
{
|
||||||
//std::cout << ex.what() << "*" << std::endl;
|
//std::cout << ex.what() << "*" << std::endl;
|
||||||
//BOOST_TEST(std::strcmp(ex.what(),
|
//BOOST_TEST(std::strcmp(ex.what(),
|
||||||
@ -121,8 +122,11 @@ namespace
|
|||||||
BOOST_TEST(ex.code() == ec);
|
BOOST_TEST(ex.code() == ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
try { throw fs::filesystem_error(str_1, "p1", "p2", ec); }
|
try
|
||||||
catch (const fs::filesystem_error & ex)
|
{
|
||||||
|
throw fs::filesystem_error(str_1, "p1", "p2", ec);
|
||||||
|
}
|
||||||
|
catch (const fs::filesystem_error& ex)
|
||||||
{
|
{
|
||||||
//std::cout << ex.what() << "*" << std::endl;
|
//std::cout << ex.what() << "*" << std::endl;
|
||||||
//BOOST_TEST(std::strcmp(ex.what(),
|
//BOOST_TEST(std::strcmp(ex.what(),
|
||||||
@ -131,15 +135,15 @@ namespace
|
|||||||
BOOST_TEST(ex.path1() == "p1");
|
BOOST_TEST(ex.path1() == "p1");
|
||||||
BOOST_TEST(ex.path2() == "p2");
|
BOOST_TEST(ex.path2() == "p2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// overload_tests ------------------------------------------------------------------//
|
// overload_tests ------------------------------------------------------------------//
|
||||||
|
|
||||||
// These verify various overloads don't cause compiler errors
|
// These verify various overloads don't cause compiler errors
|
||||||
// They pre-date operations_unit_test.cpp
|
// They pre-date operations_unit_test.cpp
|
||||||
|
|
||||||
void overload_tests()
|
void overload_tests()
|
||||||
{
|
{
|
||||||
std::cout << "overload_tests..." << std::endl;
|
std::cout << "overload_tests..." << std::endl;
|
||||||
|
|
||||||
fs::exists(p1);
|
fs::exists(p1);
|
||||||
@ -156,12 +160,12 @@ namespace
|
|||||||
p4 /= path("foo");
|
p4 /= path("foo");
|
||||||
p4 /= "foo";
|
p4 /= "foo";
|
||||||
p4 /= std::string("foo");
|
p4 /= std::string("foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterator_tests ------------------------------------------------------------------//
|
// iterator_tests ------------------------------------------------------------------//
|
||||||
|
|
||||||
void iterator_tests()
|
void iterator_tests()
|
||||||
{
|
{
|
||||||
std::cout << "iterator_tests..." << std::endl;
|
std::cout << "iterator_tests..." << std::endl;
|
||||||
|
|
||||||
path itr_ck = "";
|
path itr_ck = "";
|
||||||
@ -430,12 +434,12 @@ namespace
|
|||||||
PATH_TEST_EQ(itr->string(), "/");
|
PATH_TEST_EQ(itr->string(), "/");
|
||||||
BOOST_TEST(++itr == itr_ck.end());
|
BOOST_TEST(++itr == itr_ck.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// non_member_tests ----------------------------------------------------------------//
|
// non_member_tests ----------------------------------------------------------------//
|
||||||
|
|
||||||
void non_member_tests()
|
void non_member_tests()
|
||||||
{
|
{
|
||||||
std::cout << "non_member_tests..." << std::endl;
|
std::cout << "non_member_tests..." << std::endl;
|
||||||
|
|
||||||
// test non-member functions, particularly operator overloads
|
// test non-member functions, particularly operator overloads
|
||||||
@ -482,22 +486,22 @@ namespace
|
|||||||
PATH_TEST_EQ(path("foo") / "bar", "foo\\bar"); // const char* arg
|
PATH_TEST_EQ(path("foo") / "bar", "foo\\bar"); // const char* arg
|
||||||
PATH_TEST_EQ(path("foo") / path("woo/bar").filename(), "foo\\bar"); // const std::string & arg
|
PATH_TEST_EQ(path("foo") / path("woo/bar").filename(), "foo\\bar"); // const std::string & arg
|
||||||
PATH_TEST_EQ("foo" / path("bar"), "foo\\bar");
|
PATH_TEST_EQ("foo" / path("bar"), "foo\\bar");
|
||||||
PATH_TEST_EQ(path("..") / ".." , "..\\..");
|
PATH_TEST_EQ(path("..") / "..", "..\\..");
|
||||||
PATH_TEST_EQ(path("/") / ".." , "/..");
|
PATH_TEST_EQ(path("/") / "..", "/..");
|
||||||
PATH_TEST_EQ(path("/..") / ".." , "/..\\..");
|
PATH_TEST_EQ(path("/..") / "..", "/..\\..");
|
||||||
PATH_TEST_EQ(path("..") / "foo" , "..\\foo");
|
PATH_TEST_EQ(path("..") / "foo", "..\\foo");
|
||||||
PATH_TEST_EQ(path("foo") / ".." , "foo\\..");
|
PATH_TEST_EQ(path("foo") / "..", "foo\\..");
|
||||||
PATH_TEST_EQ(path("..") / "f" , "..\\f");
|
PATH_TEST_EQ(path("..") / "f", "..\\f");
|
||||||
PATH_TEST_EQ(path("/..") / "f" , "/..\\f");
|
PATH_TEST_EQ(path("/..") / "f", "/..\\f");
|
||||||
PATH_TEST_EQ(path("f") / ".." , "f\\..");
|
PATH_TEST_EQ(path("f") / "..", "f\\..");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / ".." , "foo\\..\\..");
|
PATH_TEST_EQ(path("foo") / ".." / "..", "foo\\..\\..");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / ".." / ".." , "foo\\..\\..\\..");
|
PATH_TEST_EQ(path("foo") / ".." / ".." / "..", "foo\\..\\..\\..");
|
||||||
PATH_TEST_EQ(path("f") / ".." / "b" , "f\\..\\b");
|
PATH_TEST_EQ(path("f") / ".." / "b", "f\\..\\b");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / "bar" , "foo\\..\\bar");
|
PATH_TEST_EQ(path("foo") / ".." / "bar", "foo\\..\\bar");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." , "foo\\bar\\..");
|
PATH_TEST_EQ(path("foo") / "bar" / "..", "foo\\bar\\..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." / "..", "foo\\bar\\..\\..");
|
PATH_TEST_EQ(path("foo") / "bar" / ".." / "..", "foo\\bar\\..\\..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." / "blah", "foo\\bar\\..\\blah");
|
PATH_TEST_EQ(path("foo") / "bar" / ".." / "blah", "foo\\bar\\..\\blah");
|
||||||
PATH_TEST_EQ(path("f") / "b" / ".." , "f\\b\\..");
|
PATH_TEST_EQ(path("f") / "b" / "..", "f\\b\\..");
|
||||||
PATH_TEST_EQ(path("f") / "b" / ".." / "a", "f\\b\\..\\a");
|
PATH_TEST_EQ(path("f") / "b" / ".." / "a", "f\\b\\..\\a");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / "..", "foo\\bar\\blah\\..\\..");
|
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / "..", "foo\\bar\\blah\\..\\..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo\\bar\\blah\\..\\..\\bletch");
|
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo\\bar\\blah\\..\\..\\bletch");
|
||||||
@ -530,22 +534,22 @@ namespace
|
|||||||
PATH_TEST_EQ(path("foo") / "bar", "foo/bar"); // const char* arg
|
PATH_TEST_EQ(path("foo") / "bar", "foo/bar"); // const char* arg
|
||||||
PATH_TEST_EQ(path("foo") / path("woo/bar").filename(), "foo/bar"); // const std::string & arg
|
PATH_TEST_EQ(path("foo") / path("woo/bar").filename(), "foo/bar"); // const std::string & arg
|
||||||
PATH_TEST_EQ("foo" / path("bar"), "foo/bar");
|
PATH_TEST_EQ("foo" / path("bar"), "foo/bar");
|
||||||
PATH_TEST_EQ(path("..") / ".." , "../..");
|
PATH_TEST_EQ(path("..") / "..", "../..");
|
||||||
PATH_TEST_EQ(path("/") / ".." , "/..");
|
PATH_TEST_EQ(path("/") / "..", "/..");
|
||||||
PATH_TEST_EQ(path("/..") / ".." , "/../..");
|
PATH_TEST_EQ(path("/..") / "..", "/../..");
|
||||||
PATH_TEST_EQ(path("..") / "foo" , "../foo");
|
PATH_TEST_EQ(path("..") / "foo", "../foo");
|
||||||
PATH_TEST_EQ(path("foo") / ".." , "foo/..");
|
PATH_TEST_EQ(path("foo") / "..", "foo/..");
|
||||||
PATH_TEST_EQ(path("..") / "f" , "../f");
|
PATH_TEST_EQ(path("..") / "f", "../f");
|
||||||
PATH_TEST_EQ(path("/..") / "f" , "/../f");
|
PATH_TEST_EQ(path("/..") / "f", "/../f");
|
||||||
PATH_TEST_EQ(path("f") / ".." , "f/..");
|
PATH_TEST_EQ(path("f") / "..", "f/..");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / ".." , "foo/../..");
|
PATH_TEST_EQ(path("foo") / ".." / "..", "foo/../..");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / ".." / ".." , "foo/../../..");
|
PATH_TEST_EQ(path("foo") / ".." / ".." / "..", "foo/../../..");
|
||||||
PATH_TEST_EQ(path("f") / ".." / "b" , "f/../b");
|
PATH_TEST_EQ(path("f") / ".." / "b", "f/../b");
|
||||||
PATH_TEST_EQ(path("foo") / ".." / "bar" , "foo/../bar");
|
PATH_TEST_EQ(path("foo") / ".." / "bar", "foo/../bar");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." , "foo/bar/..");
|
PATH_TEST_EQ(path("foo") / "bar" / "..", "foo/bar/..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." / "..", "foo/bar/../..");
|
PATH_TEST_EQ(path("foo") / "bar" / ".." / "..", "foo/bar/../..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / ".." / "blah", "foo/bar/../blah");
|
PATH_TEST_EQ(path("foo") / "bar" / ".." / "blah", "foo/bar/../blah");
|
||||||
PATH_TEST_EQ(path("f") / "b" / ".." , "f/b/..");
|
PATH_TEST_EQ(path("f") / "b" / "..", "f/b/..");
|
||||||
PATH_TEST_EQ(path("f") / "b" / ".." / "a", "f/b/../a");
|
PATH_TEST_EQ(path("f") / "b" / ".." / "a", "f/b/../a");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / "..", "foo/bar/blah/../..");
|
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / "..", "foo/bar/blah/../..");
|
||||||
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo/bar/blah/../../bletch");
|
PATH_TEST_EQ(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo/bar/blah/../../bletch");
|
||||||
@ -669,8 +673,8 @@ namespace
|
|||||||
if (platform == "Windows")
|
if (platform == "Windows")
|
||||||
{
|
{
|
||||||
std::cout << " Windows relational tests..." << std::endl;
|
std::cout << " Windows relational tests..." << std::endl;
|
||||||
path p10 ("c:\\file");
|
path p10("c:\\file");
|
||||||
path p11 ("c:/file");
|
path p11("c:/file");
|
||||||
// check each overload
|
// check each overload
|
||||||
BOOST_TEST(p10.generic_string() == p11.generic_string());
|
BOOST_TEST(p10.generic_string() == p11.generic_string());
|
||||||
BOOST_TEST(p10 == p11);
|
BOOST_TEST(p10 == p11);
|
||||||
@ -748,15 +752,15 @@ namespace
|
|||||||
<< fs::relative("/abc/xyz/def", "/abc") << std::endl;
|
<< fs::relative("/abc/xyz/def", "/abc") << std::endl;
|
||||||
BOOST_TEST(fs::relative("abc\\xyz\\def", "abc") == path("xyz/def"));
|
BOOST_TEST(fs::relative("abc\\xyz\\def", "abc") == path("xyz/def"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// query_and_decomposition_tests ---------------------------------------------------//
|
// query_and_decomposition_tests ---------------------------------------------------//
|
||||||
//
|
//
|
||||||
// remove_filename() is also tested here, because its specification depends on
|
// remove_filename() is also tested here, because its specification depends on
|
||||||
// a decomposition function.
|
// a decomposition function.
|
||||||
|
|
||||||
void query_and_decomposition_tests()
|
void query_and_decomposition_tests()
|
||||||
{
|
{
|
||||||
std::cout << "query_and_decomposition_tests..." << std::endl;
|
std::cout << "query_and_decomposition_tests..." << std::endl;
|
||||||
|
|
||||||
// these are the examples given in reference docs, so check they work
|
// these are the examples given in reference docs, so check they work
|
||||||
@ -1382,20 +1386,19 @@ namespace
|
|||||||
p = path("/usr/local/bin:/usr/bin:/bin");
|
p = path("/usr/local/bin:/usr/bin:/bin");
|
||||||
BOOST_TEST(p.string() == "/usr/local/bin:/usr/bin:/bin");
|
BOOST_TEST(p.string() == "/usr/local/bin:/usr/bin:/bin");
|
||||||
} // POSIX
|
} // POSIX
|
||||||
}
|
}
|
||||||
|
|
||||||
// composition_tests ----------------------------------------------------------------//
|
// composition_tests ----------------------------------------------------------------//
|
||||||
|
|
||||||
void composition_tests()
|
void composition_tests()
|
||||||
{
|
{
|
||||||
std::cout << "composition_tests..." << std::endl;
|
std::cout << "composition_tests..." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// construction_tests ---------------------------------------------------------------//
|
||||||
|
|
||||||
// construction_tests ---------------------------------------------------------------//
|
void construction_tests()
|
||||||
|
{
|
||||||
void construction_tests()
|
|
||||||
{
|
|
||||||
std::cout << "construction_tests..." << std::endl;
|
std::cout << "construction_tests..." << std::endl;
|
||||||
|
|
||||||
PATH_TEST_EQ("", "");
|
PATH_TEST_EQ("", "");
|
||||||
@ -1522,22 +1525,22 @@ namespace
|
|||||||
PATH_TEST_EQ("././..", "././..");
|
PATH_TEST_EQ("././..", "././..");
|
||||||
PATH_TEST_EQ("./../.", "./../.");
|
PATH_TEST_EQ("./../.", "./../.");
|
||||||
PATH_TEST_EQ(".././.", ".././.");
|
PATH_TEST_EQ(".././.", ".././.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// append_tests --------------------------------------------------------------------//
|
// append_tests --------------------------------------------------------------------//
|
||||||
|
|
||||||
void append_test_aux(const path & p, const std::string & s, const std::string & expect)
|
void append_test_aux(const path& p, const std::string& s, const std::string& expect)
|
||||||
{
|
{
|
||||||
PATH_TEST_EQ((p / path(s)).string(), expect);
|
PATH_TEST_EQ((p / path(s)).string(), expect);
|
||||||
PATH_TEST_EQ((p / s.c_str()).string(), expect);
|
PATH_TEST_EQ((p / s.c_str()).string(), expect);
|
||||||
PATH_TEST_EQ((p / s).string(), expect);
|
PATH_TEST_EQ((p / s).string(), expect);
|
||||||
path x(p);
|
path x(p);
|
||||||
x.append(s.begin(), s.end());
|
x.append(s.begin(), s.end());
|
||||||
PATH_TEST_EQ(x.string(), expect);
|
PATH_TEST_EQ(x.string(), expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void append_tests()
|
void append_tests()
|
||||||
{
|
{
|
||||||
std::cout << "append_tests..." << std::endl;
|
std::cout << "append_tests..." << std::endl;
|
||||||
|
|
||||||
// There are many control paths to be exercised, since empty paths and arguments,
|
// There are many control paths to be exercised, since empty paths and arguments,
|
||||||
@ -1605,7 +1608,6 @@ namespace
|
|||||||
PATH_TEST_EQ(path("foo/") / "bar", "foo/bar");
|
PATH_TEST_EQ(path("foo/") / "bar", "foo/bar");
|
||||||
append_test_aux("foo/", "bar", "foo/bar");
|
append_test_aux("foo/", "bar", "foo/bar");
|
||||||
|
|
||||||
|
|
||||||
if (platform == "Windows")
|
if (platform == "Windows")
|
||||||
{
|
{
|
||||||
PATH_TEST_EQ(path("foo") / "bar", "foo\\bar");
|
PATH_TEST_EQ(path("foo") / "bar", "foo\\bar");
|
||||||
@ -1638,12 +1640,12 @@ namespace
|
|||||||
path p6819;
|
path p6819;
|
||||||
p6819 /= u.a;
|
p6819 /= u.a;
|
||||||
BOOST_TEST_EQ(p6819, path("ab"));
|
BOOST_TEST_EQ(p6819, path("ab"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// self_assign_and_append_tests ------------------------------------------------------//
|
// self_assign_and_append_tests ------------------------------------------------------//
|
||||||
|
|
||||||
void self_assign_and_append_tests()
|
void self_assign_and_append_tests()
|
||||||
{
|
{
|
||||||
std::cout << "self_assign_and_append_tests..." << std::endl;
|
std::cout << "self_assign_and_append_tests..." << std::endl;
|
||||||
|
|
||||||
path p;
|
path p;
|
||||||
@ -1660,7 +1662,7 @@ namespace
|
|||||||
PATH_TEST_EQ(p, "snafubar");
|
PATH_TEST_EQ(p, "snafubar");
|
||||||
|
|
||||||
p = "snafubar";
|
p = "snafubar";
|
||||||
PATH_TEST_EQ(p = p.c_str()+5, "bar");
|
PATH_TEST_EQ(p = p.c_str() + 5, "bar");
|
||||||
|
|
||||||
p = "snafubar";
|
p = "snafubar";
|
||||||
PATH_TEST_EQ(p.assign(p.c_str() + 5, p.c_str() + 7), "ba");
|
PATH_TEST_EQ(p.assign(p.c_str() + 5, p.c_str() + 7), "ba");
|
||||||
@ -1679,13 +1681,12 @@ namespace
|
|||||||
|
|
||||||
p = "snafubar";
|
p = "snafubar";
|
||||||
PATH_TEST_EQ(p.append(p.c_str() + 5, p.c_str() + 7), "snafubar" BOOST_DIR_SEP "ba");
|
PATH_TEST_EQ(p.append(p.c_str() + 5, p.c_str() + 7), "snafubar" BOOST_DIR_SEP "ba");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// name_function_tests -------------------------------------------------------------//
|
||||||
|
|
||||||
// name_function_tests -------------------------------------------------------------//
|
void name_function_tests()
|
||||||
|
{
|
||||||
void name_function_tests()
|
|
||||||
{
|
|
||||||
std::cout << "name_function_tests..." << std::endl;
|
std::cout << "name_function_tests..." << std::endl;
|
||||||
|
|
||||||
BOOST_TEST(fs::portable_posix_name(std::string("x")));
|
BOOST_TEST(fs::portable_posix_name(std::string("x")));
|
||||||
@ -1763,12 +1764,12 @@ namespace
|
|||||||
BOOST_TEST(!fs::portable_name(std::string("foo.")));
|
BOOST_TEST(!fs::portable_name(std::string("foo.")));
|
||||||
BOOST_TEST(!fs::portable_directory_name(std::string("foo.")));
|
BOOST_TEST(!fs::portable_directory_name(std::string("foo.")));
|
||||||
BOOST_TEST(!fs::portable_file_name(std::string("foo.")));
|
BOOST_TEST(!fs::portable_file_name(std::string("foo.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace_extension_tests ---------------------------------------------------------//
|
// replace_extension_tests ---------------------------------------------------------//
|
||||||
|
|
||||||
void replace_extension_tests()
|
void replace_extension_tests()
|
||||||
{
|
{
|
||||||
std::cout << "replace_extension_tests..." << std::endl;
|
std::cout << "replace_extension_tests..." << std::endl;
|
||||||
|
|
||||||
BOOST_TEST(path().replace_extension().empty());
|
BOOST_TEST(path().replace_extension().empty());
|
||||||
@ -1793,32 +1794,29 @@ namespace
|
|||||||
BOOST_TEST(path("a/b").replace_extension(".c") == "a/b.c");
|
BOOST_TEST(path("a/b").replace_extension(".c") == "a/b.c");
|
||||||
PATH_TEST_EQ(path("a.txt/b").replace_extension(".c"), "a.txt/b.c"); // ticket 4702
|
PATH_TEST_EQ(path("a.txt/b").replace_extension(".c"), "a.txt/b.c"); // ticket 4702
|
||||||
BOOST_TEST(path("foo.txt").replace_extension("exe") == "foo.exe"); // ticket 5118
|
BOOST_TEST(path("foo.txt").replace_extension("exe") == "foo.exe"); // ticket 5118
|
||||||
BOOST_TEST(path("foo.txt").replace_extension(".tar.bz2")
|
BOOST_TEST(path("foo.txt").replace_extension(".tar.bz2") == "foo.tar.bz2"); // ticket 5118
|
||||||
== "foo.tar.bz2"); // ticket 5118
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// make_preferred_tests ------------------------------------------------------------//
|
// make_preferred_tests ------------------------------------------------------------//
|
||||||
|
|
||||||
void make_preferred_tests()
|
void make_preferred_tests()
|
||||||
{
|
{
|
||||||
std::cout << "make_preferred_tests..." << std::endl;
|
std::cout << "make_preferred_tests..." << std::endl;
|
||||||
|
|
||||||
if (platform == "Windows")
|
if (platform == "Windows")
|
||||||
{
|
{
|
||||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native()
|
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native() == path("\\\\abc\\def\\ghi").native());
|
||||||
== path("\\\\abc\\def\\ghi").native());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native()
|
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native() == path("//abc\\def/ghi").native());
|
||||||
== path("//abc\\def/ghi").native());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// lexically_normal_tests ----------------------------------------------------------//
|
// lexically_normal_tests ----------------------------------------------------------//
|
||||||
|
|
||||||
void lexically_normal_tests()
|
void lexically_normal_tests()
|
||||||
{
|
{
|
||||||
std::cout << "lexically_normal_tests..." << std::endl;
|
std::cout << "lexically_normal_tests..." << std::endl;
|
||||||
|
|
||||||
// Note: lexically_lexically_normal() uses /= to build up some results, so these results will
|
// Note: lexically_lexically_normal() uses /= to build up some results, so these results will
|
||||||
@ -1844,14 +1842,14 @@ namespace
|
|||||||
PATH_TEST_EQ(path("../foo").lexically_normal().generic_path(), "../foo");
|
PATH_TEST_EQ(path("../foo").lexically_normal().generic_path(), "../foo");
|
||||||
PATH_TEST_EQ(path("foo/..").lexically_normal().generic_path(), ".");
|
PATH_TEST_EQ(path("foo/..").lexically_normal().generic_path(), ".");
|
||||||
PATH_TEST_EQ(path("foo/../").lexically_normal().generic_path(), "./.");
|
PATH_TEST_EQ(path("foo/../").lexically_normal().generic_path(), "./.");
|
||||||
PATH_TEST_EQ((path("foo") / "..").lexically_normal().generic_path() , ".");
|
PATH_TEST_EQ((path("foo") / "..").lexically_normal().generic_path(), ".");
|
||||||
PATH_TEST_EQ(path("foo/...").lexically_normal().generic_path(), "foo/...");
|
PATH_TEST_EQ(path("foo/...").lexically_normal().generic_path(), "foo/...");
|
||||||
PATH_TEST_EQ(path("foo/.../").lexically_normal().generic_path(), "foo/.../.");
|
PATH_TEST_EQ(path("foo/.../").lexically_normal().generic_path(), "foo/.../.");
|
||||||
PATH_TEST_EQ(path("foo/..bar").lexically_normal().generic_path(), "foo/..bar");
|
PATH_TEST_EQ(path("foo/..bar").lexically_normal().generic_path(), "foo/..bar");
|
||||||
PATH_TEST_EQ(path("../f").lexically_normal().generic_path(), "../f");
|
PATH_TEST_EQ(path("../f").lexically_normal().generic_path(), "../f");
|
||||||
PATH_TEST_EQ(path("/../f").lexically_normal().generic_path(), "/../f");
|
PATH_TEST_EQ(path("/../f").lexically_normal().generic_path(), "/../f");
|
||||||
PATH_TEST_EQ(path("f/..").lexically_normal().generic_path(), ".");
|
PATH_TEST_EQ(path("f/..").lexically_normal().generic_path(), ".");
|
||||||
PATH_TEST_EQ((path("f") / "..").lexically_normal().generic_path() , ".");
|
PATH_TEST_EQ((path("f") / "..").lexically_normal().generic_path(), ".");
|
||||||
PATH_TEST_EQ(path("foo/../..").lexically_normal().generic_path(), "..");
|
PATH_TEST_EQ(path("foo/../..").lexically_normal().generic_path(), "..");
|
||||||
PATH_TEST_EQ(path("foo/../../").lexically_normal().generic_path(), "../.");
|
PATH_TEST_EQ(path("foo/../../").lexically_normal().generic_path(), "../.");
|
||||||
PATH_TEST_EQ(path("foo/../../..").lexically_normal().generic_path(), "../..");
|
PATH_TEST_EQ(path("foo/../../..").lexically_normal().generic_path(), "../..");
|
||||||
@ -1933,13 +1931,13 @@ namespace
|
|||||||
PATH_TEST_EQ(path("c:/../../foo/").lexically_normal(), "../foo/.");
|
PATH_TEST_EQ(path("c:/../../foo/").lexically_normal(), "../foo/.");
|
||||||
PATH_TEST_EQ(path("c:/..foo").lexically_normal(), "c:/..foo");
|
PATH_TEST_EQ(path("c:/..foo").lexically_normal(), "c:/..foo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void odr_use(const path::value_type& c)
|
inline void odr_use(const path::value_type& c)
|
||||||
{
|
{
|
||||||
static const path::value_type dummy = '\0';
|
static const path::value_type dummy = '\0';
|
||||||
BOOST_TEST(&c != &dummy);
|
BOOST_TEST(&c != &dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
@ -1958,9 +1956,7 @@ int cpp_main(int, char*[])
|
|||||||
// The choice of platform is make at runtime rather than compile-time
|
// The choice of platform is make at runtime rather than compile-time
|
||||||
// so that compile errors for all platforms will be detected even though
|
// so that compile errors for all platforms will be detected even though
|
||||||
// only the current platform is runtime tested.
|
// only the current platform is runtime tested.
|
||||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
|
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||||
? "Windows"
|
|
||||||
: "POSIX";
|
|
||||||
std::cout << "Platform is " << platform << '\n';
|
std::cout << "Platform is " << platform << '\n';
|
||||||
|
|
||||||
BOOST_TEST(p1.string() != p3.string());
|
BOOST_TEST(p1.string() != p3.string());
|
||||||
@ -1988,14 +1984,14 @@ int cpp_main(int, char*[])
|
|||||||
|
|
||||||
// verify deprecated names still available
|
// verify deprecated names still available
|
||||||
|
|
||||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
|
|
||||||
p1.branch_path();
|
p1.branch_path();
|
||||||
p1.leaf();
|
p1.leaf();
|
||||||
path p_remove_leaf;
|
path p_remove_leaf;
|
||||||
p_remove_leaf.remove_leaf();
|
p_remove_leaf.remove_leaf();
|
||||||
|
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
std::string s1("//:somestring"); // this used to be treated specially
|
std::string s1("//:somestring"); // this used to be treated specially
|
||||||
|
|
||||||
@ -2008,7 +2004,7 @@ int cpp_main(int, char*[])
|
|||||||
|
|
||||||
// this code, courtesy of David Whetstone, detects a now fixed bug that
|
// this code, courtesy of David Whetstone, detects a now fixed bug that
|
||||||
// derefereced the end iterator (assuming debug build with checked itors)
|
// derefereced the end iterator (assuming debug build with checked itors)
|
||||||
std::vector<char> v1;
|
std::vector< char > v1;
|
||||||
p5.assign(v1.begin(), v1.end());
|
p5.assign(v1.begin(), v1.end());
|
||||||
std::string s2(v1.begin(), v1.end());
|
std::string s2(v1.begin(), v1.end());
|
||||||
PATH_TEST_EQ(p5.string(), s2);
|
PATH_TEST_EQ(p5.string(), s2);
|
||||||
@ -2026,7 +2022,7 @@ int cpp_main(int, char*[])
|
|||||||
BOOST_TEST(path("foo").empty() == false);
|
BOOST_TEST(path("foo").empty() == false);
|
||||||
|
|
||||||
// inserter and extractor tests
|
// inserter and extractor tests
|
||||||
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // bypass VC++ 7.0 and earlier
|
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // bypass VC++ 7.0 and earlier
|
||||||
std::cout << "\nInserter and extractor test...";
|
std::cout << "\nInserter and extractor test...";
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << fs::path("foo/bar") << std::endl;
|
ss << fs::path("foo/bar") << std::endl;
|
||||||
@ -2034,7 +2030,7 @@ int cpp_main(int, char*[])
|
|||||||
ss >> round_trip;
|
ss >> round_trip;
|
||||||
BOOST_TEST(round_trip.string() == "foo/bar");
|
BOOST_TEST(round_trip.string() == "foo/bar");
|
||||||
std::cout << round_trip.string() << "..." << round_trip << " complete\n";
|
std::cout << round_trip.string() << "..." << round_trip << " complete\n";
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
// Check that path constants have definitions
|
// Check that path constants have definitions
|
||||||
// https://svn.boost.org/trac10/ticket/12759
|
// https://svn.boost.org/trac10/ticket/12759
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
|
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/timer/timer.hpp>
|
#include <boost/timer/timer.hpp>
|
||||||
@ -21,9 +21,9 @@
|
|||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# if defined( BOOST_NO_STD_WSTRING )
|
#if defined(BOOST_NO_STD_WSTRING)
|
||||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
|
|
||||||
@ -36,13 +36,12 @@ using namespace boost::timer;
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
boost::int64_t max_cycles;
|
||||||
boost::int64_t max_cycles;
|
|
||||||
|
|
||||||
template <class STD_STRING>
|
template< class STD_STRING >
|
||||||
nanosecond_type time_ctor(const STD_STRING& s)
|
nanosecond_type time_ctor(const STD_STRING& s)
|
||||||
{
|
{
|
||||||
boost::timer::auto_cpu_timer tmr;
|
boost::timer::auto_cpu_timer tmr;
|
||||||
boost::int64_t count = 0;
|
boost::int64_t count = 0;
|
||||||
do
|
do
|
||||||
@ -53,10 +52,10 @@ namespace
|
|||||||
|
|
||||||
boost::timer::cpu_times elapsed = tmr.elapsed();
|
boost::timer::cpu_times elapsed = tmr.elapsed();
|
||||||
return elapsed.user + elapsed.system;
|
return elapsed.user + elapsed.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
nanosecond_type time_loop()
|
nanosecond_type time_loop()
|
||||||
{
|
{
|
||||||
boost::timer::auto_cpu_timer tmr;
|
boost::timer::auto_cpu_timer tmr;
|
||||||
boost::int64_t count = 0;
|
boost::int64_t count = 0;
|
||||||
do
|
do
|
||||||
@ -66,7 +65,7 @@ namespace
|
|||||||
|
|
||||||
boost::timer::cpu_times elapsed = tmr.elapsed();
|
boost::timer::cpu_times elapsed = tmr.elapsed();
|
||||||
return elapsed.user + elapsed.system;
|
return elapsed.user + elapsed.system;
|
||||||
}
|
}
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
@ -94,9 +93,9 @@ int cpp_main(int argc, char* argv[])
|
|||||||
nanosecond_type w = time_ctor(std::wstring(L"/foo/bar/baz"));
|
nanosecond_type w = time_ctor(std::wstring(L"/foo/bar/baz"));
|
||||||
|
|
||||||
if (s > w)
|
if (s > w)
|
||||||
cout << "narrow/wide CPU-time ratio = " << long double(s)/w << endl;
|
cout << "narrow/wide CPU-time ratio = " << long double(s) / w << endl;
|
||||||
else
|
else
|
||||||
cout << "wide/narrow CPU-time ratio = " << long double(w)/s << endl;
|
cout << "wide/narrow CPU-time ratio = " << long double(w) / s << endl;
|
||||||
|
|
||||||
cout << "returning from main()" << endl;
|
cout << "returning from main()" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
// See deprecated_test for tests of deprecated features
|
// See deprecated_test for tests of deprecated features
|
||||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_FILESYSTEM_NO_DEPRECATED
|
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
#ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
# define BOOST_SYSTEM_NO_DEPRECATED
|
#define BOOST_SYSTEM_NO_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
@ -57,26 +57,25 @@ using std::wstring;
|
|||||||
#define CHECK(x) check(x, __FILE__, __LINE__)
|
#define CHECK(x) check(x, __FILE__, __LINE__)
|
||||||
#define PATH_IS(a, b) check_path(a, b, __FILE__, __LINE__)
|
#define PATH_IS(a, b) check_path(a, b, __FILE__, __LINE__)
|
||||||
#define NATIVE_IS(p, s, ws) check_native(p, s, ws, __FILE__, __LINE__)
|
#define NATIVE_IS(p, s, ws) check_native(p, s, ws, __FILE__, __LINE__)
|
||||||
#define IS(a,b) check_equal(a, b, __FILE__, __LINE__)
|
#define IS(a, b) check_equal(a, b, __FILE__, __LINE__)
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(push) // Save warning settings.
|
#pragma warning(push) // Save warning settings.
|
||||||
# pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
|
#pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
|
||||||
|
boost::system::error_code ec;
|
||||||
|
const boost::system::error_code ok;
|
||||||
|
const boost::system::error_code ng(-1, boost::system::system_category());
|
||||||
|
|
||||||
|
std::string platform(BOOST_PLATFORM);
|
||||||
|
|
||||||
|
void check_path(const path& source, const wstring& expected, const char* file, int line)
|
||||||
{
|
{
|
||||||
|
if (source == expected)
|
||||||
boost::system::error_code ec;
|
return;
|
||||||
const boost::system::error_code ok;
|
|
||||||
const boost::system::error_code ng(-1, boost::system::system_category());
|
|
||||||
|
|
||||||
std::string platform(BOOST_PLATFORM);
|
|
||||||
|
|
||||||
void check_path(const path& source,
|
|
||||||
const wstring& expected, const char* file, int line)
|
|
||||||
{
|
|
||||||
if (source == expected) return;
|
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
@ -84,23 +83,23 @@ namespace
|
|||||||
std::wcout << L'(' << line << L"): source.wstring(): \""
|
std::wcout << L'(' << line << L"): source.wstring(): \""
|
||||||
<< source.wstring()
|
<< source.wstring()
|
||||||
<< L"\" != expected: \"" << expected
|
<< L"\" != expected: \"" << expected
|
||||||
<< L"\"\n" ;
|
<< L"\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
void check_native(const path& p,
|
void check_native(const path& p, const string&, const wstring& expected, const char* file, int line)
|
||||||
const string&, const wstring& expected, const char* file, int line)
|
#else
|
||||||
# else
|
void check_native(const path& p, const string& expected, const wstring&, const char* file, int line)
|
||||||
void check_native(const path& p,
|
#endif
|
||||||
const string& expected, const wstring&, const char* file, int line)
|
{
|
||||||
# endif
|
if (p.native() == expected)
|
||||||
{
|
return;
|
||||||
if (p.native() == expected) return;
|
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
std::cout << file << '(' << line << "): native() is not equal expected\n"
|
std::cout << file << '(' << line << "): native() is not equal expected\n"
|
||||||
" native---: " << std::hex;
|
" native---: "
|
||||||
|
<< std::hex;
|
||||||
path::string_type nat(p.native());
|
path::string_type nat(p.native());
|
||||||
for (path::string_type::const_iterator it = nat.begin(); it != nat.end(); ++it)
|
for (path::string_type::const_iterator it = nat.begin(); it != nat.end(); ++it)
|
||||||
std::cout << long(*it) << ' ';
|
std::cout << long(*it) << ' ';
|
||||||
@ -108,13 +107,13 @@ namespace
|
|||||||
for (path::string_type::const_iterator it = expected.begin(); it != expected.end(); ++it)
|
for (path::string_type::const_iterator it = expected.begin(); it != expected.end(); ++it)
|
||||||
std::cout << long(*it) << ' ';
|
std::cout << long(*it) << ' ';
|
||||||
std::cout << std::dec << std::endl;
|
std::cout << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T1, class T2 >
|
template< class T1, class T2 >
|
||||||
void check_equal(const T1& value,
|
void check_equal(const T1& value, const T2& expected, const char* file, int line)
|
||||||
const T2& expected, const char* file, int line)
|
{
|
||||||
{
|
if (value == expected)
|
||||||
if (value == expected) return;
|
return;
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
@ -122,33 +121,40 @@ namespace
|
|||||||
|
|
||||||
std::wcout << L'(' << line << L"): value: \"" << value
|
std::wcout << L'(' << line << L"): value: \"" << value
|
||||||
<< L"\" != expected: \"" << expected
|
<< L"\" != expected: \"" << expected
|
||||||
<< L"\"\n" ;
|
<< L"\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(bool ok_, const char* file, int line)
|
void check(bool ok_, const char* file, int line)
|
||||||
{
|
{
|
||||||
if (ok_) return;
|
if (ok_)
|
||||||
|
return;
|
||||||
|
|
||||||
++::boost::detail::test_errors();
|
++::boost::detail::test_errors();
|
||||||
|
|
||||||
std::cout << file << '(' << line << "): test failed\n";
|
std::cout << file << '(' << line << "): test failed\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
string s("string");
|
string s("string");
|
||||||
wstring ws(L"wstring");
|
wstring ws(L"wstring");
|
||||||
std::list<char> l; // see main() for initialization to s, t, r, i, n, g
|
std::list< char > l; // see main() for initialization to s, t, r, i, n, g
|
||||||
std::list<wchar_t> wl; // see main() for initialization to w, s, t, r, i, n, g
|
std::list< wchar_t > wl; // see main() for initialization to w, s, t, r, i, n, g
|
||||||
std::vector<char> v; // see main() for initialization to f, u, z
|
std::vector< char > v; // see main() for initialization to f, u, z
|
||||||
std::vector<wchar_t> wv; // see main() for initialization to w, f, u, z
|
std::vector< wchar_t > wv; // see main() for initialization to w, f, u, z
|
||||||
|
|
||||||
class Base {};
|
class Base
|
||||||
class Derived : public Base {};
|
{
|
||||||
void fun(const boost::shared_ptr< Base >&) {}
|
};
|
||||||
|
class Derived : public Base
|
||||||
|
{
|
||||||
|
};
|
||||||
|
void fun(const boost::shared_ptr< Base >&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// test_constructors ---------------------------------------------------------------//
|
// test_constructors ---------------------------------------------------------------//
|
||||||
|
|
||||||
void test_constructors()
|
void test_constructors()
|
||||||
{
|
{
|
||||||
std::cout << "testing constructors..." << std::endl;
|
std::cout << "testing constructors..." << std::endl;
|
||||||
|
|
||||||
path x0; // default constructor
|
path x0; // default constructor
|
||||||
@ -212,11 +218,11 @@ namespace
|
|||||||
PATH_IS(x9, L"wstring");
|
PATH_IS(x9, L"wstring");
|
||||||
BOOST_TEST_EQ(x9.native().size(), 7U);
|
BOOST_TEST_EQ(x9.native().size(), 7U);
|
||||||
|
|
||||||
path x8nc(const_cast<char*>(s.c_str())); // char* null terminated
|
path x8nc(const_cast< char* >(s.c_str())); // char* null terminated
|
||||||
PATH_IS(x8nc, L"string");
|
PATH_IS(x8nc, L"string");
|
||||||
BOOST_TEST_EQ(x8nc.native().size(), 6U);
|
BOOST_TEST_EQ(x8nc.native().size(), 6U);
|
||||||
|
|
||||||
path x9nc(const_cast<wchar_t*>(ws.c_str())); // wchar_t* null terminated
|
path x9nc(const_cast< wchar_t* >(ws.c_str())); // wchar_t* null terminated
|
||||||
PATH_IS(x9nc, L"wstring");
|
PATH_IS(x9nc, L"wstring");
|
||||||
BOOST_TEST_EQ(x9nc.native().size(), 7U);
|
BOOST_TEST_EQ(x9nc.native().size(), 7U);
|
||||||
|
|
||||||
@ -232,18 +238,18 @@ namespace
|
|||||||
// easy-to-make coding errors
|
// easy-to-make coding errors
|
||||||
// path e1(x0, path::codecvt()); // fails to compile, and that is OK
|
// path e1(x0, path::codecvt()); // fails to compile, and that is OK
|
||||||
|
|
||||||
boost::shared_ptr< Derived > pDerived( new Derived() );
|
boost::shared_ptr< Derived > pDerived(new Derived());
|
||||||
fun( pDerived ); // tests constructor member template enable_if working correctly;
|
fun(pDerived); // tests constructor member template enable_if working correctly;
|
||||||
// will fail to compile if enable_if not taking path off the table
|
// will fail to compile if enable_if not taking path off the table
|
||||||
}
|
}
|
||||||
|
|
||||||
path x;
|
path x;
|
||||||
path y;
|
path y;
|
||||||
|
|
||||||
// test_assignments ----------------------------------------------------------------//
|
// test_assignments ----------------------------------------------------------------//
|
||||||
|
|
||||||
void test_assignments()
|
void test_assignments()
|
||||||
{
|
{
|
||||||
std::cout << "testing assignments..." << std::endl;
|
std::cout << "testing assignments..." << std::endl;
|
||||||
|
|
||||||
x = path("yet another path"); // another path
|
x = path("yet another path"); // another path
|
||||||
@ -277,15 +283,15 @@ namespace
|
|||||||
|
|
||||||
x = ws.c_str(); // const wchar_t* null terminated
|
x = ws.c_str(); // const wchar_t* null terminated
|
||||||
PATH_IS(x, L"wstring");
|
PATH_IS(x, L"wstring");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_move_construction_and_assignment -------------------------------------------//
|
// test_move_construction_and_assignment -------------------------------------------//
|
||||||
|
|
||||||
void test_move_construction_and_assignment()
|
void test_move_construction_and_assignment()
|
||||||
{
|
{
|
||||||
std::cout << "testing move_construction_and_assignment..." << std::endl;
|
std::cout << "testing move_construction_and_assignment..." << std::endl;
|
||||||
|
|
||||||
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
path from("long enough to avoid small object optimization");
|
path from("long enough to avoid small object optimization");
|
||||||
path to(std::move(from));
|
path to(std::move(from));
|
||||||
BOOST_TEST(to == "long enough to avoid small object optimization");
|
BOOST_TEST(to == "long enough to avoid small object optimization");
|
||||||
@ -298,24 +304,22 @@ namespace
|
|||||||
BOOST_TEST(to2 == "long enough to avoid small object optimization");
|
BOOST_TEST(to2 == "long enough to avoid small object optimization");
|
||||||
if (!from2.empty())
|
if (!from2.empty())
|
||||||
cout << "Note: move assignment did not result in empty rhs path" << endl;
|
cout << "Note: move assignment did not result in empty rhs path" << endl;
|
||||||
# else
|
#else
|
||||||
std::cout <<
|
std::cout << "Test skipped because compiler does not support move semantics" << std::endl;
|
||||||
"Test skipped because compiler does not support move semantics" << std::endl;
|
#endif
|
||||||
# endif
|
}
|
||||||
|
|
||||||
}
|
// test_appends --------------------------------------------------------------------//
|
||||||
|
|
||||||
// test_appends --------------------------------------------------------------------//
|
void test_appends()
|
||||||
|
{
|
||||||
void test_appends()
|
|
||||||
{
|
|
||||||
std::cout << "testing appends..." << std::endl;
|
std::cout << "testing appends..." << std::endl;
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
# define BOOST_FS_FOO L"/foo\\"
|
#define BOOST_FS_FOO L"/foo\\"
|
||||||
# else // POSIX paths
|
#else // POSIX paths
|
||||||
# define BOOST_FS_FOO L"/foo/"
|
#define BOOST_FS_FOO L"/foo/"
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
x = "/foo";
|
x = "/foo";
|
||||||
x /= path(""); // empty path
|
x /= path(""); // empty path
|
||||||
@ -368,12 +372,12 @@ namespace
|
|||||||
x = "/foo";
|
x = "/foo";
|
||||||
x /= ws.c_str(); // const wchar_t* null terminated
|
x /= ws.c_str(); // const wchar_t* null terminated
|
||||||
PATH_IS(x, BOOST_FS_FOO L"wstring");
|
PATH_IS(x, BOOST_FS_FOO L"wstring");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_concats --------------------------------------------------------------------//
|
// test_concats --------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_concats()
|
void test_concats()
|
||||||
{
|
{
|
||||||
std::cout << "testing concats..." << std::endl;
|
std::cout << "testing concats..." << std::endl;
|
||||||
|
|
||||||
x = "/foo";
|
x = "/foo";
|
||||||
@ -435,12 +439,12 @@ namespace
|
|||||||
x = "foo-";
|
x = "foo-";
|
||||||
x += L'x'; // wchar
|
x += L'x'; // wchar
|
||||||
PATH_IS(x, L"foo-x");
|
PATH_IS(x, L"foo-x");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_observers ------------------------------------------------------------------//
|
// test_observers ------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_observers()
|
void test_observers()
|
||||||
{
|
{
|
||||||
std::cout << "testing observers..." << std::endl;
|
std::cout << "testing observers..." << std::endl;
|
||||||
|
|
||||||
path p0("abc");
|
path p0("abc");
|
||||||
@ -456,7 +460,7 @@ namespace
|
|||||||
CHECK(p0.native().size() == 0);
|
CHECK(p0.native().size() == 0);
|
||||||
CHECK(p0.size() == 0);
|
CHECK(p0.size() == 0);
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
|
|
||||||
path p("abc\\def/ghi");
|
path p("abc\\def/ghi");
|
||||||
|
|
||||||
@ -469,11 +473,11 @@ namespace
|
|||||||
CHECK(p.generic_string() == "abc/def/ghi");
|
CHECK(p.generic_string() == "abc/def/ghi");
|
||||||
CHECK(p.generic_wstring() == L"abc/def/ghi");
|
CHECK(p.generic_wstring() == L"abc/def/ghi");
|
||||||
|
|
||||||
CHECK(p.generic_string<string>() == "abc/def/ghi");
|
CHECK(p.generic_string< string >() == "abc/def/ghi");
|
||||||
CHECK(p.generic_string<wstring>() == L"abc/def/ghi");
|
CHECK(p.generic_string< wstring >() == L"abc/def/ghi");
|
||||||
CHECK(p.generic_string<path::string_type>() == L"abc/def/ghi");
|
CHECK(p.generic_string< path::string_type >() == L"abc/def/ghi");
|
||||||
|
|
||||||
# else // BOOST_POSIX_API
|
#else // BOOST_POSIX_API
|
||||||
|
|
||||||
path p("abc\\def/ghi");
|
path p("abc\\def/ghi");
|
||||||
|
|
||||||
@ -486,26 +490,26 @@ namespace
|
|||||||
CHECK(p.generic_string() == "abc\\def/ghi");
|
CHECK(p.generic_string() == "abc\\def/ghi");
|
||||||
CHECK(p.generic_wstring() == L"abc\\def/ghi");
|
CHECK(p.generic_wstring() == L"abc\\def/ghi");
|
||||||
|
|
||||||
CHECK(p.generic_string<string>() == "abc\\def/ghi");
|
CHECK(p.generic_string< string >() == "abc\\def/ghi");
|
||||||
CHECK(p.generic_string<wstring>() == L"abc\\def/ghi");
|
CHECK(p.generic_string< wstring >() == L"abc\\def/ghi");
|
||||||
CHECK(p.generic_string<path::string_type>() == "abc\\def/ghi");
|
CHECK(p.generic_string< path::string_type >() == "abc\\def/ghi");
|
||||||
|
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_relationals ----------------------------------------------------------------//
|
// test_relationals ----------------------------------------------------------------//
|
||||||
|
|
||||||
void test_relationals()
|
void test_relationals()
|
||||||
{
|
{
|
||||||
std::cout << "testing relationals..." << std::endl;
|
std::cout << "testing relationals..." << std::endl;
|
||||||
|
|
||||||
boost::hash<path> hash;
|
boost::hash< path > hash;
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
// this is a critical use case to meet user expectations
|
// this is a critical use case to meet user expectations
|
||||||
CHECK(path("c:\\abc") == path("c:/abc"));
|
CHECK(path("c:\\abc") == path("c:/abc"));
|
||||||
CHECK(hash(path("c:\\abc")) == hash(path("c:/abc")));
|
CHECK(hash(path("c:\\abc")) == hash(path("c:/abc")));
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
const path p("bar");
|
const path p("bar");
|
||||||
const path p2("baz");
|
const path p2("baz");
|
||||||
@ -554,10 +558,10 @@ namespace
|
|||||||
CHECK(p2 >= p);
|
CHECK(p2 >= p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_inserter_and_extractor -----------------------------------------------------//
|
// test_inserter_and_extractor -----------------------------------------------------//
|
||||||
|
|
||||||
void test_inserter_and_extractor()
|
void test_inserter_and_extractor()
|
||||||
{
|
{
|
||||||
std::cout << "testing inserter and extractor..." << std::endl;
|
std::cout << "testing inserter and extractor..." << std::endl;
|
||||||
|
|
||||||
path p1("foo bar"); // verify space in path roundtrips per ticket #3863
|
path p1("foo bar"); // verify space in path roundtrips per ticket #3863
|
||||||
@ -579,12 +583,12 @@ namespace
|
|||||||
wss << wp1;
|
wss << wp1;
|
||||||
wss >> wp2;
|
wss >> wp2;
|
||||||
CHECK(wp1 == wp2);
|
CHECK(wp1 == wp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_other_non_members ----------------------------------------------------------//
|
// test_other_non_members ----------------------------------------------------------//
|
||||||
|
|
||||||
void test_other_non_members()
|
void test_other_non_members()
|
||||||
{
|
{
|
||||||
std::cout << "testing other_non_members..." << std::endl;
|
std::cout << "testing other_non_members..." << std::endl;
|
||||||
|
|
||||||
path p1("foo");
|
path p1("foo");
|
||||||
@ -624,17 +628,17 @@ namespace
|
|||||||
CHECK(path("foo/").filename_is_dot());
|
CHECK(path("foo/").filename_is_dot());
|
||||||
CHECK(path("/").filename() == path("/"));
|
CHECK(path("/").filename() == path("/"));
|
||||||
CHECK(!path("/").filename_is_dot());
|
CHECK(!path("/").filename_is_dot());
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
CHECK(path("c:.").filename() == path("."));
|
CHECK(path("c:.").filename() == path("."));
|
||||||
CHECK(path("c:.").filename_is_dot());
|
CHECK(path("c:.").filename_is_dot());
|
||||||
CHECK(path("c:/").filename() == path("/"));
|
CHECK(path("c:/").filename() == path("/"));
|
||||||
CHECK(!path("c:\\").filename_is_dot());
|
CHECK(!path("c:\\").filename_is_dot());
|
||||||
# else
|
#else
|
||||||
CHECK(path("c:.").filename() == path("c:."));
|
CHECK(path("c:.").filename() == path("c:."));
|
||||||
CHECK(!path("c:.").filename_is_dot());
|
CHECK(!path("c:.").filename_is_dot());
|
||||||
CHECK(path("c:/").filename() == path("."));
|
CHECK(path("c:/").filename() == path("."));
|
||||||
CHECK(path("c:/").filename_is_dot());
|
CHECK(path("c:/").filename_is_dot());
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
// check that the implementation code to make the edge cases above work right
|
// check that the implementation code to make the edge cases above work right
|
||||||
// doesn't cause some non-edge cases to fail
|
// doesn't cause some non-edge cases to fail
|
||||||
@ -651,7 +655,7 @@ namespace
|
|||||||
std::cout << path("/foo.").filename_is_dot(); // outputs 0
|
std::cout << path("/foo.").filename_is_dot(); // outputs 0
|
||||||
std::cout << path("..").filename_is_dot(); // outputs 0
|
std::cout << path("..").filename_is_dot(); // outputs 0
|
||||||
cout << std::endl;
|
cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // test_modifiers ------------------------------------------------------------------//
|
// // test_modifiers ------------------------------------------------------------------//
|
||||||
//
|
//
|
||||||
@ -661,10 +665,10 @@ namespace
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// test_iterators ------------------------------------------------------------------//
|
// test_iterators ------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_iterators()
|
void test_iterators()
|
||||||
{
|
{
|
||||||
std::cout << "testing iterators..." << std::endl;
|
std::cout << "testing iterators..." << std::endl;
|
||||||
|
|
||||||
path p1;
|
path p1;
|
||||||
@ -687,12 +691,12 @@ namespace
|
|||||||
CHECK(*++it == "bar");
|
CHECK(*++it == "bar");
|
||||||
CHECK(*++it == "baz");
|
CHECK(*++it == "baz");
|
||||||
CHECK(++it == p3.end());
|
CHECK(++it == p3.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_reverse_iterators ----------------------------------------------------------//
|
// test_reverse_iterators ----------------------------------------------------------//
|
||||||
|
|
||||||
void test_reverse_iterators()
|
void test_reverse_iterators()
|
||||||
{
|
{
|
||||||
std::cout << "testing reverse_iterators..." << std::endl;
|
std::cout << "testing reverse_iterators..." << std::endl;
|
||||||
|
|
||||||
path p1;
|
path p1;
|
||||||
@ -715,12 +719,12 @@ namespace
|
|||||||
CHECK(*++it == "bar");
|
CHECK(*++it == "bar");
|
||||||
CHECK(*++it == "foo");
|
CHECK(*++it == "foo");
|
||||||
CHECK(++it == p3.rend());
|
CHECK(++it == p3.rend());
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_modifiers ------------------------------------------------------------------//
|
// test_modifiers ------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_modifiers()
|
void test_modifiers()
|
||||||
{
|
{
|
||||||
std::cout << "testing modifiers..." << std::endl;
|
std::cout << "testing modifiers..." << std::endl;
|
||||||
|
|
||||||
CHECK(path("").remove_filename() == "");
|
CHECK(path("").remove_filename() == "");
|
||||||
@ -736,12 +740,12 @@ namespace
|
|||||||
BOOST_TEST_EQ(path("/..").remove_filename(), path("/"));
|
BOOST_TEST_EQ(path("/..").remove_filename(), path("/"));
|
||||||
BOOST_TEST_EQ(path("//").remove_filename(), path(""));
|
BOOST_TEST_EQ(path("//").remove_filename(), path(""));
|
||||||
BOOST_TEST_EQ(path("////").remove_filename(), path(""));
|
BOOST_TEST_EQ(path("////").remove_filename(), path(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_decompositions -------------------------------------------------------------//
|
// test_decompositions -------------------------------------------------------------//
|
||||||
|
|
||||||
void test_decompositions()
|
void test_decompositions()
|
||||||
{
|
{
|
||||||
std::cout << "testing decompositions..." << std::endl;
|
std::cout << "testing decompositions..." << std::endl;
|
||||||
|
|
||||||
CHECK(path("").root_name().string() == "");
|
CHECK(path("").root_name().string() == "");
|
||||||
@ -764,9 +768,9 @@ namespace
|
|||||||
CHECK(path("//netname").root_path().string() == "//netname");
|
CHECK(path("//netname").root_path().string() == "//netname");
|
||||||
CHECK(path("//netname/foo").root_path().string() == "//netname/");
|
CHECK(path("//netname/foo").root_path().string() == "//netname/");
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
CHECK(path("c:/foo").root_path().string() == "c:/");
|
CHECK(path("c:/foo").root_path().string() == "c:/");
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
CHECK(path("").relative_path().string() == "");
|
CHECK(path("").relative_path().string() == "");
|
||||||
CHECK(path("/").relative_path().string() == "");
|
CHECK(path("/").relative_path().string() == "");
|
||||||
@ -785,12 +789,12 @@ namespace
|
|||||||
CHECK(path("foo.bar.baz.tar.bz2").extension().string() == ".bz2");
|
CHECK(path("foo.bar.baz.tar.bz2").extension().string() == ".bz2");
|
||||||
CHECK(path("/foo/bar/baz.zoo").extension().string() == ".zoo");
|
CHECK(path("/foo/bar/baz.zoo").extension().string() == ".zoo");
|
||||||
CHECK(path("/foo/bar.woo/baz").extension().string() == "");
|
CHECK(path("/foo/bar.woo/baz").extension().string() == "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_queries --------------------------------------------------------------------//
|
// test_queries --------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_queries()
|
void test_queries()
|
||||||
{
|
{
|
||||||
std::cout << "testing queries..." << std::endl;
|
std::cout << "testing queries..." << std::endl;
|
||||||
|
|
||||||
path p1("");
|
path p1("");
|
||||||
@ -819,13 +823,12 @@ namespace
|
|||||||
CHECK(p2.has_extension());
|
CHECK(p2.has_extension());
|
||||||
CHECK(p2.is_absolute());
|
CHECK(p2.is_absolute());
|
||||||
CHECK(!p2.is_relative());
|
CHECK(!p2.is_relative());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// test_imbue_locale ---------------------------------------------------------------//
|
||||||
|
|
||||||
// test_imbue_locale ---------------------------------------------------------------//
|
void test_imbue_locale()
|
||||||
|
{
|
||||||
void test_imbue_locale()
|
|
||||||
{
|
|
||||||
std::cout << "testing imbue locale..." << std::endl;
|
std::cout << "testing imbue locale..." << std::endl;
|
||||||
|
|
||||||
// weak test case for before/after states since we don't know what characters the
|
// weak test case for before/after states since we don't know what characters the
|
||||||
@ -853,15 +856,15 @@ namespace
|
|||||||
CHECK(before == after);
|
CHECK(before == after);
|
||||||
|
|
||||||
std::cout << " locale testing complete" << std::endl;
|
std::cout << " locale testing complete" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_codecvt_argument -----------------------------------------------------------//
|
// test_codecvt_argument -----------------------------------------------------------//
|
||||||
|
|
||||||
void test_codecvt_argument()
|
void test_codecvt_argument()
|
||||||
{
|
{
|
||||||
std::cout << "testing codecvt arguments..." << std::endl;
|
std::cout << "testing codecvt arguments..." << std::endl;
|
||||||
|
|
||||||
const char * c1 = "a1";
|
const char* c1 = "a1";
|
||||||
const std::string s1(c1);
|
const std::string s1(c1);
|
||||||
const std::wstring ws1(L"b2"); // off-by-one mimics test_codecvt
|
const std::wstring ws1(L"b2"); // off-by-one mimics test_codecvt
|
||||||
const std::string s2("y8");
|
const std::string s2("y8");
|
||||||
@ -894,7 +897,7 @@ namespace
|
|||||||
// assigns
|
// assigns
|
||||||
p1.clear();
|
p1.clear();
|
||||||
std::cout << " assigns test " << ++t << std::endl;
|
std::cout << " assigns test " << ++t << std::endl;
|
||||||
p1.assign(s1,cvt);
|
p1.assign(s1, cvt);
|
||||||
NATIVE_IS(p1, s1, ws1);
|
NATIVE_IS(p1, s1, ws1);
|
||||||
p1.clear();
|
p1.clear();
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
@ -905,7 +908,7 @@ namespace
|
|||||||
// appends
|
// appends
|
||||||
p1.clear();
|
p1.clear();
|
||||||
std::cout << " appends test " << ++t << std::endl;
|
std::cout << " appends test " << ++t << std::endl;
|
||||||
p1.append(s1,cvt);
|
p1.append(s1, cvt);
|
||||||
NATIVE_IS(p1, s1, ws1);
|
NATIVE_IS(p1, s1, ws1);
|
||||||
p1.clear();
|
p1.clear();
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
@ -915,31 +918,31 @@ namespace
|
|||||||
|
|
||||||
// native observers
|
// native observers
|
||||||
std::cout << " native observers test " << ++t << std::endl;
|
std::cout << " native observers test " << ++t << std::endl;
|
||||||
CHECK(p.string<std::string>(cvt) == s1);
|
CHECK(p.string< std::string >(cvt) == s1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.string(cvt) == s1);
|
CHECK(p.string(cvt) == s1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.string<std::wstring>(cvt) == ws1);
|
CHECK(p.string< std::wstring >(cvt) == ws1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.wstring(cvt) == ws1);
|
CHECK(p.wstring(cvt) == ws1);
|
||||||
|
|
||||||
// generic observers
|
// generic observers
|
||||||
std::cout << " generic observers test " << ++t << std::endl;
|
std::cout << " generic observers test " << ++t << std::endl;
|
||||||
CHECK(p.generic_string<std::string>(cvt) == s1);
|
CHECK(p.generic_string< std::string >(cvt) == s1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.generic_string(cvt) == s1);
|
CHECK(p.generic_string(cvt) == s1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.generic_string<std::wstring>(cvt) == ws1);
|
CHECK(p.generic_string< std::wstring >(cvt) == ws1);
|
||||||
std::cout << " test " << ++t << std::endl;
|
std::cout << " test " << ++t << std::endl;
|
||||||
CHECK(p.generic_wstring(cvt) == ws1);
|
CHECK(p.generic_wstring(cvt) == ws1);
|
||||||
|
|
||||||
std::cout << " codecvt arguments testing complete" << std::endl;
|
std::cout << " codecvt arguments testing complete" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_overloads ------------------------------------------------------------------//
|
// test_overloads ------------------------------------------------------------------//
|
||||||
|
|
||||||
void test_overloads()
|
void test_overloads()
|
||||||
{
|
{
|
||||||
std::cout << "testing overloads..." << std::endl;
|
std::cout << "testing overloads..." << std::endl;
|
||||||
std::string sto("hello");
|
std::string sto("hello");
|
||||||
const char a[] = "goodbye";
|
const char a[] = "goodbye";
|
||||||
@ -954,52 +957,54 @@ namespace
|
|||||||
path wp2(wsto.c_str());
|
path wp2(wsto.c_str());
|
||||||
path wp3(wa);
|
path wp3(wa);
|
||||||
path wp4(L"foo");
|
path wp4(L"foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
// test_error_handling -------------------------------------------------------------//
|
||||||
|
|
||||||
|
class error_codecvt :
|
||||||
|
public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit error_codecvt() :
|
||||||
|
std::codecvt< wchar_t, char, std::mbstate_t >()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// test_error_handling -------------------------------------------------------------//
|
protected:
|
||||||
|
|
||||||
class error_codecvt
|
|
||||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit error_codecvt()
|
|
||||||
: std::codecvt<wchar_t, char, std::mbstate_t>() {}
|
|
||||||
protected:
|
|
||||||
|
|
||||||
virtual bool do_always_noconv() const throw() { return false; }
|
virtual bool do_always_noconv() const throw() { return false; }
|
||||||
virtual int do_encoding() const throw() { return 0; }
|
virtual int do_encoding() const throw() { return 0; }
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_in(std::mbstate_t&,
|
virtual std::codecvt_base::result do_in(std::mbstate_t&, const char*, const char*, const char*&, wchar_t*, wchar_t*, wchar_t*&) const
|
||||||
const char*, const char*, const char*&,
|
|
||||||
wchar_t*, wchar_t*, wchar_t*&) const
|
|
||||||
{
|
{
|
||||||
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
||||||
if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
|
if (r == std::codecvt_base::partial)
|
||||||
else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
|
r = std::codecvt_base::error;
|
||||||
else r = std::codecvt_base::partial;
|
else if (r == std::codecvt_base::error)
|
||||||
|
r = std::codecvt_base::noconv;
|
||||||
|
else
|
||||||
|
r = std::codecvt_base::partial;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_out(std::mbstate_t &,
|
virtual std::codecvt_base::result do_out(std::mbstate_t&, const wchar_t*, const wchar_t*, const wchar_t*&, char*, char*, char*&) const
|
||||||
const wchar_t*, const wchar_t*, const wchar_t*&,
|
|
||||||
char*, char*, char*&) const
|
|
||||||
{
|
{
|
||||||
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
||||||
if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
|
if (r == std::codecvt_base::partial)
|
||||||
else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
|
r = std::codecvt_base::error;
|
||||||
else r = std::codecvt_base::partial;
|
else if (r == std::codecvt_base::error)
|
||||||
|
r = std::codecvt_base::noconv;
|
||||||
|
else
|
||||||
|
r = std::codecvt_base::partial;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_unshift(std::mbstate_t&,
|
virtual std::codecvt_base::result do_unshift(std::mbstate_t&, char*, char*, char*&) const { return ok; }
|
||||||
char*, char*, char* &) const { return ok; }
|
virtual int do_length(std::mbstate_t&, const char*, const char*, std::size_t) const { return 0; }
|
||||||
virtual int do_length(std::mbstate_t &,
|
virtual int do_max_length() const throw() { return 0; }
|
||||||
const char*, const char*, std::size_t) const { return 0; }
|
};
|
||||||
virtual int do_max_length() const throw () { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_error_handling()
|
void test_error_handling()
|
||||||
{
|
{
|
||||||
std::cout << "testing error handling..." << std::endl;
|
std::cout << "testing error handling..." << std::endl;
|
||||||
|
|
||||||
std::locale global_loc = std::locale();
|
std::locale global_loc = std::locale();
|
||||||
@ -1010,60 +1015,75 @@ namespace
|
|||||||
// These tests rely on a path constructor that fails in the locale conversion.
|
// These tests rely on a path constructor that fails in the locale conversion.
|
||||||
// Thus construction has to call codecvt. Force that by using a narrow string
|
// Thus construction has to call codecvt. Force that by using a narrow string
|
||||||
// for Windows, and a wide string for POSIX.
|
// for Windows, and a wide string for POSIX.
|
||||||
# ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
# define STRING_FOO_ "foo"
|
#define STRING_FOO_ "foo"
|
||||||
# else
|
#else
|
||||||
# define STRING_FOO_ L"foo"
|
#define STRING_FOO_ L"foo"
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << " testing std::codecvt_base::partial error..." << std::endl;
|
std::cout << " testing std::codecvt_base::partial error..." << std::endl;
|
||||||
bool exception_thrown (false);
|
bool exception_thrown(false);
|
||||||
try { path(STRING_FOO_); }
|
try
|
||||||
catch (const bs::system_error & ex)
|
{
|
||||||
|
path(STRING_FOO_);
|
||||||
|
}
|
||||||
|
catch (const bs::system_error& ex)
|
||||||
{
|
{
|
||||||
exception_thrown = true;
|
exception_thrown = true;
|
||||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial,
|
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial, fs::codecvt_error_category()));
|
||||||
fs::codecvt_error_category()));
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||||
}
|
}
|
||||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
|
||||||
BOOST_TEST(exception_thrown);
|
BOOST_TEST(exception_thrown);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << " testing std::codecvt_base::error error..." << std::endl;
|
std::cout << " testing std::codecvt_base::error error..." << std::endl;
|
||||||
bool exception_thrown (false);
|
bool exception_thrown(false);
|
||||||
try { path(STRING_FOO_); }
|
try
|
||||||
catch (const bs::system_error & ex)
|
{
|
||||||
|
path(STRING_FOO_);
|
||||||
|
}
|
||||||
|
catch (const bs::system_error& ex)
|
||||||
{
|
{
|
||||||
exception_thrown = true;
|
exception_thrown = true;
|
||||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error,
|
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error, fs::codecvt_error_category()));
|
||||||
fs::codecvt_error_category()));
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||||
}
|
}
|
||||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
|
||||||
BOOST_TEST(exception_thrown);
|
BOOST_TEST(exception_thrown);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << " testing std::codecvt_base::noconv error..." << std::endl;
|
std::cout << " testing std::codecvt_base::noconv error..." << std::endl;
|
||||||
bool exception_thrown (false);
|
bool exception_thrown(false);
|
||||||
try { path(STRING_FOO_); }
|
try
|
||||||
catch (const bs::system_error & ex)
|
{
|
||||||
|
path(STRING_FOO_);
|
||||||
|
}
|
||||||
|
catch (const bs::system_error& ex)
|
||||||
{
|
{
|
||||||
exception_thrown = true;
|
exception_thrown = true;
|
||||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv,
|
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv, fs::codecvt_error_category()));
|
||||||
fs::codecvt_error_category()));
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||||
}
|
}
|
||||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
|
||||||
BOOST_TEST(exception_thrown);
|
BOOST_TEST(exception_thrown);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << " restoring original locale ..." << std::endl;
|
std::cout << " restoring original locale ..." << std::endl;
|
||||||
path::imbue(old_loc);
|
path::imbue(old_loc);
|
||||||
std::cout << " testing error handling complete" << std::endl;
|
std::cout << " testing error handling complete" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if 0
|
#if 0
|
||||||
|
|
||||||
// // test_locales --------------------------------------------------------------------//
|
// // test_locales --------------------------------------------------------------------//
|
||||||
//
|
//
|
||||||
@ -1073,63 +1093,59 @@ namespace
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// test_user_supplied_type ---------------------------------------------------------//
|
// test_user_supplied_type ---------------------------------------------------------//
|
||||||
|
|
||||||
typedef std::basic_string<int> user_string;
|
typedef std::basic_string<int> user_string;
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
namespace boost
|
namespace boost {
|
||||||
{
|
namespace filesystem {
|
||||||
namespace filesystem
|
namespace path_traits {
|
||||||
{
|
|
||||||
namespace path_traits
|
|
||||||
{
|
|
||||||
template<> struct is_iterator<const user_string::value_type *> { static const bool value = true; };
|
|
||||||
template<> struct is_iterator<user_string::value_type *> { static const bool value = true; };
|
|
||||||
template<> struct is_iterator<user_string::iterator> { static const bool value = true; };
|
|
||||||
template<> struct is_iterator<user_string::const_iterator> { static const bool value = true; };
|
|
||||||
template<> struct is_container<user_string> { static const bool value = true; };
|
|
||||||
|
|
||||||
template<>
|
template<> struct is_iterator< const user_string::value_type* > { static const bool value = true; };
|
||||||
void append<user_string::value_type>(const user_string::value_type * begin,
|
template<> struct is_iterator< user_string::value_type* > { static const bool value = true; };
|
||||||
const user_string::value_type * end, string_type & target, system::error_code & ec)
|
template<> struct is_iterator< user_string::iterator > { static const bool value = true; };
|
||||||
{
|
template<> struct is_iterator< user_string::const_iterator > { static const bool value = true; };
|
||||||
|
template<> struct is_container< user_string > { static const bool value = true; };
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void append< user_string::value_type >(const user_string::value_type* begin,
|
||||||
|
const user_string::value_type* end, string_type& target, system::error_code& ec)
|
||||||
|
{
|
||||||
for (; begin != end && *begin; ++begin)
|
for (; begin != end && *begin; ++begin)
|
||||||
target += *begin + 1; // change so that results distinguishable from char cvts
|
target += *begin + 1; // change so that results distinguishable from char cvts
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
// This specialization shouldn't be needed, and VC++, Intel, and others work
|
// This specialization shouldn't be needed, and VC++, Intel, and others work
|
||||||
// fine without it. But gcc 4.3.2, and presumably other versions, need it.
|
// fine without it. But gcc 4.3.2, and presumably other versions, need it.
|
||||||
template<>
|
template<>
|
||||||
void append<user_string::value_type>(const user_string::value_type * begin,
|
void append< user_string::value_type >(const user_string::value_type* begin,
|
||||||
string_type & target, system::error_code & ec)
|
string_type& target, system::error_code& ec)
|
||||||
{
|
{
|
||||||
path_traits::append<user_string::value_type>(begin,
|
path_traits::append<user_string::value_type>(begin,
|
||||||
static_cast<const user_string::value_type *>(0), target, ec);
|
static_cast<const user_string::value_type *>(0), target, ec);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
user_string convert<user_string>(const string_type & source,
|
user_string convert< user_string >(string_type const& source, system::error_code& ec)
|
||||||
system::error_code & ec)
|
{
|
||||||
{
|
|
||||||
user_string temp;
|
user_string temp;
|
||||||
for (string_type::const_iterator it = source.begin();
|
for (string_type::const_iterator it = source.begin(); it != source.end(); ++it)
|
||||||
it != source.end(); ++it)
|
|
||||||
temp += *it - 1;
|
temp += *it - 1;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
} // namespace path_traits
|
|
||||||
|
} // namespace path_traits
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
|
|
||||||
void test_user_supplied_type()
|
void test_user_supplied_type()
|
||||||
{
|
{
|
||||||
std::cout << "testing user supplied type..." << std::endl;
|
std::cout << "testing user supplied type..." << std::endl;
|
||||||
|
|
||||||
user_string::value_type usr_c_str[] = { 'a', 'b', 'c', 0 };
|
user_string::value_type usr_c_str[] = { 'a', 'b', 'c', 0 };
|
||||||
@ -1140,12 +1156,12 @@ namespace
|
|||||||
CHECK(p1 == "bcd");
|
CHECK(p1 == "bcd");
|
||||||
user_string s1(p1.string<user_string>());
|
user_string s1(p1.string<user_string>());
|
||||||
CHECK(s1 == usr);
|
CHECK(s1 == usr);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
inline const char* macro_value(const char* name, const char* value)
|
inline const char* macro_value(const char* name, const char* value)
|
||||||
{
|
{
|
||||||
static const char* no_value = "[no value]";
|
static const char* no_value = "[no value]";
|
||||||
static const char* not_defined = "[not defined]";
|
static const char* not_defined = "[not defined]";
|
||||||
|
|
||||||
@ -1158,10 +1174,8 @@ namespace
|
|||||||
//}
|
//}
|
||||||
//return not_defined;
|
//return not_defined;
|
||||||
|
|
||||||
return 0 == strcmp(name, value + 1)
|
return 0 == strcmp(name, value + 1) ? not_defined : (value[1] ? value : no_value);
|
||||||
? not_defined
|
}
|
||||||
: (value[1] ? value : no_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BOOST_MACRO_VALUE(X) macro_value(#X, BOOST_STRINGIZE(=X))
|
#define BOOST_MACRO_VALUE(X) macro_value(#X, BOOST_STRINGIZE(=X))
|
||||||
|
|
||||||
@ -1188,12 +1202,12 @@ int test_main(int, char*[])
|
|||||||
cout << "BOOST_FILESYSTEM_DECL "
|
cout << "BOOST_FILESYSTEM_DECL "
|
||||||
<< BOOST_MACRO_VALUE(BOOST_FILESYSTEM_DECL) << endl;
|
<< BOOST_MACRO_VALUE(BOOST_FILESYSTEM_DECL) << endl;
|
||||||
|
|
||||||
//#ifdef BOOST_FILESYSTEM_DECL
|
//#ifdef BOOST_FILESYSTEM_DECL
|
||||||
// cout << "BOOST_FILESYSTEM_DECL is defined as "
|
// cout << "BOOST_FILESYSTEM_DECL is defined as "
|
||||||
// << BOOST_STRINGIZE(BOOST_FILESYSTEM_DECL) << endl;
|
// << BOOST_STRINGIZE(BOOST_FILESYSTEM_DECL) << endl;
|
||||||
//#else
|
//#else
|
||||||
// cout << "BOOST_FILESYSTEM_DECL is not defined" << endl;
|
// cout << "BOOST_FILESYSTEM_DECL is not defined" << endl;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
l.push_back('s');
|
l.push_back('s');
|
||||||
l.push_back('t');
|
l.push_back('t');
|
||||||
@ -1239,9 +1253,7 @@ int test_main(int, char*[])
|
|||||||
test_error_handling();
|
test_error_handling();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
test_user_supplied_type();
|
test_user_supplied_type();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string foo("\\abc");
|
std::string foo("\\abc");
|
||||||
|
@ -15,10 +15,10 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fs::path p1( "a" );
|
fs::path p1("a");
|
||||||
fs::path p2 = p1 / "b";
|
fs::path p2 = p1 / "b";
|
||||||
|
|
||||||
BOOST_TEST_EQ( p2, "a/b" );
|
BOOST_TEST_EQ(p2, "a/b");
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ using boost::filesystem::path;
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
|
||||||
|
void lexically_relative_test()
|
||||||
{
|
{
|
||||||
void lexically_relative_test()
|
|
||||||
{
|
|
||||||
cout << "lexically_relative_test..." << endl;
|
cout << "lexically_relative_test..." << endl;
|
||||||
|
|
||||||
BOOST_TEST(path("").lexically_relative("") == "");
|
BOOST_TEST(path("").lexically_relative("") == "");
|
||||||
@ -76,23 +76,24 @@ namespace
|
|||||||
// Some tests from Jamie Allsop's paper
|
// Some tests from Jamie Allsop's paper
|
||||||
BOOST_TEST(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
BOOST_TEST(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
||||||
BOOST_TEST(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
BOOST_TEST(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
||||||
#ifdef BOOST_WINDOWS_API
|
#ifdef BOOST_WINDOWS_API
|
||||||
BOOST_TEST(path("c:\\y").lexically_relative("c:\\x") == "../y");
|
BOOST_TEST(path("c:\\y").lexically_relative("c:\\x") == "../y");
|
||||||
#else
|
#else
|
||||||
BOOST_TEST(path("c:\\y").lexically_relative("c:\\x") == "");
|
BOOST_TEST(path("c:\\y").lexically_relative("c:\\x") == "");
|
||||||
#endif
|
#endif
|
||||||
BOOST_TEST(path("d:\\y").lexically_relative("c:\\x") == "");
|
BOOST_TEST(path("d:\\y").lexically_relative("c:\\x") == "");
|
||||||
|
|
||||||
// From issue #1976
|
// From issue #1976
|
||||||
BOOST_TEST(path("/foo/new").lexically_relative("/foo/bar") == "../new");
|
BOOST_TEST(path("/foo/new").lexically_relative("/foo/bar") == "../new");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lexically_proximate_test()
|
void lexically_proximate_test()
|
||||||
{
|
{
|
||||||
cout << "lexically_proximate_test..." << endl;
|
cout << "lexically_proximate_test..." << endl;
|
||||||
// paths unrelated
|
// paths unrelated
|
||||||
BOOST_TEST(path("a/b/c").lexically_proximate("x") == "a/b/c");
|
BOOST_TEST(path("a/b/c").lexically_proximate("x") == "a/b/c");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#ifndef BOOST_LIGHTWEIGHT_MAIN
|
#ifndef BOOST_LIGHTWEIGHT_MAIN
|
||||||
# include <boost/test/prg_exec_monitor.hpp>
|
#include <boost/test/prg_exec_monitor.hpp>
|
||||||
#else
|
#else
|
||||||
# include <boost/detail/lightweight_main.hpp>
|
#include <boost/detail/lightweight_main.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@ -30,9 +30,8 @@ using std::endl;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
bool cleanup = true;
|
||||||
bool cleanup = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cpp_main ----------------------------------------------------------------//
|
// cpp_main ----------------------------------------------------------------//
|
||||||
|
@ -14,34 +14,33 @@
|
|||||||
#include <locale>
|
#include <locale>
|
||||||
#include <cwchar> // for mbstate_t
|
#include <cwchar> // for mbstate_t
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------//
|
||||||
// //
|
// //
|
||||||
// class test_codecvt //
|
// class test_codecvt //
|
||||||
// //
|
// //
|
||||||
// Warning: partial implementation; even do_in and do_out only partially meet the //
|
// Warning: partial implementation; even do_in and do_out only partially meet the //
|
||||||
// standard library specifications as the "to" buffer must hold the entire result. //
|
// standard library specifications as the "to" buffer must hold the entire result. //
|
||||||
// //
|
// //
|
||||||
// The value of a wide character is the value of the corresponding narrow character //
|
// The value of a wide character is the value of the corresponding narrow character //
|
||||||
// plus 1. This ensures that compares against expected values will fail if the //
|
// plus 1. This ensures that compares against expected values will fail if the //
|
||||||
// code conversion did not occur as expected. //
|
// code conversion did not occur as expected. //
|
||||||
// //
|
// //
|
||||||
//------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
class test_codecvt
|
class test_codecvt :
|
||||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit test_codecvt() :
|
||||||
|
std::codecvt< wchar_t, char, std::mbstate_t >()
|
||||||
{
|
{
|
||||||
public:
|
}
|
||||||
explicit test_codecvt()
|
|
||||||
: std::codecvt<wchar_t, char, std::mbstate_t>() {}
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual bool do_always_noconv() const throw() { return false; }
|
virtual bool do_always_noconv() const throw() { return false; }
|
||||||
|
|
||||||
virtual int do_encoding() const throw() { return 0; }
|
virtual int do_encoding() const throw() { return 0; }
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_in(std::mbstate_t&,
|
virtual std::codecvt_base::result do_in(std::mbstate_t&, const char* from, const char* from_end, const char*& from_next, wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
|
||||||
const char* from, const char* from_end, const char*& from_next,
|
|
||||||
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
|
|
||||||
{
|
{
|
||||||
for (; from != from_end && to != to_end; ++from, ++to)
|
for (; from != from_end && to != to_end; ++from, ++to)
|
||||||
*to = wchar_t(*from + 1);
|
*to = wchar_t(*from + 1);
|
||||||
@ -53,12 +52,10 @@
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_out(std::mbstate_t&,
|
virtual std::codecvt_base::result do_out(std::mbstate_t&, const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next, char* to, char* to_end, char*& to_next) const
|
||||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
|
||||||
char* to, char* to_end, char*& to_next) const
|
|
||||||
{
|
{
|
||||||
for (; from != from_end && to != to_end; ++from, ++to)
|
for (; from != from_end && to != to_end; ++from, ++to)
|
||||||
*to = static_cast<char>(*from - 1);
|
*to = static_cast< char >(*from - 1);
|
||||||
if (to == to_end)
|
if (to == to_end)
|
||||||
return error;
|
return error;
|
||||||
*to = '\0';
|
*to = '\0';
|
||||||
@ -67,13 +64,9 @@
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::codecvt_base::result do_unshift(std::mbstate_t&,
|
virtual std::codecvt_base::result do_unshift(std::mbstate_t&, char* /*from*/, char* /*to*/, char*& /*next*/) const { return ok; }
|
||||||
char* /*from*/, char* /*to*/, char* & /*next*/) const { return ok; }
|
virtual int do_length(std::mbstate_t&, const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; }
|
||||||
|
virtual int do_max_length() const throw() { return 0; }
|
||||||
virtual int do_length(std::mbstate_t&,
|
};
|
||||||
const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; }
|
|
||||||
|
|
||||||
virtual int do_max_length() const throw () { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BOOST_FILESYSTEM3_TEST_CODECVT_HPP
|
#endif // BOOST_FILESYSTEM3_TEST_CODECVT_HPP
|
||||||
|
@ -24,25 +24,25 @@
|
|||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
int cpp_main( int argc, char* argv[])
|
int cpp_main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
typedef std::map<DWORD, std::string> decode_type;
|
typedef std::map< DWORD, std::string > decode_type;
|
||||||
decode_type table;
|
decode_type table;
|
||||||
|
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_ARCHIVE, "FILE_ATTRIBUTE_ARCHIVE"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_ARCHIVE, "FILE_ATTRIBUTE_ARCHIVE"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_COMPRESSED, "FILE_ATTRIBUTE_COMPRESSED"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_COMPRESSED, "FILE_ATTRIBUTE_COMPRESSED"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_DEVICE, "FILE_ATTRIBUTE_DEVICE"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_DEVICE, "FILE_ATTRIBUTE_DEVICE"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_DIRECTORY, "FILE_ATTRIBUTE_DIRECTORY"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_DIRECTORY, "FILE_ATTRIBUTE_DIRECTORY"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_ENCRYPTED, "FILE_ATTRIBUTE_ENCRYPTED"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_ENCRYPTED, "FILE_ATTRIBUTE_ENCRYPTED"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_HIDDEN, "FILE_ATTRIBUTE_HIDDEN"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_HIDDEN, "FILE_ATTRIBUTE_HIDDEN"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "FILE_ATTRIBUTE_NOT_CONTENT_INDEXED"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "FILE_ATTRIBUTE_NOT_CONTENT_INDEXED"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_OFFLINE, "FILE_ATTRIBUTE_OFFLINE"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_OFFLINE, "FILE_ATTRIBUTE_OFFLINE"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_READONLY, "FILE_ATTRIBUTE_READONLY"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_READONLY, "FILE_ATTRIBUTE_READONLY"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_REPARSE_POINT, "FILE_ATTRIBUTE_REPARSE_POINT"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_REPARSE_POINT, "FILE_ATTRIBUTE_REPARSE_POINT"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_SPARSE_FILE, "FILE_ATTRIBUTE_SPARSE_FILE"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_SPARSE_FILE, "FILE_ATTRIBUTE_SPARSE_FILE"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_SYSTEM, "FILE_ATTRIBUTE_SYSTEM"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_SYSTEM, "FILE_ATTRIBUTE_SYSTEM"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_TEMPORARY, "FILE_ATTRIBUTE_TEMPORARY"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_TEMPORARY, "FILE_ATTRIBUTE_TEMPORARY"));
|
||||||
table.insert(make_pair<DWORD, std::string>(FILE_ATTRIBUTE_VIRTUAL, "FILE_ATTRIBUTE_VIRTUAL"));
|
table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_VIRTUAL, "FILE_ATTRIBUTE_VIRTUAL"));
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user