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
@ -17,8 +17,7 @@ using boost::filesystem::path;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
std::ifstream infile;
|
||||
std::ofstream posix_outfile;
|
||||
std::ifstream posix_infile;
|
||||
@ -54,7 +53,8 @@ namespace
|
||||
string s;
|
||||
for (path::iterator i(p.begin()); i != p.end(); ++i)
|
||||
{
|
||||
if ( i != p.begin() ) s += ',';
|
||||
if (i != p.begin())
|
||||
s += ',';
|
||||
s += (*i).string();
|
||||
}
|
||||
return s;
|
||||
@ -151,14 +151,12 @@ namespace
|
||||
|
||||
void do_table()
|
||||
{
|
||||
outfile <<
|
||||
"<h1>Path Decomposition Table</h1>\n"
|
||||
outfile << "<h1>Path Decomposition Table</h1>\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"
|
||||
"<i>POSIX</i> result and the bottom value is the <i>Windows</i> result.\n"
|
||||
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n"
|
||||
"<p>\n"
|
||||
;
|
||||
"<p>\n";
|
||||
|
||||
// generate the column headings
|
||||
|
||||
@ -196,15 +194,13 @@ int cpp_main( int argc, char * argv[] ) // note name!
|
||||
{
|
||||
if (argc != 5)
|
||||
{
|
||||
std::cerr <<
|
||||
"Usage: path_table \"POSIX\"|\"Windows\" input-file posix-file output-file\n"
|
||||
std::cerr << "Usage: path_table \"POSIX\"|\"Windows\" input-file posix-file output-file\n"
|
||||
"Run on POSIX first, then on Windows\n"
|
||||
" \"POSIX\" causes POSIX results to be saved in posix-file;\n"
|
||||
" \"Windows\" causes POSIX results read from posix-file\n"
|
||||
" input-file contains the paths to appear in the table.\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;
|
||||
}
|
||||
|
||||
@ -247,14 +243,12 @@ int cpp_main( int argc, char * argv[] ) // note name!
|
||||
"<head>\n"
|
||||
"<title>Path Decomposition Table</title>\n"
|
||||
"</head>\n"
|
||||
"<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
|
||||
;
|
||||
"<body bgcolor=\"#ffffff\" text=\"#000000\">\n";
|
||||
|
||||
do_table();
|
||||
|
||||
outfile << "</body>\n"
|
||||
"</html>\n"
|
||||
;
|
||||
"</html>\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using namespace boost::filesystem;
|
||||
|
@ -24,15 +24,13 @@ using boost::system::error_code;
|
||||
using boost::system::system_error;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
void report_system_error(const system_error& ex)
|
||||
{
|
||||
cout << " threw system_error:\n"
|
||||
<< " ex.code().value() is " << ex.code().value() << '\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)
|
||||
@ -40,8 +38,7 @@ namespace
|
||||
cout << " threw filesystem_error exception:\n"
|
||||
<< " ex.code().value() is " << ex.code().value() << '\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)
|
||||
@ -50,25 +47,35 @@ namespace
|
||||
switch (s.type())
|
||||
{
|
||||
case fs::status_error:
|
||||
cout << "status_error\n"; break;
|
||||
cout << "status_error\n";
|
||||
break;
|
||||
case fs::file_not_found:
|
||||
cout << "file_not_found\n"; break;
|
||||
cout << "file_not_found\n";
|
||||
break;
|
||||
case fs::regular_file:
|
||||
cout << "regular_file\n"; break;
|
||||
cout << "regular_file\n";
|
||||
break;
|
||||
case fs::directory_file:
|
||||
cout << "directory_file\n"; break;
|
||||
cout << "directory_file\n";
|
||||
break;
|
||||
case fs::symlink_file:
|
||||
cout << "symlink_file\n"; break;
|
||||
cout << "symlink_file\n";
|
||||
break;
|
||||
case fs::block_file:
|
||||
cout << "block_file\n"; break;
|
||||
cout << "block_file\n";
|
||||
break;
|
||||
case fs::character_file:
|
||||
cout << "character_file\n"; break;
|
||||
cout << "character_file\n";
|
||||
break;
|
||||
case fs::fifo_file:
|
||||
cout << "fifo_file\n"; break;
|
||||
cout << "fifo_file\n";
|
||||
break;
|
||||
case fs::socket_file:
|
||||
cout << "socket_file\n"; break;
|
||||
cout << "socket_file\n";
|
||||
break;
|
||||
case fs::type_unknown:
|
||||
cout << "type_unknown\n"; break;
|
||||
cout << "type_unknown\n";
|
||||
break;
|
||||
default:
|
||||
cout << "not a valid enumeration constant\n";
|
||||
}
|
||||
@ -79,13 +86,12 @@ namespace
|
||||
cout << " ec:\n"
|
||||
<< " value() is " << ec.value() << '\n'
|
||||
<< " category().name() is " << ec.category().name() << '\n'
|
||||
<< " message() is " << ec.message() << '\n'
|
||||
;
|
||||
<< " message() is " << ec.message() << '\n';
|
||||
}
|
||||
|
||||
bool threw_exception;
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@ -119,7 +125,10 @@ int main(int argc, char* argv[])
|
||||
cout << "\nstatus(\"" << p.string() << "\");\n";
|
||||
threw_exception = false;
|
||||
|
||||
try { s = fs::status(p); }
|
||||
try
|
||||
{
|
||||
s = fs::status(p);
|
||||
}
|
||||
catch (const system_error& ex)
|
||||
{
|
||||
report_filesystem_error(ex);
|
||||
@ -141,7 +150,10 @@ int main(int argc, char* argv[])
|
||||
cout << "\nexists(\"" << p.string() << "\");\n";
|
||||
threw_exception = false;
|
||||
|
||||
try { b = fs::exists(p); }
|
||||
try
|
||||
{
|
||||
b = fs::exists(p);
|
||||
}
|
||||
catch (const system_error& ex)
|
||||
{
|
||||
report_filesystem_error(ex);
|
||||
@ -160,7 +172,10 @@ int main(int argc, char* argv[])
|
||||
cout << "\ndirectory_iterator(\"" << p.string() << "\");\n";
|
||||
threw_exception = false;
|
||||
|
||||
try { di = fs::directory_iterator(p); }
|
||||
try
|
||||
{
|
||||
di = fs::directory_iterator(p);
|
||||
}
|
||||
catch (const system_error& ex)
|
||||
{
|
||||
report_filesystem_error(ex);
|
||||
|
@ -13,11 +13,12 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
|
||||
using std::cout; using std::endl;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
path p;
|
||||
|
||||
void print_boost_macros()
|
||||
@ -36,11 +37,9 @@ namespace
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
const char* file_type_tab[] =
|
||||
{ "status_error", "file_not_found", "regular_file", "directory_file",
|
||||
const char* file_type_tab[] = { "status_error", "file_not_found", "regular_file", "directory_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)
|
||||
{
|
||||
@ -88,7 +87,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int cpp_main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -25,30 +25,45 @@
|
||||
|
||||
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)
|
||||
{
|
||||
fs::ifstream from_file(from, std::ios_base::in | std::ios_base::binary);
|
||||
if ( !from_file ) { std::cout << "input open failed\n"; return; }
|
||||
if (!from_file)
|
||||
{
|
||||
std::cout << "input open failed\n";
|
||||
return;
|
||||
}
|
||||
|
||||
fs::ofstream to_file(to, std::ios_base::out | std::ios_base::binary);
|
||||
if ( !to_file ) { std::cout << "output open failed\n"; return; }
|
||||
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 (to_file.fail())
|
||||
{
|
||||
std::cout << "write error\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !from_file.eof() ) { std::cout << "read error\n"; }
|
||||
if (!from_file.eof())
|
||||
{
|
||||
std::cout << "read error\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
@ -83,8 +98,3 @@ int main( int argc, char * argv[] )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,21 +19,20 @@
|
||||
|
||||
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 >*
|
||||
cvt( &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
|
||||
( loc ) );
|
||||
}
|
||||
cvt(&std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc));
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace user {
|
||||
|
||||
namespace user
|
||||
{
|
||||
mbpath_traits::external_string_type
|
||||
mbpath_traits::to_external( const mbpath & ph,
|
||||
const internal_string_type & src )
|
||||
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]);
|
||||
@ -73,8 +72,7 @@ namespace user
|
||||
void mbpath_traits::imbue(const std::locale& new_loc)
|
||||
{
|
||||
loc = new_loc;
|
||||
cvt = &std::use_facet
|
||||
<std::codecvt<wchar_t, char, std::mbstate_t> >( loc );
|
||||
cvt = &std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc);
|
||||
}
|
||||
|
||||
} // namespace user
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <string>
|
||||
#include <locale>
|
||||
|
||||
namespace user
|
||||
{
|
||||
namespace user {
|
||||
|
||||
struct mbpath_traits;
|
||||
|
||||
typedef boost::filesystem::basic_path< std::wstring, mbpath_traits > mbpath;
|
||||
@ -25,20 +25,23 @@ namespace user
|
||||
typedef std::wstring internal_string_type;
|
||||
typedef std::string external_string_type;
|
||||
|
||||
static external_string_type to_external( const mbpath & ph,
|
||||
const internal_string_type & src );
|
||||
static external_string_type to_external(const mbpath& ph, const internal_string_type& src);
|
||||
|
||||
static internal_string_type to_internal(const external_string_type& src);
|
||||
|
||||
static void imbue(const std::locale& loc);
|
||||
};
|
||||
|
||||
} // namespace user
|
||||
|
||||
namespace boost
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
template<>
|
||||
struct is_basic_path< user::mbpath >
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
template<> struct is_basic_path<user::mbpath>
|
||||
{ static const bool value = true; };
|
||||
}
|
||||
}
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
@ -9,10 +9,14 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace std;
|
||||
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[])
|
||||
{
|
||||
|
@ -70,7 +70,6 @@ int main(int argc, char* argv[])
|
||||
++other_count;
|
||||
std::cout << dir_itr->path().filename() << " [other]\n";
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
@ -78,7 +77,8 @@ int main(int argc, char* argv[])
|
||||
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"
|
||||
<< other_count << " others\n"
|
||||
<< err_count << " errors\n";
|
||||
|
@ -16,7 +16,7 @@ namespace fs = boost::filesystem;
|
||||
|
||||
typedef std::basic_string< TCHAR > tstring;
|
||||
|
||||
void func( const fs::path & p )
|
||||
void func(fs::path const& p)
|
||||
{
|
||||
assert(fs::exists(p));
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace std;
|
||||
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?
|
||||
cout << p << " size is " << file_size(p) << '\n';
|
||||
|
||||
else if (is_directory(p)) // is path p a directory?
|
||||
cout << p << " is a directory\n";
|
||||
|
||||
else
|
||||
cout << p << " exists, but is not a regular file or directory\n";
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using std::cout;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
@ -27,13 +28,14 @@ int main(int argc, char* argv[])
|
||||
if (exists(p))
|
||||
{
|
||||
if (is_regular_file(p))
|
||||
{
|
||||
cout << p << " size is " << file_size(p) << '\n';
|
||||
|
||||
}
|
||||
else if (is_directory(p))
|
||||
{
|
||||
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';
|
||||
}
|
||||
else
|
||||
@ -42,8 +44,7 @@ int main(int argc, char* argv[])
|
||||
else
|
||||
cout << p << " does not exist\n";
|
||||
}
|
||||
|
||||
catch (const filesystem_error& ex)
|
||||
catch (filesystem_error& ex)
|
||||
{
|
||||
cout << ex.what() << '\n';
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using std::cout;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
@ -29,8 +30,9 @@ int main(int argc, char* argv[])
|
||||
if (exists(p))
|
||||
{
|
||||
if (is_regular_file(p))
|
||||
{
|
||||
cout << p << " size is " << file_size(p) << '\n';
|
||||
|
||||
}
|
||||
else if (is_directory(p))
|
||||
{
|
||||
cout << p << " is a directory containing:\n";
|
||||
@ -51,8 +53,7 @@ int main(int argc, char* argv[])
|
||||
else
|
||||
cout << p << " does not exist\n";
|
||||
}
|
||||
|
||||
catch (const filesystem_error& ex)
|
||||
catch (filesystem_error& ex)
|
||||
{
|
||||
cout << ex.what() << '\n';
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
int main()
|
||||
@ -33,20 +34,36 @@ int main()
|
||||
wide_list.push_back(L'3');
|
||||
wide_list.push_back(L'\u263A');
|
||||
|
||||
{ fs::ofstream f("smile"); }
|
||||
{ fs::ofstream f(L"smile\u263A"); }
|
||||
{ fs::ofstream f(narrow_string); }
|
||||
{ fs::ofstream f(wide_string); }
|
||||
{ fs::ofstream f(narrow_list); }
|
||||
{ fs::ofstream f(wide_list); }
|
||||
{
|
||||
fs::ofstream f("smile");
|
||||
}
|
||||
{
|
||||
fs::ofstream f(L"smile\u263A");
|
||||
}
|
||||
{
|
||||
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.push_back('4');
|
||||
wide_list.pop_back();
|
||||
wide_list.pop_back();
|
||||
wide_list.push_back(L'4');
|
||||
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;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@ -37,8 +38,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (const std::exception& ex)
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
std::cout << "************* exception *****************\n";
|
||||
std::cout << ex.what() << '\n';
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@ -23,24 +24,25 @@ int main(int argc, char* argv[])
|
||||
try
|
||||
{
|
||||
for (recursive_directory_iterator it(argv[1]);
|
||||
it != recursive_directory_iterator();
|
||||
)
|
||||
it != recursive_directory_iterator();)
|
||||
{
|
||||
for (int i = 0; i <= it.level(); ++i)
|
||||
std::cout << " ";
|
||||
|
||||
std::cout << it->path() << '\n';
|
||||
|
||||
try { ++it; }
|
||||
catch (const filesystem_error& ex)
|
||||
try
|
||||
{
|
||||
++it;
|
||||
}
|
||||
catch (filesystem_error& ex)
|
||||
{
|
||||
std::cout << "************* filesystem_error *****************\n";
|
||||
std::cout << ex.what() << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (const std::exception& ex)
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
std::cout << "************* exception *****************\n";
|
||||
std::cout << ex.what() << '\n';
|
||||
|
@ -25,8 +25,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
error_code 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)
|
||||
std::cout << " ";
|
||||
|
@ -55,8 +55,7 @@
|
||||
|
||||
// normalize macros ------------------------------------------------------------------//
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) \
|
||||
&& !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
|
||||
#if !defined(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
|
||||
#define BOOST_FILESYSTEM_STATIC_LINK
|
||||
#endif
|
||||
|
||||
@ -88,8 +87,7 @@
|
||||
|
||||
// enable automatic library variant selection ----------------------------------------//
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
||||
&& !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||
//
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
|
@ -24,10 +24,8 @@
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
|
||||
@ -50,9 +48,9 @@ namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
||||
|
@ -20,10 +20,9 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
inline const char* macro_value(const char* name, const char* value)
|
||||
{
|
||||
static const char* no_value = "[no value]";
|
||||
@ -32,12 +31,11 @@ namespace boost
|
||||
BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
|
||||
BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
|
||||
|
||||
return strcmp(name, value + 1)
|
||||
? ((*value && *(value+1)) ? (value+1) : no_value)
|
||||
: not_defined; // name == value+1 so the macro is not defined
|
||||
return strcmp(name, value + 1) ? ((*value && *(value + 1)) ? (value + 1) : no_value) : not_defined; // name == value+1 so the macro is not defined
|
||||
}
|
||||
} // detail
|
||||
} // boost
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
|
||||
|
||||
|
@ -10,9 +10,14 @@
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#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
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
@ -62,22 +62,23 @@ public:
|
||||
typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry
|
||||
|
||||
directory_entry() BOOST_NOEXCEPT {}
|
||||
|
||||
explicit directory_entry(const boost::filesystem::path& p) :
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
directory_entry& operator=(const directory_entry& rhs)
|
||||
directory_entry& operator=(directory_entry const& rhs)
|
||||
{
|
||||
m_path = rhs.m_path;
|
||||
m_status = rhs.m_status;
|
||||
@ -91,9 +92,12 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
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
|
||||
{
|
||||
m_path = std::move(rhs.m_path);
|
||||
@ -103,16 +107,14 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void assign(const boost::filesystem::path& p,
|
||||
file_status st = file_status(), file_status symlink_st = file_status())
|
||||
void assign(const boost::filesystem::path& p, file_status st = file_status(), file_status symlink_st = file_status())
|
||||
{
|
||||
m_path = p;
|
||||
m_status = st;
|
||||
m_symlink_status = symlink_st;
|
||||
}
|
||||
|
||||
void replace_filename(const boost::filesystem::path& p,
|
||||
file_status st = file_status(), file_status symlink_st = file_status())
|
||||
void replace_filename(const boost::filesystem::path& p, file_status st = file_status(), file_status symlink_st = file_status())
|
||||
{
|
||||
m_path.remove_filename();
|
||||
m_path /= p;
|
||||
@ -127,19 +129,22 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
const boost::filesystem::path& path() const BOOST_NOEXCEPT { return m_path; }
|
||||
operator const boost::filesystem::path&() const BOOST_NOEXCEPT { return m_path; }
|
||||
const boost::filesystem::path& path() const BOOST_NOEXCEPT
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
operator boost::filesystem::path const&() const BOOST_NOEXCEPT { return m_path; }
|
||||
file_status status() const { return get_status(); }
|
||||
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(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!=(const directory_entry& 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<=(const directory_entry& 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>=(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!=(directory_entry const& 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<=(directory_entry const& 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>=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path >= rhs.m_path; }
|
||||
|
||||
private:
|
||||
BOOST_FILESYSTEM_DECL file_status get_status(system::error_code* ec = 0) const;
|
||||
@ -151,7 +156,6 @@ private:
|
||||
mutable file_status m_symlink_status; // lstat()-like
|
||||
}; // directory_entry
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// //
|
||||
// directory_entry overloads //
|
||||
@ -160,28 +164,79 @@ private:
|
||||
|
||||
// Without these functions, calling (for example) 'is_directory' with a 'directory_entry' results in:
|
||||
// - 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())'
|
||||
|
||||
inline file_status status (const directory_entry& e) { return e.status(); }
|
||||
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()); }
|
||||
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 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()); }
|
||||
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 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()); }
|
||||
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 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()); }
|
||||
inline bool is_other (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_other(e.status(ec)); }
|
||||
inline file_status status(directory_entry const& e)
|
||||
{
|
||||
return e.status();
|
||||
}
|
||||
inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return e.status(ec);
|
||||
}
|
||||
inline bool type_present(directory_entry const& e)
|
||||
{
|
||||
return filesystem::type_present(e.status());
|
||||
}
|
||||
inline bool type_present(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return filesystem::type_present(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
|
||||
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
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
@ -245,7 +300,7 @@ struct dir_itr_imp :
|
||||
};
|
||||
|
||||
// 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);
|
||||
|
||||
} // namespace detail
|
||||
@ -265,7 +320,7 @@ class directory_iterator :
|
||||
{
|
||||
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);
|
||||
|
||||
public:
|
||||
@ -273,17 +328,17 @@ public:
|
||||
|
||||
// iterator_facade derived classes don't seem to like implementations in
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -346,19 +401,48 @@ private:
|
||||
// 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
|
||||
// emphasizes begin() is just a pass through.
|
||||
inline const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
||||
inline directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
||||
inline directory_iterator const& begin(directory_iterator const& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
inline directory_iterator end(directory_iterator const&) BOOST_NOEXCEPT
|
||||
{
|
||||
return directory_iterator();
|
||||
}
|
||||
|
||||
// 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 cend(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
||||
inline directory_iterator const& cbegin(directory_iterator const& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
inline directory_iterator cend(directory_iterator const&) BOOST_NOEXCEPT
|
||||
{
|
||||
return directory_iterator();
|
||||
}
|
||||
|
||||
// enable directory_iterator BOOST_FOREACH -----------------------------------------//
|
||||
|
||||
inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
||||
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(); }
|
||||
inline directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
|
||||
inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -418,7 +502,7 @@ struct recur_dir_itr_imp :
|
||||
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_pop(recursive_directory_iterator& it, system::error_code* ec);
|
||||
|
||||
@ -439,41 +523,41 @@ class recursive_directory_iterator :
|
||||
{
|
||||
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_pop(recursive_directory_iterator& it, system::error_code* ec);
|
||||
|
||||
public:
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -514,7 +598,10 @@ public:
|
||||
}
|
||||
|
||||
#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_request() const BOOST_NOEXCEPT { return !recursion_pending(); }
|
||||
#endif
|
||||
@ -539,7 +626,10 @@ public:
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
file_status status() const
|
||||
@ -594,19 +684,48 @@ typedef recursive_directory_iterator wrecursive_directory_iterator;
|
||||
// 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
|
||||
// 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 end(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
||||
inline recursive_directory_iterator const& begin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
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
|
||||
inline const recursive_directory_iterator& cbegin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
|
||||
inline recursive_directory_iterator cend(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
||||
inline recursive_directory_iterator const& cbegin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
inline recursive_directory_iterator cend(recursive_directory_iterator const&) BOOST_NOEXCEPT
|
||||
{
|
||||
return recursive_directory_iterator();
|
||||
}
|
||||
|
||||
// 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(const recursive_directory_iterator& 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(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
|
||||
inline recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -616,6 +735,7 @@ struct range_mutable_iterator<boost::filesystem::recursive_directory_iterator, v
|
||||
{
|
||||
typedef boost::filesystem::recursive_directory_iterator type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< boost::filesystem::recursive_directory_iterator, void >
|
||||
{
|
||||
@ -625,4 +745,5 @@ struct range_const_iterator<boost::filesystem::recursive_directory_iterator, voi
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_DIRECTORY_HPP
|
||||
|
@ -83,8 +83,14 @@ private:
|
||||
std::string m_what; // not built until needed
|
||||
|
||||
BOOST_DEFAULTED_FUNCTION(impl(), {})
|
||||
explicit impl(path const& path1) : m_path1(path1) {}
|
||||
impl(path const& path1, path const& path2) : m_path1(path1), m_path2(path2) {}
|
||||
explicit impl(path const& path1) :
|
||||
m_path1(path1)
|
||||
{
|
||||
}
|
||||
impl(path const& path1, path const& path2) :
|
||||
m_path1(path1), m_path2(path2)
|
||||
{
|
||||
}
|
||||
};
|
||||
boost::intrusive_ptr< impl > m_imp_ptr;
|
||||
};
|
||||
@ -97,4 +103,5 @@ private:
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_EXCEPTION_HPP
|
||||
|
@ -23,7 +23,6 @@
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#include <boost/detail/bitmask.hpp>
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
@ -129,15 +128,18 @@ class file_status
|
||||
{
|
||||
public:
|
||||
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 :
|
||||
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 :
|
||||
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.
|
||||
|
||||
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
|
||||
@ -159,7 +162,8 @@ public:
|
||||
#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
|
||||
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
|
||||
@ -196,42 +200,52 @@ inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.type() != status_error;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool permissions_present(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.permissions() != perms_not_known;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool status_known(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return filesystem::type_present(f) && filesystem::permissions_present(f);
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool exists(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.type() != status_error && f.type() != file_not_found;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool is_regular_file(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.type() == regular_file;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool is_directory(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.type() == directory_file;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool is_symlink(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return f.type() == symlink_file;
|
||||
}
|
||||
|
||||
inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT
|
||||
{
|
||||
return filesystem::exists(f) && !filesystem::is_regular_file(f)
|
||||
&& !filesystem::is_directory(f) && !filesystem::is_symlink(f);
|
||||
return filesystem::exists(f) && !filesystem::is_regular_file(f) && !filesystem::is_directory(f) && !filesystem::is_symlink(f);
|
||||
}
|
||||
|
||||
#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
|
||||
{
|
||||
return filesystem::is_regular_file(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_FILE_STATUS_HPP
|
||||
|
@ -26,8 +26,7 @@
|
||||
|
||||
// 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()
|
||||
#if defined(BOOST_WINDOWS_API) \
|
||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
|
||||
#if defined(BOOST_WINDOWS_API) && (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
|
||||
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
|
||||
#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
|
||||
@ -40,31 +39,26 @@
|
||||
#pragma warning(disable : 4250)
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// basic_filebuf //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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&);
|
||||
const basic_filebuf& operator=(const basic_filebuf&);
|
||||
public:
|
||||
BOOST_DEFAULTED_FUNCTION(basic_filebuf(), {})
|
||||
BOOST_DELETED_FUNCTION(basic_filebuf(const basic_filebuf&))
|
||||
BOOST_DELETED_FUNCTION(const basic_filebuf& operator=(const basic_filebuf&))
|
||||
|
||||
public:
|
||||
basic_filebuf() {}
|
||||
virtual ~basic_filebuf() {}
|
||||
|
||||
basic_filebuf<charT,traits>*
|
||||
open(const path& p, std::ios_base::openmode mode)
|
||||
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)
|
||||
? this : 0;
|
||||
return std::basic_filebuf< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode) ? this : 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -73,31 +67,34 @@ namespace filesystem
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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&);
|
||||
const basic_ifstream& operator=(const basic_ifstream&);
|
||||
|
||||
public:
|
||||
basic_ifstream() {}
|
||||
BOOST_DEFAULTED_FUNCTION(basic_ifstream(), {})
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_ifstream(const path& p)
|
||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
|
||||
explicit basic_ifstream(const path& p) :
|
||||
std::basic_ifstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
|
||||
|
||||
basic_ifstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
basic_ifstream(const path& p, std::ios_base::openmode 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)
|
||||
{ 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)
|
||||
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_ifstream() {}
|
||||
{
|
||||
std::basic_ifstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
@ -105,31 +102,34 @@ namespace filesystem
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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&);
|
||||
const basic_ofstream& operator=(const basic_ofstream&);
|
||||
|
||||
public:
|
||||
basic_ofstream() {}
|
||||
BOOST_DEFAULTED_FUNCTION(basic_ofstream(), {})
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_ofstream(const path& p)
|
||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
|
||||
explicit basic_ofstream(const path& p) :
|
||||
std::basic_ofstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
|
||||
|
||||
basic_ofstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
basic_ofstream(const path& p, std::ios_base::openmode 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)
|
||||
{ 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)
|
||||
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_ofstream() {}
|
||||
{
|
||||
std::basic_ofstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
@ -137,34 +137,34 @@ namespace filesystem
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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&);
|
||||
const basic_fstream & operator=(const basic_fstream&);
|
||||
|
||||
public:
|
||||
basic_fstream() {}
|
||||
BOOST_DEFAULTED_FUNCTION(basic_fstream(), {})
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_fstream(const path& p)
|
||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR,
|
||||
std::ios_base::in | std::ios_base::out) {}
|
||||
explicit basic_fstream(const path& p) :
|
||||
std::basic_fstream< charT, traits >(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in | std::ios_base::out) {}
|
||||
|
||||
basic_fstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
basic_fstream(const path& p, std::ios_base::openmode 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)
|
||||
{ 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)
|
||||
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_fstream() {}
|
||||
|
||||
{
|
||||
std::basic_fstream< charT, traits >::open(p.BOOST_FILESYSTEM_C_STR, mode);
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
@ -189,4 +189,5 @@ namespace filesystem
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_FSTREAM_HPP
|
||||
|
@ -93,80 +93,78 @@ BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
|
||||
namespace detail {
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
path initial_path(system::error_code* ec = 0);
|
||||
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
|
||||
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)
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
void create_directory_symlink(const path& to, const path& from,
|
||||
system::error_code* ec=0);
|
||||
void create_directory_symlink(path const& to, path const& from, system::error_code* ec = 0);
|
||||
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
|
||||
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
|
||||
path current_path(system::error_code* ec = 0);
|
||||
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
|
||||
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::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::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
|
||||
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
|
||||
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
|
||||
void last_write_time(const path& p, const std::time_t new_time,
|
||||
system::error_code* ec=0);
|
||||
void last_write_time(path const& p, const std::time_t new_time, system::error_code* ec = 0);
|
||||
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
|
||||
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
|
||||
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
|
||||
bool remove(const path& p, system::error_code* ec=0);
|
||||
bool remove(path const& p, system::error_code* ec = 0);
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
path temp_directory_path(system::error_code* ec = 0);
|
||||
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
|
||||
path weakly_canonical(const path& p, system::error_code* ec = 0);
|
||||
path weakly_canonical(path const& p, system::error_code* ec = 0);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@ -176,54 +174,97 @@ path weakly_canonical(const path& p, system::error_code* ec = 0);
|
||||
// //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
inline
|
||||
file_status status(const path& p) {return detail::status(p);}
|
||||
inline
|
||||
file_status status(const path& p, system::error_code& ec)
|
||||
{return detail::status(p, &ec);}
|
||||
inline
|
||||
file_status symlink_status(const path& p) {return detail::symlink_status(p);}
|
||||
inline
|
||||
file_status symlink_status(const path& p, system::error_code& ec)
|
||||
{return detail::symlink_status(p, &ec);}
|
||||
inline
|
||||
bool exists(const path& p) {return exists(detail::status(p));}
|
||||
inline
|
||||
bool exists(const path& p, system::error_code& ec)
|
||||
{return exists(detail::status(p, &ec));}
|
||||
inline
|
||||
bool is_directory(const path& p) {return is_directory(detail::status(p));}
|
||||
inline
|
||||
bool is_directory(const path& p, system::error_code& ec)
|
||||
{return is_directory(detail::status(p, &ec));}
|
||||
inline
|
||||
bool is_regular_file(const path& p) {return is_regular_file(detail::status(p));}
|
||||
inline
|
||||
bool is_regular_file(const path& p, system::error_code& ec)
|
||||
{return is_regular_file(detail::status(p, &ec));}
|
||||
inline
|
||||
bool is_other(const path& p) {return is_other(detail::status(p));}
|
||||
inline
|
||||
bool is_other(const path& p, system::error_code& ec)
|
||||
{return is_other(detail::status(p, &ec));}
|
||||
inline
|
||||
bool is_symlink(const path& p) {return is_symlink(detail::symlink_status(p));}
|
||||
inline
|
||||
bool is_symlink(const path& p, system::error_code& ec)
|
||||
{return is_symlink(detail::symlink_status(p, &ec));}
|
||||
inline file_status status(path const& p)
|
||||
{
|
||||
return detail::status(p);
|
||||
}
|
||||
|
||||
inline file_status status(path const& p, system::error_code& ec)
|
||||
{
|
||||
return detail::status(p, &ec);
|
||||
}
|
||||
|
||||
inline file_status symlink_status(path const& p)
|
||||
{
|
||||
return detail::symlink_status(p);
|
||||
}
|
||||
|
||||
inline file_status symlink_status(path const& p, system::error_code& ec)
|
||||
{
|
||||
return detail::symlink_status(p, &ec);
|
||||
}
|
||||
|
||||
inline bool exists(path const& p)
|
||||
{
|
||||
return exists(detail::status(p));
|
||||
}
|
||||
|
||||
inline bool exists(path const& p, system::error_code& ec)
|
||||
{
|
||||
return exists(detail::status(p, &ec));
|
||||
}
|
||||
|
||||
inline bool is_directory(path const& p)
|
||||
{
|
||||
return is_directory(detail::status(p));
|
||||
}
|
||||
|
||||
inline bool is_directory(path const& p, system::error_code& ec)
|
||||
{
|
||||
return is_directory(detail::status(p, &ec));
|
||||
}
|
||||
|
||||
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
|
||||
inline
|
||||
bool is_regular(const path& p) {return is_regular(detail::status(p));}
|
||||
inline
|
||||
bool is_regular(const path& p, system::error_code& ec)
|
||||
{return is_regular(detail::status(p, &ec));}
|
||||
inline bool is_regular(path const& p)
|
||||
{
|
||||
return is_regular(detail::status(p));
|
||||
}
|
||||
|
||||
inline bool is_regular(path const& p, system::error_code& ec)
|
||||
{
|
||||
return is_regular(detail::status(p, &ec));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
bool is_empty(const path& p) {return detail::is_empty(p);}
|
||||
inline
|
||||
bool is_empty(const path& p, system::error_code& ec)
|
||||
{return detail::is_empty(p, &ec);}
|
||||
inline bool is_empty(path const& p)
|
||||
{
|
||||
return detail::is_empty(p);
|
||||
}
|
||||
|
||||
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
|
||||
path initial_path() {return detail::initial_path();}
|
||||
inline path initial_path()
|
||||
{
|
||||
return detail::initial_path();
|
||||
}
|
||||
|
||||
inline
|
||||
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
|
||||
inline path initial_path(system::error_code& ec)
|
||||
{
|
||||
return detail::initial_path(&ec);
|
||||
}
|
||||
|
||||
template< class Path >
|
||||
path initial_path() {return initial_path();}
|
||||
path initial_path()
|
||||
{
|
||||
return initial_path();
|
||||
}
|
||||
template< class Path >
|
||||
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
|
||||
path initial_path(system::error_code& ec)
|
||||
{
|
||||
return detail::initial_path(&ec);
|
||||
}
|
||||
|
||||
inline
|
||||
path current_path() {return detail::current_path();}
|
||||
inline path current_path()
|
||||
{
|
||||
return detail::current_path();
|
||||
}
|
||||
|
||||
inline
|
||||
path current_path(system::error_code& ec) {return detail::current_path(&ec);}
|
||||
inline path current_path(system::error_code& ec)
|
||||
{
|
||||
return detail::current_path(&ec);
|
||||
}
|
||||
|
||||
inline
|
||||
void current_path(const path& p) {detail::current_path(p);}
|
||||
inline void current_path(path const& p)
|
||||
{
|
||||
detail::current_path(p);
|
||||
}
|
||||
|
||||
inline
|
||||
void current_path(const path& p, system::error_code& ec) BOOST_NOEXCEPT {detail::current_path(p, &ec);}
|
||||
inline void current_path(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::current_path(p, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
path absolute(const path& p, const path& base=current_path()) {return detail::absolute(p, base);}
|
||||
inline
|
||||
path absolute(const path& p, system::error_code& ec)
|
||||
inline path absolute(path const& p, path const& base = current_path())
|
||||
{
|
||||
return detail::absolute(p, base);
|
||||
}
|
||||
|
||||
inline path absolute(path const& p, system::error_code& ec)
|
||||
{
|
||||
path base = current_path(ec);
|
||||
if (ec)
|
||||
return path();
|
||||
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
|
||||
path canonical(const path& p, const path& base=current_path())
|
||||
{return detail::canonical(p, base);}
|
||||
inline
|
||||
path canonical(const path& p, system::error_code& ec)
|
||||
inline path absolute(path const& p, path const& base, system::error_code& ec)
|
||||
{
|
||||
return detail::absolute(p, base, &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);
|
||||
if (ec)
|
||||
return path();
|
||||
return detail::canonical(p, base, &ec);
|
||||
}
|
||||
inline
|
||||
path canonical(const path& p, const path& base, system::error_code& ec)
|
||||
{return detail::canonical(p, base, &ec);}
|
||||
|
||||
inline path canonical(path const& p, path const& base, system::error_code& ec)
|
||||
{
|
||||
return detail::canonical(p, base, &ec);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
inline
|
||||
path complete(const path& p)
|
||||
inline path complete(path const& p)
|
||||
{
|
||||
return absolute(p, initial_path());
|
||||
}
|
||||
|
||||
inline
|
||||
path complete(const path& p, const path& base)
|
||||
inline path complete(path const& p, path const& base)
|
||||
{
|
||||
return absolute(p, base);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
void copy(const path& from, const path& to)
|
||||
inline void copy(path const& from, path const& to)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||
inline
|
||||
void copy_directory(const path& from, const path& 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)
|
||||
{
|
||||
detail::copy_directory(from, to);
|
||||
}
|
||||
|
||||
inline void copy_directory(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::copy_directory(from, to, &ec);
|
||||
}
|
||||
#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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
|
||||
}
|
||||
#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
|
||||
void copy_symlink(const path& existing_symlink, const path& new_symlink,
|
||||
system::error_code& ec) BOOST_NOEXCEPT
|
||||
{detail::copy_symlink(existing_symlink, new_symlink, &ec);}
|
||||
inline
|
||||
bool create_directories(const path& p) {return detail::create_directories(p);}
|
||||
inline void copy_symlink(path const& existing_symlink, path const& new_symlink)
|
||||
{
|
||||
detail::copy_symlink(existing_symlink, new_symlink);
|
||||
}
|
||||
|
||||
inline
|
||||
bool create_directories(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::create_directories(p, &ec);}
|
||||
inline
|
||||
bool create_directory(const path& p) {return detail::create_directory(p, 0);}
|
||||
inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::copy_symlink(existing_symlink, new_symlink, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
bool create_directory(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::create_directory(p, 0, &ec);}
|
||||
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 bool create_directories(path const& p)
|
||||
{
|
||||
return detail::create_directories(p);
|
||||
}
|
||||
|
||||
inline
|
||||
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);}
|
||||
inline
|
||||
void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);}
|
||||
inline bool create_directories(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::create_directories(p, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{detail::create_symlink(to, new_symlink, &ec);}
|
||||
inline
|
||||
bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}
|
||||
inline bool create_directory(path const& p)
|
||||
{
|
||||
return detail::create_directory(p, 0);
|
||||
}
|
||||
|
||||
inline
|
||||
bool equivalent(const path& p1, const path& p2, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::equivalent(p1, p2, &ec);}
|
||||
inline
|
||||
boost::uintmax_t file_size(const path& p) {return detail::file_size(p);}
|
||||
inline bool create_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::create_directory(p, 0, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
boost::uintmax_t file_size(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::file_size(p, &ec);}
|
||||
inline
|
||||
boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}
|
||||
inline bool create_directory(path const& p, path const& existing)
|
||||
{
|
||||
return detail::create_directory(p, &existing);
|
||||
}
|
||||
|
||||
inline
|
||||
boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::hard_link_count(p, &ec);}
|
||||
inline
|
||||
std::time_t creation_time(const path& p) { return detail::creation_time(p); }
|
||||
inline bool create_directory(path const& p, path const& existing, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::create_directory(p, &existing, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
std::time_t creation_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{ return detail::creation_time(p, &ec); }
|
||||
inline
|
||||
std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}
|
||||
inline void create_directory_symlink(path const& to, path const& from)
|
||||
{
|
||||
detail::create_directory_symlink(to, from);
|
||||
}
|
||||
|
||||
inline
|
||||
std::time_t last_write_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::last_write_time(p, &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 void create_directory_symlink(path const& to, path const& from, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::create_directory_symlink(to, from, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
path read_symlink(const path& p) {return detail::read_symlink(p);}
|
||||
inline void create_hard_link(path const& to, path const& new_hard_link)
|
||||
{
|
||||
detail::create_hard_link(to, new_hard_link);
|
||||
}
|
||||
|
||||
inline
|
||||
path read_symlink(const path& p, system::error_code& ec)
|
||||
{return detail::read_symlink(p, &ec);}
|
||||
inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::create_hard_link(to, new_hard_link, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
bool remove(const path& p) {return detail::remove(p);}
|
||||
inline void create_symlink(path const& to, path const& new_symlink)
|
||||
{
|
||||
detail::create_symlink(to, new_symlink);
|
||||
}
|
||||
|
||||
inline
|
||||
bool remove(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::remove(p, &ec);}
|
||||
inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
detail::create_symlink(to, new_symlink, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}
|
||||
inline bool equivalent(path const& p1, path const& p2)
|
||||
{
|
||||
return detail::equivalent(p1, p2);
|
||||
}
|
||||
|
||||
inline
|
||||
boost::uintmax_t remove_all(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::remove_all(p, &ec);}
|
||||
inline
|
||||
void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}
|
||||
inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::equivalent(p1, p2, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
void rename(const path& old_p, const path& new_p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{detail::rename(old_p, new_p, &ec);}
|
||||
inline // name suggested by Scott McMurray
|
||||
void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}
|
||||
inline boost::uintmax_t file_size(path const& p)
|
||||
{
|
||||
return detail::file_size(p);
|
||||
}
|
||||
|
||||
inline
|
||||
void resize_file(const path& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{detail::resize_file(p, size, &ec);}
|
||||
inline
|
||||
path relative(const path& p, const path& base=current_path())
|
||||
{return detail::relative(p, base);}
|
||||
inline
|
||||
path relative(const path& p, system::error_code& ec)
|
||||
inline boost::uintmax_t file_size(path const& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::file_size(p, &ec);
|
||||
}
|
||||
|
||||
inline boost::uintmax_t hard_link_count(path const& p)
|
||||
{
|
||||
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);
|
||||
if (ec)
|
||||
return path();
|
||||
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
|
||||
space_info space(const path& p, system::error_code& ec) BOOST_NOEXCEPT
|
||||
{return detail::space(p, &ec);}
|
||||
inline path relative(path const& p, path const& base, system::error_code& 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
|
||||
inline bool symbolic_link_exists(const path& p)
|
||||
{ return is_symlink(filesystem::symlink_status(p)); }
|
||||
inline bool symbolic_link_exists(path const& p)
|
||||
{
|
||||
return is_symlink(filesystem::symlink_status(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
path system_complete(const path& p) {return detail::system_complete(p);}
|
||||
inline path system_complete(path const& p)
|
||||
{
|
||||
return detail::system_complete(p);
|
||||
}
|
||||
|
||||
inline
|
||||
path system_complete(const path& p, system::error_code& ec)
|
||||
{return detail::system_complete(p, &ec);}
|
||||
inline
|
||||
path temp_directory_path() {return detail::temp_directory_path();}
|
||||
inline path system_complete(path const& p, system::error_code& ec)
|
||||
{
|
||||
return detail::system_complete(p, &ec);
|
||||
}
|
||||
|
||||
inline
|
||||
path temp_directory_path(system::error_code& ec)
|
||||
{return detail::temp_directory_path(&ec);}
|
||||
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 path temp_directory_path()
|
||||
{
|
||||
return detail::temp_directory_path();
|
||||
}
|
||||
|
||||
inline
|
||||
path weakly_canonical(const path& p, system::error_code& ec)
|
||||
{return detail::weakly_canonical(p, &ec);}
|
||||
inline path temp_directory_path(system::error_code& 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 -----------------------------------------------------------------------//
|
||||
|
||||
@ -548,4 +711,5 @@ BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP
|
||||
|
@ -43,10 +43,8 @@
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
namespace path_detail // intentionally don't use filesystem::detail to not bring internal Boost.Filesystem functions into ADL via path_constants
|
||||
{
|
||||
|
||||
@ -90,15 +88,12 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
>
|
||||
{
|
||||
public:
|
||||
|
||||
// value_type is the character type used by the operating system API to
|
||||
// represent paths.
|
||||
|
||||
typedef path_constants_base::value_type value_type;
|
||||
typedef std::basic_string< value_type > string_type;
|
||||
typedef std::codecvt<wchar_t, char,
|
||||
std::mbstate_t> codecvt_type;
|
||||
|
||||
typedef std::codecvt< wchar_t, char, std::mbstate_t > codecvt_type;
|
||||
|
||||
// ----- character encoding conversions -----
|
||||
|
||||
@ -158,19 +153,17 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// ----- constructors -----
|
||||
|
||||
path() BOOST_NOEXCEPT {}
|
||||
path(const path& p) : m_pathname(p.m_pathname) {}
|
||||
path(path const& p) : m_pathname(p.m_pathname) {}
|
||||
|
||||
template< class Source >
|
||||
path(Source const& source,
|
||||
typename boost::enable_if<path_traits::is_pathable<
|
||||
typename boost::decay<Source>::type> >::type* =0)
|
||||
path(Source const& source, typename boost::enable_if< path_traits::is_pathable< typename boost::decay< Source >::type > >::type* = 0)
|
||||
{
|
||||
path_traits::dispatch(source, m_pathname);
|
||||
}
|
||||
|
||||
path(const value_type* s) : m_pathname(s) {}
|
||||
path(value_type* s) : m_pathname(s) {}
|
||||
path(const string_type& s) : m_pathname(s) {}
|
||||
path(string_type const& s) : m_pathname(s) {}
|
||||
path(string_type& s) : m_pathname(s) {}
|
||||
|
||||
// As of October 2015 the interaction between noexcept and =default is so troublesome
|
||||
@ -178,13 +171,18 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// functions. GCC is not even consistent for the same release on different platforms.
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
path(path&& p) BOOST_NOEXCEPT : m_pathname(std::move(p.m_pathname)) {}
|
||||
path(path&& p) BOOST_NOEXCEPT : m_pathname(std::move(p.m_pathname))
|
||||
{
|
||||
}
|
||||
path& operator=(path&& p) BOOST_NOEXCEPT
|
||||
{ m_pathname = std::move(p.m_pathname); return *this; }
|
||||
{
|
||||
m_pathname = std::move(p.m_pathname);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class Source >
|
||||
path(Source const& source, const codecvt_type& cvt)
|
||||
path(Source const& source, codecvt_type const& cvt)
|
||||
{
|
||||
path_traits::dispatch(source, m_pathname, cvt);
|
||||
}
|
||||
@ -195,35 +193,32 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
if (begin != end)
|
||||
{
|
||||
// convert requires contiguous string, so copy
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname);
|
||||
}
|
||||
}
|
||||
|
||||
template< class InputIterator >
|
||||
path(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
||||
path(InputIterator begin, InputIterator end, codecvt_type const& cvt)
|
||||
{
|
||||
if (begin != end)
|
||||
{
|
||||
// convert requires contiguous string, so copy
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname, cvt);
|
||||
}
|
||||
}
|
||||
|
||||
// ----- assignments -----
|
||||
|
||||
path& operator=(const path& p)
|
||||
path& operator=(path const& p)
|
||||
{
|
||||
m_pathname = p.m_pathname;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class Source >
|
||||
typename boost::enable_if<path_traits::is_pathable<
|
||||
typename boost::decay<Source>::type>, path&>::type
|
||||
typename boost::enable_if< path_traits::is_pathable< typename boost::decay< Source >::type >, path& >::type
|
||||
operator=(Source const& source)
|
||||
{
|
||||
m_pathname.clear();
|
||||
@ -234,16 +229,37 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// value_type overloads
|
||||
|
||||
path& operator=(const value_type* ptr) // required in case ptr overlaps *this
|
||||
{m_pathname = ptr; return *this;}
|
||||
path& operator=(value_type* ptr) // required in case ptr overlaps *this
|
||||
{m_pathname = ptr; return *this;}
|
||||
path& operator=(const string_type& s) {m_pathname = s; return *this;}
|
||||
path& operator=(string_type& s) {m_pathname = s; return *this;}
|
||||
{
|
||||
m_pathname = ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator=(value_type* ptr) // required in case ptr overlaps *this
|
||||
{
|
||||
m_pathname = ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator=(string_type const& s)
|
||||
{
|
||||
m_pathname = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator=(string_type& s)
|
||||
{
|
||||
m_pathname = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& assign(const value_type* ptr, codecvt_type const&) // required in case ptr overlaps *this
|
||||
{
|
||||
m_pathname = ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& assign(const value_type* ptr, const codecvt_type&) // required in case ptr overlaps *this
|
||||
{m_pathname = ptr; return *this;}
|
||||
template< class Source >
|
||||
path& assign(Source const& source, const codecvt_type& cvt)
|
||||
path& assign(Source const& source, codecvt_type const& cvt)
|
||||
{
|
||||
m_pathname.clear();
|
||||
path_traits::dispatch(source, m_pathname, cvt);
|
||||
@ -256,21 +272,19 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
m_pathname.clear();
|
||||
if (begin != end)
|
||||
{
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class InputIterator >
|
||||
path& assign(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
||||
path& assign(InputIterator begin, InputIterator end, codecvt_type const& cvt)
|
||||
{
|
||||
m_pathname.clear();
|
||||
if (begin != end)
|
||||
{
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname, cvt);
|
||||
}
|
||||
return *this;
|
||||
@ -279,20 +293,47 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// ----- concatenation -----
|
||||
|
||||
template< class Source >
|
||||
typename boost::enable_if<path_traits::is_pathable<
|
||||
typename boost::decay<Source>::type>, path&>::type
|
||||
typename boost::enable_if< path_traits::is_pathable< typename boost::decay< Source >::type >, path& >::type
|
||||
operator+=(Source const& source)
|
||||
{
|
||||
return concat(source);
|
||||
}
|
||||
|
||||
// value_type overloads. Same rationale as for constructors above
|
||||
path& operator+=(const path& p) { m_pathname += p.m_pathname; return *this; }
|
||||
path& operator+=(const value_type* ptr) { m_pathname += ptr; return *this; }
|
||||
path& operator+=(value_type* ptr) { m_pathname += ptr; return *this; }
|
||||
path& operator+=(const string_type& s) { m_pathname += s; return *this; }
|
||||
path& operator+=(string_type& s) { m_pathname += s; return *this; }
|
||||
path& operator+=(value_type c) { m_pathname += c; return *this; }
|
||||
path& operator+=(path const& p)
|
||||
{
|
||||
m_pathname += p.m_pathname;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator+=(const value_type* ptr)
|
||||
{
|
||||
m_pathname += ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator+=(value_type* ptr)
|
||||
{
|
||||
m_pathname += ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator+=(string_type const& s)
|
||||
{
|
||||
m_pathname += s;
|
||||
return *this;
|
||||
}
|
||||
path& operator+=(string_type& s)
|
||||
{
|
||||
m_pathname += s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& operator+=(value_type c)
|
||||
{
|
||||
m_pathname += c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class CharT >
|
||||
typename boost::enable_if< boost::is_integral< CharT >, path& >::type
|
||||
@ -312,7 +353,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
}
|
||||
|
||||
template< class Source >
|
||||
path& concat(Source const& source, const codecvt_type& cvt)
|
||||
path& concat(Source const& source, codecvt_type const& cvt)
|
||||
{
|
||||
path_traits::dispatch(source, m_pathname, cvt);
|
||||
return *this;
|
||||
@ -323,19 +364,17 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
{
|
||||
if (begin == end)
|
||||
return *this;
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class InputIterator >
|
||||
path& concat(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
||||
path& concat(InputIterator begin, InputIterator end, codecvt_type const& cvt)
|
||||
{
|
||||
if (begin == end)
|
||||
return *this;
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname, cvt);
|
||||
return *this;
|
||||
}
|
||||
@ -345,11 +384,10 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// if a separator is added, it is the preferred separator for the platform;
|
||||
// slash for POSIX, backslash for Windows
|
||||
|
||||
BOOST_FILESYSTEM_DECL path& operator/=(const path& p);
|
||||
BOOST_FILESYSTEM_DECL path& operator/=(path const& p);
|
||||
|
||||
template< class Source >
|
||||
typename boost::enable_if<path_traits::is_pathable<
|
||||
typename boost::decay<Source>::type>, path&>::type
|
||||
typename boost::enable_if< path_traits::is_pathable< typename boost::decay< Source >::type >, path& >::type
|
||||
operator/=(Source const& source)
|
||||
{
|
||||
return append(source);
|
||||
@ -360,7 +398,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
{
|
||||
return this->operator/=(const_cast< const value_type* >(ptr));
|
||||
}
|
||||
path& operator/=(const string_type& s) { return this->operator/=(path(s)); }
|
||||
path& operator/=(string_type const& s) { return this->operator/=(path(s)); }
|
||||
path& operator/=(string_type& s) { return this->operator/=(path(s)); }
|
||||
|
||||
path& append(const value_type* ptr) // required in case ptr overlaps *this
|
||||
@ -369,7 +407,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
return *this;
|
||||
}
|
||||
|
||||
path& append(const value_type* ptr, const codecvt_type&) // required in case ptr overlaps *this
|
||||
path& append(const value_type* ptr, codecvt_type const&) // required in case ptr overlaps *this
|
||||
{
|
||||
this->operator/=(ptr);
|
||||
return *this;
|
||||
@ -379,7 +417,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
path& append(Source const& source);
|
||||
|
||||
template< class Source >
|
||||
path& append(Source const& source, const codecvt_type& cvt);
|
||||
path& append(Source const& source, codecvt_type const& cvt);
|
||||
|
||||
template< class InputIterator >
|
||||
path& append(InputIterator begin, InputIterator end);
|
||||
@ -391,7 +429,11 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
void clear() BOOST_NOEXCEPT { m_pathname.clear(); }
|
||||
#ifdef BOOST_POSIX_API
|
||||
path& make_preferred() { return *this; } // POSIX no effect
|
||||
path& make_preferred()
|
||||
{
|
||||
// No effect on POSIX
|
||||
return *this;
|
||||
}
|
||||
#else // BOOST_WINDOWS_API
|
||||
BOOST_FILESYSTEM_DECL path& make_preferred(); // change slashes to backslashes
|
||||
#endif
|
||||
@ -429,48 +471,44 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
String string() const;
|
||||
|
||||
template< class String >
|
||||
String string(const codecvt_type& cvt) const;
|
||||
String string(codecvt_type const& cvt) const;
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::string string() const
|
||||
{
|
||||
std::string tmp;
|
||||
if (!m_pathname.empty())
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
||||
tmp);
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str() + m_pathname.size(), tmp);
|
||||
return tmp;
|
||||
}
|
||||
std::string string(const codecvt_type& cvt) const
|
||||
std::string string(codecvt_type const& cvt) const
|
||||
{
|
||||
std::string tmp;
|
||||
if (!m_pathname.empty())
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
||||
tmp, cvt);
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str() + m_pathname.size(), tmp, cvt);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// string_type is std::wstring, so there is no conversion
|
||||
const std::wstring& wstring() const { return m_pathname; }
|
||||
const std::wstring& wstring(const codecvt_type&) const { return m_pathname; }
|
||||
const std::wstring& wstring(codecvt_type const&) const { return m_pathname; }
|
||||
#else // BOOST_POSIX_API
|
||||
// string_type is std::string, so there is no conversion
|
||||
const std::string& string() const { return m_pathname; }
|
||||
const std::string& string(const codecvt_type&) const { return m_pathname; }
|
||||
const std::string& string(codecvt_type const&) const { return m_pathname; }
|
||||
|
||||
std::wstring wstring() const
|
||||
{
|
||||
std::wstring tmp;
|
||||
if (!m_pathname.empty())
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
||||
tmp);
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str() + m_pathname.size(), tmp);
|
||||
return tmp;
|
||||
}
|
||||
std::wstring wstring(const codecvt_type& cvt) const
|
||||
std::wstring wstring(codecvt_type const& cvt) const
|
||||
{
|
||||
std::wstring tmp;
|
||||
if (!m_pathname.empty())
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
||||
tmp, cvt);
|
||||
path_traits::convert(m_pathname.c_str(), m_pathname.c_str() + m_pathname.size(), tmp, cvt);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
@ -490,25 +528,25 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
String generic_string() const;
|
||||
|
||||
template< class String >
|
||||
String generic_string(const codecvt_type& cvt) const;
|
||||
String generic_string(codecvt_type const& cvt) const;
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::string generic_string() const { return generic_path().string(); }
|
||||
std::string generic_string(const codecvt_type& cvt) const { return generic_path().string(cvt); }
|
||||
std::string generic_string(codecvt_type const& cvt) const { return generic_path().string(cvt); }
|
||||
std::wstring generic_wstring() const { return generic_path().wstring(); }
|
||||
std::wstring generic_wstring(const codecvt_type&) const { return generic_wstring(); }
|
||||
std::wstring generic_wstring(codecvt_type const&) const { return generic_wstring(); }
|
||||
#else // BOOST_POSIX_API
|
||||
// On POSIX-like systems, the generic format is the same as the native format
|
||||
const std::string& generic_string() const { return m_pathname; }
|
||||
const std::string& generic_string(const codecvt_type&) const { return m_pathname; }
|
||||
const std::string& generic_string(codecvt_type const&) const { return m_pathname; }
|
||||
std::wstring generic_wstring() const { return this->wstring(); }
|
||||
std::wstring generic_wstring(const codecvt_type& cvt) const { return this->wstring(cvt); }
|
||||
std::wstring generic_wstring(codecvt_type const& cvt) const { return this->wstring(cvt); }
|
||||
#endif
|
||||
|
||||
// ----- compare -----
|
||||
|
||||
BOOST_FILESYSTEM_DECL int compare(const path& p) const BOOST_NOEXCEPT; // generic, lexicographical
|
||||
int compare(const std::string& s) const { return compare(path(s)); }
|
||||
BOOST_FILESYSTEM_DECL int compare(path const& p) const BOOST_NOEXCEPT; // generic, lexicographical
|
||||
int compare(std::string const& s) const { return compare(path(s)); }
|
||||
int compare(const value_type* s) const { return compare(path(s)); }
|
||||
|
||||
// ----- decomposition -----
|
||||
@ -582,7 +620,8 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
||||
// recently deprecated functions supplied by default
|
||||
path& normalize() {
|
||||
path& normalize()
|
||||
{
|
||||
path tmp(lexically_normal());
|
||||
m_pathname.swap(tmp.m_pathname);
|
||||
return *this;
|
||||
@ -622,18 +661,18 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
private:
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push) // Save warning settings
|
||||
#pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>'
|
||||
#endif // needs to have dll-interface...
|
||||
|
||||
/*
|
||||
m_pathname has the type, encoding, and format required by the native
|
||||
operating system. Thus for POSIX and Windows there is no conversion for
|
||||
passing m_pathname.c_str() to the O/S API or when obtaining a path from the
|
||||
O/S API. POSIX encoding is unspecified other than for dot and slash
|
||||
characters; POSIX just treats paths as a sequence of bytes. Windows
|
||||
encoding is UCS-2 or UTF-16 depending on the version.
|
||||
* m_pathname has the type, encoding, and format required by the native
|
||||
* operating system. Thus for POSIX and Windows there is no conversion for
|
||||
* passing m_pathname.c_str() to the O/S API or when obtaining a path from the
|
||||
* O/S API. POSIX encoding is unspecified other than for dot and slash
|
||||
* characters; POSIX just treats paths as a sequence of bytes. Windows
|
||||
* encoding is UCS-2 or UTF-16 depending on the version.
|
||||
*/
|
||||
string_type m_pathname; // Windows: as input; backslashes NOT converted to slashes,
|
||||
// slashes NOT converted to backslashes
|
||||
@ -651,7 +690,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// Was qualified; como433beta8 reports:
|
||||
// warning #427-D: qualified name is not allowed in member declaration
|
||||
friend class iterator;
|
||||
friend bool operator<(const path& lhs, const path& rhs);
|
||||
friend bool operator<(path const& lhs, path const& rhs);
|
||||
|
||||
// see path::iterator::increment/decrement comment below
|
||||
static BOOST_FILESYSTEM_DECL void m_path_iterator_increment(path::iterator& it);
|
||||
@ -659,16 +698,11 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
}; // class path
|
||||
|
||||
namespace detail
|
||||
{
|
||||
BOOST_FILESYSTEM_DECL
|
||||
int lex_compare(path::iterator first1, path::iterator last1,
|
||||
path::iterator first2, path::iterator last2);
|
||||
BOOST_FILESYSTEM_DECL
|
||||
const path& dot_path();
|
||||
BOOST_FILESYSTEM_DECL
|
||||
const path& dot_dot_path();
|
||||
}
|
||||
namespace detail {
|
||||
BOOST_FILESYSTEM_DECL int lex_compare(path::iterator first1, path::iterator last1, path::iterator first2, path::iterator last2);
|
||||
BOOST_FILESYSTEM_DECL const path& dot_path();
|
||||
BOOST_FILESYSTEM_DECL const path& dot_dot_path();
|
||||
} // namespace detail
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
typedef path wpath;
|
||||
@ -678,11 +712,12 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// class path::iterator //
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
class path::iterator
|
||||
: public boost::iterator_facade<
|
||||
class path::iterator :
|
||||
public boost::iterator_facade<
|
||||
path::iterator,
|
||||
path const,
|
||||
boost::bidirectional_traversal_tag >
|
||||
const path,
|
||||
boost::bidirectional_traversal_tag
|
||||
>
|
||||
{
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
@ -703,28 +738,33 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
void increment() { m_path_iterator_increment(*this); }
|
||||
void decrement() { m_path_iterator_decrement(*this); }
|
||||
|
||||
path m_element; // current element
|
||||
const path* m_path_ptr; // path being iterated over
|
||||
string_type::size_type m_pos; // position of m_element in
|
||||
// m_path_ptr->m_pathname.
|
||||
private:
|
||||
// current element
|
||||
path m_element;
|
||||
// path being iterated over
|
||||
const path* m_path_ptr;
|
||||
// position of m_element in m_path_ptr->m_pathname.
|
||||
// if m_element is implicit dot, m_pos is the
|
||||
// position of the last separator in the path.
|
||||
// end() iterator is indicated by
|
||||
// m_pos == m_path_ptr->m_pathname.size()
|
||||
}; // path::iterator
|
||||
string_type::size_type m_pos;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------//
|
||||
// class path::reverse_iterator //
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
class path::reverse_iterator
|
||||
: public boost::iterator_facade<
|
||||
class path::reverse_iterator :
|
||||
public boost::iterator_facade<
|
||||
path::reverse_iterator,
|
||||
path const,
|
||||
boost::bidirectional_traversal_tag >
|
||||
const path,
|
||||
boost::bidirectional_traversal_tag
|
||||
>
|
||||
{
|
||||
public:
|
||||
explicit reverse_iterator(iterator itr) : m_itr(itr)
|
||||
explicit reverse_iterator(iterator itr) :
|
||||
m_itr(itr)
|
||||
{
|
||||
if (itr != itr.m_path_ptr->begin())
|
||||
m_element = *--itr;
|
||||
@ -736,6 +776,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
const path& dereference() const { return m_element; }
|
||||
bool equal(const reverse_iterator& rhs) const { return m_itr == rhs.m_itr; }
|
||||
|
||||
void increment()
|
||||
{
|
||||
--m_itr;
|
||||
@ -745,16 +786,17 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
m_element = *--tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void decrement()
|
||||
{
|
||||
m_element = *m_itr;
|
||||
++m_itr;
|
||||
}
|
||||
|
||||
private:
|
||||
iterator m_itr;
|
||||
path m_element;
|
||||
|
||||
}; // path::reverse_iterator
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------//
|
||||
// //
|
||||
@ -764,30 +806,81 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
// std::lexicographical_compare would infinitely recurse because path iterators
|
||||
// yield paths, so provide a path aware version
|
||||
inline bool lexicographical_compare(path::iterator first1, path::iterator last1,
|
||||
path::iterator first2, path::iterator last2)
|
||||
{ return detail::lex_compare(first1, last1, first2, last2) < 0; }
|
||||
inline bool lexicographical_compare(path::iterator first1, path::iterator last1, path::iterator first2, path::iterator last2)
|
||||
{
|
||||
return detail::lex_compare(first1, last1, first2, last2) < 0;
|
||||
}
|
||||
|
||||
inline bool operator==(const path& lhs, const path& rhs) {return lhs.compare(rhs) == 0;}
|
||||
inline bool operator==(const path& lhs, const path::string_type& rhs) {return lhs.compare(rhs) == 0;}
|
||||
inline bool operator==(const path::string_type& lhs, const path& rhs) {return rhs.compare(lhs) == 0;}
|
||||
inline bool operator==(const path& lhs, const path::value_type* rhs) {return lhs.compare(rhs) == 0;}
|
||||
inline bool operator==(const path::value_type* lhs, const path& rhs) {return rhs.compare(lhs) == 0;}
|
||||
inline bool operator==(path const& lhs, path const& rhs)
|
||||
{
|
||||
return lhs.compare(rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(const path& lhs, const path& rhs) {return lhs.compare(rhs) != 0;}
|
||||
inline bool operator!=(const path& lhs, const path::string_type& rhs) {return lhs.compare(rhs) != 0;}
|
||||
inline bool operator!=(const path::string_type& lhs, const path& rhs) {return rhs.compare(lhs) != 0;}
|
||||
inline bool operator!=(const path& lhs, const path::value_type* rhs) {return lhs.compare(rhs) != 0;}
|
||||
inline bool operator!=(const path::value_type* lhs, const path& rhs) {return rhs.compare(lhs) != 0;}
|
||||
inline bool operator==(path const& lhs, path::string_type const& rhs)
|
||||
{
|
||||
return lhs.compare(rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool operator==(path::string_type const& lhs, path const& rhs)
|
||||
{
|
||||
return rhs.compare(lhs) == 0;
|
||||
}
|
||||
|
||||
inline bool operator==(path const& lhs, const path::value_type* rhs)
|
||||
{
|
||||
return lhs.compare(rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool operator==(const path::value_type* lhs, path const& rhs)
|
||||
{
|
||||
return rhs.compare(lhs) == 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(path const& lhs, path const& rhs)
|
||||
{
|
||||
return lhs.compare(rhs) != 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(path const& lhs, path::string_type const& rhs)
|
||||
{
|
||||
return lhs.compare(rhs) != 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(path::string_type const& lhs, path const& rhs)
|
||||
{
|
||||
return rhs.compare(lhs) != 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(path const& lhs, const path::value_type* rhs)
|
||||
{
|
||||
return lhs.compare(rhs) != 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(const path::value_type* lhs, path const& rhs)
|
||||
{
|
||||
return rhs.compare(lhs) != 0;
|
||||
}
|
||||
|
||||
// TODO: why do == and != have additional overloads, but the others don't?
|
||||
|
||||
inline bool operator<(const path& lhs, const path& rhs) {return lhs.compare(rhs) < 0;}
|
||||
inline bool operator<=(const path& lhs, const path& rhs) {return !(rhs < lhs);}
|
||||
inline bool operator> (const path& lhs, const path& rhs) {return rhs < lhs;}
|
||||
inline bool operator>=(const path& lhs, const path& rhs) {return !(lhs < rhs);}
|
||||
inline bool operator<(path const& lhs, path const& rhs)
|
||||
{
|
||||
return lhs.compare(rhs) < 0;
|
||||
}
|
||||
inline bool operator<=(path const& lhs, path const& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
inline bool operator>(path const& lhs, path const& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
inline bool operator>=(path const& lhs, path const& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(const path& x) BOOST_NOEXCEPT
|
||||
inline std::size_t hash_value(path const& x) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::size_t seed = 0;
|
||||
@ -799,16 +892,20 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void swap(path& lhs, path& rhs) BOOST_NOEXCEPT { lhs.swap(rhs); }
|
||||
inline void swap(path& lhs, path& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
inline path operator/(const path& lhs, const path& rhs)
|
||||
inline path operator/(path const& lhs, path const& rhs)
|
||||
{
|
||||
path p = lhs;
|
||||
p /= rhs;
|
||||
return p;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
inline path operator/(path&& lhs, const path& rhs)
|
||||
inline path operator/(path&& lhs, path const& rhs)
|
||||
{
|
||||
lhs /= rhs;
|
||||
return std::move(lhs);
|
||||
@ -821,10 +918,9 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
template< class Char, class Traits >
|
||||
inline std::basic_ostream< Char, Traits >&
|
||||
operator<<(std::basic_ostream<Char, Traits>& os, const path& p)
|
||||
operator<<(std::basic_ostream< Char, Traits >& os, path const& p)
|
||||
{
|
||||
return os
|
||||
<< boost::io::quoted(p.template string<std::basic_string<Char> >(), static_cast<Char>('&'));
|
||||
return os << boost::io::quoted(p.template string< std::basic_string< Char > >(), static_cast< Char >('&'));
|
||||
}
|
||||
|
||||
template< class Char, class Traits >
|
||||
@ -842,20 +938,19 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// These functions are holdovers from version 1. It isn't clear they have much
|
||||
// usefulness, or how to generalize them for later versions.
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool windows_name(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_name(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool native(const std::string & name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_posix_name(std::string const& name);
|
||||
BOOST_FILESYSTEM_DECL bool windows_name(std::string const& name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_name(std::string const& name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_directory_name(std::string const& name);
|
||||
BOOST_FILESYSTEM_DECL bool portable_file_name(std::string const& name);
|
||||
BOOST_FILESYSTEM_DECL bool native(std::string const& name);
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// For POSIX, is_directory_separator() and is_element_separator() are identical since
|
||||
// a forward slash is the only valid directory separator and also the only valid
|
||||
// element separator. For Windows, forward slash and back slash are the possible
|
||||
// directory separators, but colon (example: "c:foo") is also an element separator.
|
||||
|
||||
inline bool is_directory_separator(path::value_type c) BOOST_NOEXCEPT
|
||||
{
|
||||
return c == path::separator
|
||||
@ -864,6 +959,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
inline bool is_element_separator(path::value_type c) BOOST_NOEXCEPT
|
||||
{
|
||||
return c == path::separator
|
||||
@ -872,14 +968,21 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//------------------------------------------------------------------------------------//
|
||||
// class path miscellaneous function implementations //
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
inline path::reverse_iterator path::rbegin() const { return reverse_iterator(end()); }
|
||||
inline path::reverse_iterator path::rend() const { return reverse_iterator(begin()); }
|
||||
inline path::reverse_iterator path::rbegin() const
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
inline path::reverse_iterator path::rend() const
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
inline bool path::filename_is_dot() const
|
||||
{
|
||||
@ -891,8 +994,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
|
||||
inline bool path::filename_is_dot_dot() const
|
||||
{
|
||||
return size() >= 2 && m_pathname[size()-1] == dot && m_pathname[size()-2] == dot
|
||||
&& (m_pathname.size() == 2 || detail::is_element_separator(m_pathname[size()-3]));
|
||||
return size() >= 2 && m_pathname[size() - 1] == dot && m_pathname[size() - 2] == dot && (m_pathname.size() == 2 || detail::is_element_separator(m_pathname[size() - 3]));
|
||||
// use detail::is_element_separator() rather than detail::is_directory_separator
|
||||
// to deal with "c:.." edge case on Windows when ':' acts as a separator
|
||||
}
|
||||
@ -907,8 +1009,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
if (begin == end)
|
||||
return *this;
|
||||
string_type::size_type sep_pos(m_append_separator_if_needed());
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname);
|
||||
if (sep_pos)
|
||||
m_erase_redundant_separator(sep_pos);
|
||||
@ -916,13 +1017,12 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
}
|
||||
|
||||
template< class InputIterator >
|
||||
path& path::append(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
||||
path& path::append(InputIterator begin, InputIterator end, codecvt_type const& cvt)
|
||||
{
|
||||
if (begin == end)
|
||||
return *this;
|
||||
string_type::size_type sep_pos(m_append_separator_if_needed());
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
seq(begin, end);
|
||||
std::basic_string< typename std::iterator_traits< InputIterator >::value_type > seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str() + seq.size(), m_pathname, cvt);
|
||||
if (sep_pos)
|
||||
m_erase_redundant_separator(sep_pos);
|
||||
@ -942,7 +1042,7 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
}
|
||||
|
||||
template< class Source >
|
||||
path& path::append(Source const& source, const codecvt_type& cvt)
|
||||
path& path::append(Source const& source, codecvt_type const& cvt)
|
||||
{
|
||||
if (path_traits::empty(source))
|
||||
return *this;
|
||||
@ -957,45 +1057,60 @@ namespace path_detail // intentionally don't use filesystem::detail to not bring
|
||||
// class path member template specializations //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template <> inline
|
||||
std::string path::string<std::string>() const
|
||||
{ return string(); }
|
||||
template<>
|
||||
inline std::string path::string< std::string >() const
|
||||
{
|
||||
return string();
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::wstring path::string<std::wstring>() const
|
||||
{ return wstring(); }
|
||||
template<>
|
||||
inline std::wstring path::string< std::wstring >() const
|
||||
{
|
||||
return wstring();
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::string path::string<std::string>(const codecvt_type& cvt) const
|
||||
{ return string(cvt); }
|
||||
template<>
|
||||
inline std::string path::string< std::string >(const codecvt_type& cvt) const
|
||||
{
|
||||
return string(cvt);
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::wstring path::string<std::wstring>(const codecvt_type& cvt) const
|
||||
{ return wstring(cvt); }
|
||||
template<>
|
||||
inline std::wstring path::string< std::wstring >(const codecvt_type& cvt) const
|
||||
{
|
||||
return wstring(cvt);
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::string path::generic_string<std::string>() const
|
||||
{ return generic_string(); }
|
||||
template<>
|
||||
inline std::string path::generic_string< std::string >() const
|
||||
{
|
||||
return generic_string();
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::wstring path::generic_string<std::wstring>() const
|
||||
{ return generic_wstring(); }
|
||||
template<>
|
||||
inline std::wstring path::generic_string< std::wstring >() const
|
||||
{
|
||||
return generic_wstring();
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::string path::generic_string<std::string>(const codecvt_type& cvt) const
|
||||
{ return generic_string(cvt); }
|
||||
template<>
|
||||
inline std::string path::generic_string< std::string >(codecvt_type const& cvt) const
|
||||
{
|
||||
return generic_string(cvt);
|
||||
}
|
||||
|
||||
template <> inline
|
||||
std::wstring path::generic_string<std::wstring>(const codecvt_type& cvt) const
|
||||
{ return generic_wstring(cvt); }
|
||||
template<>
|
||||
inline std::wstring path::generic_string< std::wstring >(codecvt_type const& cvt) const
|
||||
{
|
||||
return generic_wstring(cvt);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// path_traits convert function implementations //
|
||||
// requiring path::codecvt() be visable //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace path_traits
|
||||
{ // without codecvt
|
||||
namespace path_traits { // without codecvt
|
||||
|
||||
inline void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
@ -1011,19 +1126,18 @@ namespace path_traits
|
||||
convert(from, from_end, to, path::codecvt());
|
||||
}
|
||||
|
||||
inline void convert(const char* from,
|
||||
std::wstring & to)
|
||||
inline void convert(const char* from, std::wstring& to)
|
||||
{
|
||||
BOOST_ASSERT(!!from);
|
||||
convert(from, 0, to, path::codecvt());
|
||||
}
|
||||
|
||||
inline void convert(const wchar_t* from,
|
||||
std::string & to)
|
||||
inline void convert(const wchar_t* from, std::string& to)
|
||||
{
|
||||
BOOST_ASSERT(!!from);
|
||||
convert(from, 0, to, path::codecvt());
|
||||
}
|
||||
|
||||
} // namespace path_traits
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <cstddef>
|
||||
#include <cwchar> // for mbstate_t
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -32,7 +33,8 @@
|
||||
|
||||
#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();
|
||||
// uses std::codecvt_base::result used for error codes:
|
||||
@ -54,39 +56,101 @@ namespace path_traits {
|
||||
// is_pathable type trait; allows disabling over-agressive class path member templates
|
||||
|
||||
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<> struct is_pathable<const char*> { static const bool value = true; };
|
||||
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; };
|
||||
template<>
|
||||
struct is_pathable< char* >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct is_pathable< const char* >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
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
|
||||
template< class Container >
|
||||
inline
|
||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||
// conforming compilers. Replace by plain "bool" at some future date (2012?)
|
||||
typename boost::disable_if< boost::is_array< Container >, bool >::type
|
||||
empty(const Container & c)
|
||||
{ return c.begin() == c.end(); }
|
||||
empty(Container const& c)
|
||||
{
|
||||
return c.begin() == c.end();
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
bool empty(T * const & c_str)
|
||||
template< class T >
|
||||
inline bool empty(T* const& c_str)
|
||||
{
|
||||
BOOST_ASSERT(c_str);
|
||||
return !*c_str;
|
||||
}
|
||||
|
||||
template <typename T, size_t N> inline
|
||||
bool empty(T (&x)[N])
|
||||
{ return !x[0]; }
|
||||
template< typename T, std::size_t N >
|
||||
inline bool empty(T (&x)[N])
|
||||
{
|
||||
return !x[0];
|
||||
}
|
||||
|
||||
// value types differ ---------------------------------------------------------------//
|
||||
//
|
||||
@ -97,28 +161,20 @@ namespace path_traits {
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
std::wstring & to,
|
||||
const codecvt_type& cvt);
|
||||
std::wstring& to, codecvt_type const& cvt);
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const wchar_t* from,
|
||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||
std::string & to,
|
||||
const codecvt_type& cvt);
|
||||
std::string& to, codecvt_type const& cvt);
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::wstring & to,
|
||||
const codecvt_type& cvt)
|
||||
inline void convert(const char* from, std::wstring& to, codecvt_type const& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
convert(from, 0, to, cvt);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::string & to,
|
||||
const codecvt_type& cvt)
|
||||
inline void convert(const wchar_t* from, std::string& to, codecvt_type const& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
convert(from, 0, to, cvt);
|
||||
@ -126,41 +182,30 @@ namespace path_traits {
|
||||
|
||||
// without codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
inline void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
std::wstring& to);
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
inline void convert(const wchar_t* from,
|
||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||
std::string& to);
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::wstring & to);
|
||||
inline void convert(const char* from, std::wstring& to);
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::string & to);
|
||||
inline void convert(const wchar_t* from, std::string& to);
|
||||
|
||||
// value types same -----------------------------------------------------------------//
|
||||
|
||||
// char with codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from, const char* from_end, std::string & to,
|
||||
const codecvt_type&)
|
||||
inline void convert(const char* from, const char* from_end, std::string& to, codecvt_type const&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::string & to,
|
||||
const codecvt_type&)
|
||||
inline void convert(const char* from, std::string& to, codecvt_type const&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
@ -168,19 +213,14 @@ namespace path_traits {
|
||||
|
||||
// wchar_t with codecvt
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
|
||||
const codecvt_type&)
|
||||
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to, codecvt_type const&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::wstring & to,
|
||||
const codecvt_type&)
|
||||
inline void convert(const wchar_t* from, std::wstring& to, codecvt_type const&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
@ -188,16 +228,14 @@ namespace path_traits {
|
||||
|
||||
// char without codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from, const char* from_end, std::string & to)
|
||||
inline void convert(const char* from, const char* from_end, std::string& to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const char* from, std::string & to)
|
||||
inline void convert(const char* from, std::string& to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
@ -205,16 +243,14 @@ namespace path_traits {
|
||||
|
||||
// wchar_t without codecvt
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to)
|
||||
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, std::wstring & to)
|
||||
inline void convert(const wchar_t* from, std::wstring& to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
@ -223,63 +259,64 @@ namespace path_traits {
|
||||
// Source dispatch -----------------------------------------------------------------//
|
||||
|
||||
// contiguous containers with codecvt
|
||||
template <class U> inline
|
||||
void dispatch(const std::string& c, U& to, const codecvt_type& cvt)
|
||||
template< class U >
|
||||
inline void dispatch(std::string const& c, U& to, codecvt_type const& cvt)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::wstring& c, U& to, const codecvt_type& cvt)
|
||||
template< class U >
|
||||
inline void dispatch(std::wstring const& c, U& to, codecvt_type const& cvt)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<char>& c, U& to, const codecvt_type& cvt)
|
||||
template< class U >
|
||||
inline void dispatch(std::vector< char > const& c, U& to, codecvt_type const& cvt)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<wchar_t>& c, U& to, const codecvt_type& cvt)
|
||||
template< class U >
|
||||
inline void dispatch(std::vector< wchar_t > const& c, U& to, codecvt_type const& cvt)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
|
||||
// contiguous containers without codecvt
|
||||
template <class U> inline
|
||||
void dispatch(const std::string& c, U& to)
|
||||
template< class U >
|
||||
inline void dispatch(std::string const& c, U& to)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::wstring& c, U& to)
|
||||
template< class U >
|
||||
inline void dispatch(std::wstring const& c, U& to)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<char>& c, U& to)
|
||||
template< class U >
|
||||
inline void dispatch(std::vector< char > const& c, U& to)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<wchar_t>& c, U& to)
|
||||
template< class U >
|
||||
inline void dispatch(std::vector< wchar_t > const& c, U& to)
|
||||
{
|
||||
if (!c.empty())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
|
||||
// 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
|
||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||
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())
|
||||
{
|
||||
@ -289,8 +326,8 @@ namespace path_traits {
|
||||
}
|
||||
|
||||
// c_str
|
||||
template <class T, class U> inline
|
||||
void dispatch(T * const & c_str, U& to, const codecvt_type& cvt)
|
||||
template< class T, class U >
|
||||
inline void dispatch(T* const& c_str, U& to, codecvt_type const& cvt)
|
||||
{
|
||||
// std::cout << "dispatch() const T *\n";
|
||||
BOOST_ASSERT(c_str);
|
||||
@ -301,20 +338,21 @@ namespace path_traits {
|
||||
// contain a string smaller than the array size.
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(const directory_entry & de,
|
||||
void dispatch(directory_entry const& de,
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::wstring& to,
|
||||
#else
|
||||
std::string& to,
|
||||
#endif
|
||||
const codecvt_type&);
|
||||
codecvt_type const&);
|
||||
|
||||
// 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
|
||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||
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())
|
||||
{
|
||||
@ -324,8 +362,8 @@ namespace path_traits {
|
||||
}
|
||||
|
||||
// c_str
|
||||
template <class T, class U> inline
|
||||
void dispatch(T * const & c_str, U& to)
|
||||
template< class T, class U >
|
||||
inline void dispatch(T* const& c_str, U& to)
|
||||
{
|
||||
// std::cout << "dispatch() const T *\n";
|
||||
BOOST_ASSERT(c_str);
|
||||
@ -336,7 +374,7 @@ namespace path_traits {
|
||||
// contain a string smaller than the array size.
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(const directory_entry & de,
|
||||
void dispatch(directory_entry const& de,
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::wstring& to
|
||||
#else
|
||||
@ -344,8 +382,9 @@ namespace path_traits {
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
}}} // namespace boost::filesystem::path_traits
|
||||
} // namespace path_traits
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
|
@ -10,34 +10,35 @@
|
||||
#ifndef BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||
#define BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <ios>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
inline
|
||||
void save_string_file(const path& p, const std::string& str)
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
inline void save_string_file(path const& p, std::string const& str)
|
||||
{
|
||||
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.write(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
inline
|
||||
void load_string_file(const path& p, std::string& str)
|
||||
inline void load_string_file(path const& p, std::string& str)
|
||||
{
|
||||
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);
|
||||
std::size_t sz = static_cast< std::size_t >(filesystem::file_size(p));
|
||||
str.resize(sz, '\0');
|
||||
file.read(&str[0], sz);
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
#endif // BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||
|
@ -13,21 +13,27 @@
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/path_traits.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace
|
||||
{
|
||||
class codecvt_error_cat : public boost::system::error_category
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
namespace {
|
||||
|
||||
class codecvt_error_cat BOOST_FINAL :
|
||||
public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
codecvt_error_cat(){}
|
||||
BOOST_DEFAULTED_FUNCTION(codecvt_error_cat(), {})
|
||||
const char* name() const BOOST_SYSTEM_NOEXCEPT BOOST_OVERRIDE;
|
||||
std::string message(int ev) const BOOST_OVERRIDE;
|
||||
};
|
||||
@ -56,18 +62,14 @@ namespace
|
||||
break;
|
||||
default:
|
||||
str = "unknown error";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
|
||||
BOOST_FILESYSTEM_DECL boost::system::error_category const& codecvt_error_category()
|
||||
{
|
||||
static const codecvt_error_cat codecvt_error_cat_const;
|
||||
return codecvt_error_cat_const;
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "platform_config.hpp"
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
@ -36,14 +37,13 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0)\
|
||||
&& defined(_SC_THREAD_SAFE_FUNCTIONS)\
|
||||
&& !defined(__CYGWIN__)\
|
||||
&& !(defined(linux) || defined(__linux) || defined(__linux__))\
|
||||
&& !defined(__ANDROID__)\
|
||||
&& (!defined(__hpux) || defined(_REENTRANT)) \
|
||||
&& (!defined(_AIX) || defined(__THREAD_SAFE))\
|
||||
&& !defined(__wasm)
|
||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS + 0 >= 0) && defined(_SC_THREAD_SAFE_FUNCTIONS) && \
|
||||
!defined(__CYGWIN__) && \
|
||||
!(defined(linux) || defined(__linux) || defined(__linux__)) && \
|
||||
!defined(__ANDROID__) && \
|
||||
(!defined(__hpux) || defined(_REENTRANT)) && \
|
||||
(!defined(_AIX) || defined(__THREAD_SAFE)) && \
|
||||
!defined(__wasm)
|
||||
#define BOOST_FILESYSTEM_USE_READDIR_R
|
||||
#endif
|
||||
|
||||
@ -63,8 +63,7 @@
|
||||
// macros being tested come from dirent.h.
|
||||
//
|
||||
// TODO: find out what macros indicate dirent::d_type present in more libraries
|
||||
#if defined(BOOST_WINDOWS_API)\
|
||||
|| defined(_DIRENT_HAVE_D_TYPE)// defined by GNU C library if d_type present
|
||||
#if defined(BOOST_WINDOWS_API) || defined(_DIRENT_HAVE_D_TYPE) // defined by GNU C library if d_type present
|
||||
#define BOOST_FILESYSTEM_STATUS_CACHE
|
||||
#endif
|
||||
|
||||
@ -125,18 +124,20 @@ file_status directory_entry::get_symlink_status(system::error_code* ec) const
|
||||
|
||||
namespace path_traits {
|
||||
|
||||
void dispatch(const directory_entry& de,
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(directory_entry const& de,
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::wstring& to,
|
||||
#else
|
||||
std::string& to,
|
||||
#endif
|
||||
const codecvt_type&)
|
||||
codecvt_type const&)
|
||||
{
|
||||
to = de.path().native();
|
||||
}
|
||||
|
||||
void dispatch(const directory_entry& de,
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(directory_entry const& de,
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::wstring& to
|
||||
#else
|
||||
@ -203,9 +204,7 @@ inline std::size_t path_max()
|
||||
|
||||
#endif // BOOST_FILESYSTEM_USE_READDIR_R
|
||||
|
||||
error_code dir_itr_first(void*& handle, void*& buffer,
|
||||
const char* dir, std::string& target,
|
||||
fs::file_status&, fs::file_status&)
|
||||
error_code dir_itr_first(void*& handle, void*& buffer, const char* dir, std::string& target, fs::file_status&, fs::file_status&)
|
||||
{
|
||||
if ((handle = ::opendir(dir)) == 0)
|
||||
{
|
||||
@ -255,8 +254,7 @@ inline int readdir_r_simulator(DIR* dirp, void*& buffer, struct dirent** result)
|
||||
return 0;
|
||||
}
|
||||
|
||||
error_code dir_itr_increment(void*& handle, void*& buffer,
|
||||
std::string& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||
error_code dir_itr_increment(void*& handle, void*& buffer, std::string& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||
{
|
||||
dirent* result = NULL;
|
||||
int err = readdir_r_simulator(static_cast< DIR* >(handle), buffer, &result);
|
||||
@ -294,29 +292,26 @@ error_code dir_itr_increment(void*& handle, void*& buffer,
|
||||
|
||||
#else // BOOST_WINDOWS_API
|
||||
|
||||
error_code dir_itr_first(void*& handle, const fs::path& dir,
|
||||
std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||
error_code dir_itr_first(void*& handle, fs::path const& dir, std::wstring& target, fs::file_status& sf, fs::file_status& symlink_sf)
|
||||
// Note: an empty root directory has no "." or ".." entries, so this
|
||||
// causes a ERROR_FILE_NOT_FOUND error which we do not considered an
|
||||
// error. It is treated as eof instead.
|
||||
{
|
||||
// use a form of search Sebastian Martel reports will work with Win98
|
||||
std::wstring dirpath(dir.wstring());
|
||||
dirpath += (dirpath.empty()
|
||||
|| (dirpath[dirpath.size()-1] != L'\\'
|
||||
&& dirpath[dirpath.size()-1] != L'/'
|
||||
&& dirpath[dirpath.size()-1] != L':'))? L"\\*" : L"*";
|
||||
dirpath += (dirpath.empty() || (dirpath[dirpath.size() - 1] != L'\\' && dirpath[dirpath.size() - 1] != L'/' && dirpath[dirpath.size() - 1] != L':')) ? L"\\*" : L"*";
|
||||
|
||||
WIN32_FIND_DATAW data;
|
||||
if ((handle = ::FindFirstFileW(dirpath.c_str(), &data))
|
||||
== INVALID_HANDLE_VALUE)
|
||||
if ((handle = ::FindFirstFileW(dirpath.c_str(), &data)) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
handle = 0; // signal eof
|
||||
DWORD error = ::GetLastError();
|
||||
return error_code((error == ERROR_FILE_NOT_FOUND
|
||||
// Windows Mobile returns ERROR_NO_MORE_FILES; see ticket #3551
|
||||
|| error == ERROR_NO_MORE_FILES)
|
||||
? 0 : error, system_category() );
|
||||
|| error == ERROR_NO_MORE_FILES) ?
|
||||
0 :
|
||||
error,
|
||||
system_category());
|
||||
}
|
||||
target = data.cFileName;
|
||||
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
@ -437,10 +432,9 @@ system::error_code dir_itr_close( // never throws
|
||||
}
|
||||
|
||||
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,
|
||||
"boost::filesystem::directory_iterator::construct"))
|
||||
if (error(p.empty() ? not_found_error_code : 0, p, ec, "boost::filesystem::directory_iterator::construct"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -475,8 +469,7 @@ void directory_iterator_construct(directory_iterator& it, const path& p, unsigne
|
||||
if (result != make_error_condition(system::errc::permission_denied) ||
|
||||
(opts & static_cast< unsigned int >(directory_options::skip_permission_denied)) == 0u)
|
||||
{
|
||||
error(result.value(), p,
|
||||
ec, "boost::filesystem::directory_iterator::construct");
|
||||
error(result.value(), p, ec, "boost::filesystem::directory_iterator::construct");
|
||||
}
|
||||
|
||||
return;
|
||||
@ -536,9 +529,7 @@ void directory_iterator_increment(directory_iterator& it, system::error_code* ec
|
||||
if (ec == NULL)
|
||||
{
|
||||
BOOST_FILESYSTEM_THROW(
|
||||
filesystem_error("boost::filesystem::directory_iterator::operator++",
|
||||
error_path,
|
||||
increment_ec));
|
||||
filesystem_error("boost::filesystem::directory_iterator::operator++", error_path, increment_ec));
|
||||
}
|
||||
*ec = increment_ec;
|
||||
return;
|
||||
@ -577,7 +568,7 @@ void directory_iterator_increment(directory_iterator& it, system::error_code* ec
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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)
|
||||
ec->clear();
|
||||
@ -748,8 +739,7 @@ inline push_directory_result recursive_directory_iterator_push_directory(detail:
|
||||
if (BOOST_UNLIKELY(!!ec))
|
||||
{
|
||||
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))
|
||||
== 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))
|
||||
{
|
||||
// Skip dangling symlink and continue iteration on the current depth level
|
||||
ec = error_code();
|
||||
|
@ -55,8 +55,8 @@ typedef boost::winapi::DWORD_ err_t;
|
||||
|
||||
// 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, const path& 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& p, 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)
|
||||
{
|
||||
@ -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))
|
||||
{
|
||||
@ -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))
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
try
|
||||
@ -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
|
||||
{
|
||||
if (m_imp_ptr.get()) try
|
||||
if (m_imp_ptr.get())
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
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());
|
||||
}
|
||||
|
||||
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)
|
||||
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());
|
||||
}
|
||||
|
||||
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)
|
||||
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
304
src/path.cpp
304
src/path.cpp
@ -16,6 +16,7 @@
|
||||
#error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp> // for filesystem_error
|
||||
#include <boost/scoped_array.hpp>
|
||||
@ -31,8 +32,7 @@
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
#include "windows_file_codecvt.hpp"
|
||||
#include <windows.h>
|
||||
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \
|
||||
|| defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#endif
|
||||
|
||||
@ -56,8 +56,7 @@ using boost::system::error_code;
|
||||
// //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
//------------------------------------------------------------------------------------//
|
||||
// miscellaneous class path helpers //
|
||||
//------------------------------------------------------------------------------------//
|
||||
@ -87,18 +86,18 @@ namespace
|
||||
|
||||
#endif
|
||||
|
||||
bool is_root_separator(const string_type& str, size_type pos);
|
||||
// pos is position of the separator
|
||||
bool is_root_separator(string_type const& str, size_type pos);
|
||||
|
||||
size_type filename_pos(const string_type& str,
|
||||
size_type end_pos); // end_pos is past-the-end position
|
||||
// Returns: 0 if str itself is filename (or empty)
|
||||
// end_pos is past-the-end position
|
||||
size_type filename_pos(string_type const& str, size_type end_pos);
|
||||
|
||||
size_type root_directory_start(const string_type& path, size_type size);
|
||||
// Returns: npos if no root_directory found
|
||||
size_type root_directory_start(string_type const& path, size_type size);
|
||||
|
||||
void first_element(
|
||||
const string_type& src,
|
||||
string_type const& src,
|
||||
size_type& element_pos,
|
||||
size_type& element_size,
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310) // VC++ 7.1
|
||||
@ -116,10 +115,8 @@ namespace
|
||||
// //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
BOOST_FILESYSTEM_DECL path& path::operator/=(const path& p)
|
||||
{
|
||||
@ -145,8 +142,7 @@ namespace filesystem
|
||||
{
|
||||
if (!*ptr)
|
||||
return *this;
|
||||
if (ptr >= m_pathname.data()
|
||||
&& ptr < m_pathname.data() + m_pathname.size()) // overlapping source
|
||||
if (ptr >= m_pathname.data() && ptr < m_pathname.data() + m_pathname.size()) // overlapping source
|
||||
{
|
||||
path rhs(ptr);
|
||||
if (!detail::is_directory_separator(rhs.m_pathname[0]))
|
||||
@ -205,8 +201,7 @@ namespace filesystem
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
|| m_pathname[sep_pos + 1] == preferred_separator // or preferred_separator
|
||||
#endif
|
||||
)
|
||||
)
|
||||
))
|
||||
{
|
||||
m_pathname.erase(m_pathname.begin() + sep_pos); // erase the added separator
|
||||
}
|
||||
@ -233,8 +228,7 @@ namespace filesystem
|
||||
|
||||
BOOST_FILESYSTEM_DECL path& path::remove_trailing_separator()
|
||||
{
|
||||
if (!m_pathname.empty()
|
||||
&& detail::is_directory_separator(m_pathname[m_pathname.size() - 1]))
|
||||
if (!m_pathname.empty() && detail::is_directory_separator(m_pathname[m_pathname.size() - 1]))
|
||||
m_pathname.erase(m_pathname.end() - 1);
|
||||
return *this;
|
||||
}
|
||||
@ -260,7 +254,8 @@ namespace filesystem
|
||||
BOOST_FILESYSTEM_DECL path path::root_path() const
|
||||
{
|
||||
path temp(root_name());
|
||||
if (!root_directory().empty()) temp.m_pathname += root_directory().c_str();
|
||||
if (!root_directory().empty())
|
||||
temp.m_pathname += root_directory().c_str();
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -268,38 +263,39 @@ namespace filesystem
|
||||
{
|
||||
iterator itr(begin());
|
||||
|
||||
return (itr.m_pos != m_pathname.size()
|
||||
&& (
|
||||
(itr.m_element.m_pathname.size() > 1
|
||||
&& detail::is_directory_separator(itr.m_element.m_pathname[0])
|
||||
&& detail::is_directory_separator(itr.m_element.m_pathname[1]))
|
||||
return
|
||||
(
|
||||
itr.m_pos != m_pathname.size() &&
|
||||
(
|
||||
(itr.m_element.m_pathname.size() > 1 && detail::is_directory_separator(itr.m_element.m_pathname[0]) && detail::is_directory_separator(itr.m_element.m_pathname[1]))
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
|| itr.m_element.m_pathname[itr.m_element.m_pathname.size() - 1] == colon
|
||||
#endif
|
||||
))
|
||||
? itr.m_element
|
||||
: path();
|
||||
)
|
||||
) ? itr.m_element : path();
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::root_directory() const
|
||||
{
|
||||
size_type pos(root_directory_start(m_pathname, m_pathname.size()));
|
||||
|
||||
return pos == string_type::npos
|
||||
? path()
|
||||
: path(m_pathname.c_str() + pos, m_pathname.c_str() + pos + 1);
|
||||
return pos == string_type::npos ? path() : path(m_pathname.c_str() + pos, m_pathname.c_str() + pos + 1);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::relative_path() const
|
||||
{
|
||||
iterator itr(begin());
|
||||
|
||||
for (; itr.m_pos != m_pathname.size()
|
||||
&& (detail::is_directory_separator(itr.m_element.m_pathname[0])
|
||||
for (;
|
||||
itr.m_pos != m_pathname.size() &&
|
||||
(
|
||||
detail::is_directory_separator(itr.m_element.m_pathname[0])
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
|| itr.m_element.m_pathname[itr.m_element.m_pathname.size() - 1] == colon
|
||||
#endif
|
||||
); ++itr) {}
|
||||
);
|
||||
++itr)
|
||||
{
|
||||
}
|
||||
|
||||
return path(m_pathname.c_str() + itr.m_pos);
|
||||
}
|
||||
@ -308,71 +304,55 @@ namespace filesystem
|
||||
{
|
||||
size_type end_pos(filename_pos(m_pathname, m_pathname.size()));
|
||||
|
||||
bool filename_was_separator = !m_pathname.empty()
|
||||
&& detail::is_directory_separator(m_pathname[end_pos]);
|
||||
bool filename_was_separator = !m_pathname.empty() && detail::is_directory_separator(m_pathname[end_pos]);
|
||||
|
||||
// skip separators unless root directory
|
||||
size_type root_dir_pos(root_directory_start(m_pathname, end_pos));
|
||||
for (;
|
||||
end_pos > 0
|
||||
&& (end_pos-1) != root_dir_pos
|
||||
&& detail::is_directory_separator(m_pathname[end_pos-1])
|
||||
;
|
||||
--end_pos) {}
|
||||
end_pos > 0 && (end_pos - 1) != root_dir_pos && detail::is_directory_separator(m_pathname[end_pos - 1]);
|
||||
--end_pos)
|
||||
{
|
||||
}
|
||||
|
||||
return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator)
|
||||
? string_type::npos
|
||||
: end_pos;
|
||||
return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator) ? string_type::npos : end_pos;
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::parent_path() const
|
||||
{
|
||||
size_type end_pos(m_parent_path_end());
|
||||
return end_pos == string_type::npos
|
||||
? path()
|
||||
: path(m_pathname.c_str(), m_pathname.c_str() + end_pos);
|
||||
return end_pos == string_type::npos ? path() : path(m_pathname.c_str(), m_pathname.c_str() + end_pos);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::filename() const
|
||||
{
|
||||
size_type pos(filename_pos(m_pathname, m_pathname.size()));
|
||||
return (!m_pathname.empty()
|
||||
&& pos
|
||||
&& detail::is_directory_separator(m_pathname[pos])
|
||||
&& !is_root_separator(m_pathname, pos))
|
||||
? detail::dot_path()
|
||||
: path(m_pathname.c_str() + pos);
|
||||
return (!m_pathname.empty() && pos && detail::is_directory_separator(m_pathname[pos]) && !is_root_separator(m_pathname, pos)) ? detail::dot_path() : path(m_pathname.c_str() + pos);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::stem() const
|
||||
{
|
||||
path name(filename());
|
||||
if (name == detail::dot_path() || name == detail::dot_dot_path()) return name;
|
||||
if (name == detail::dot_path() || name == detail::dot_dot_path())
|
||||
return name;
|
||||
size_type pos(name.m_pathname.rfind(dot));
|
||||
return pos == string_type::npos
|
||||
? name
|
||||
: path(name.m_pathname.c_str(), name.m_pathname.c_str() + pos);
|
||||
return pos == string_type::npos ? name : path(name.m_pathname.c_str(), name.m_pathname.c_str() + pos);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::extension() const
|
||||
{
|
||||
path name(filename());
|
||||
if (name == detail::dot_path() || name == detail::dot_dot_path()) return path();
|
||||
if (name == detail::dot_path() || name == detail::dot_dot_path())
|
||||
return path();
|
||||
size_type pos(name.m_pathname.rfind(dot));
|
||||
return pos == string_type::npos
|
||||
? path()
|
||||
: path(name.m_pathname.c_str() + pos);
|
||||
return pos == string_type::npos ? path() : path(name.m_pathname.c_str() + pos);
|
||||
}
|
||||
|
||||
// lexical operations --------------------------------------------------------------//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace detail {
|
||||
// C++14 provides a mismatch algorithm with four iterator arguments(), but earlier
|
||||
// standard libraries didn't, so provide this needed functionality.
|
||||
inline
|
||||
std::pair<path::iterator, path::iterator> mismatch(path::iterator it1,
|
||||
path::iterator it1end, path::iterator it2, path::iterator it2end)
|
||||
inline std::pair< path::iterator, path::iterator > mismatch(path::iterator it1, path::iterator it1end, path::iterator it2, path::iterator it2end)
|
||||
{
|
||||
for (; it1 != it1end && it2 != it2end && *it1 == *it2;)
|
||||
{
|
||||
@ -381,7 +361,7 @@ namespace filesystem
|
||||
}
|
||||
return std::make_pair(it1, it2);
|
||||
}
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
BOOST_FILESYSTEM_DECL path path::lexically_relative(const path& base) const
|
||||
{
|
||||
@ -428,32 +408,19 @@ namespace filesystem
|
||||
for (iterator itr(start); itr != stop; ++itr)
|
||||
{
|
||||
// ignore "." except at start and last
|
||||
if (itr->native().size() == 1
|
||||
&& (itr->native())[0] == dot
|
||||
&& itr != start
|
||||
&& itr != last) continue;
|
||||
if (itr->native().size() == 1 && (itr->native())[0] == dot && itr != start && itr != last)
|
||||
continue;
|
||||
|
||||
// ignore a name and following ".."
|
||||
if (!temp.empty()
|
||||
&& itr->native().size() == 2
|
||||
&& (itr->native())[0] == dot
|
||||
&& (itr->native())[1] == dot) // dot dot
|
||||
if (!temp.empty() && itr->native().size() == 2 && (itr->native())[0] == dot && (itr->native())[1] == dot) // dot dot
|
||||
{
|
||||
string_type lf(temp.filename().native());
|
||||
string_type::size_type lf_size = lf.size();
|
||||
if (lf_size > 0
|
||||
&& (lf_size != 1
|
||||
|| (lf[0] != dot
|
||||
&& lf[0] != separator))
|
||||
&& (lf_size != 2
|
||||
|| (lf[0] != dot
|
||||
&& lf[1] != dot
|
||||
if (lf_size > 0 && (lf_size != 1 || (lf[0] != dot && lf[0] != separator)) && (lf_size != 2 || (lf[0] != dot && lf[1] != dot
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
&& lf[1] != colon
|
||||
#endif
|
||||
)
|
||||
)
|
||||
)
|
||||
)))
|
||||
{
|
||||
temp.remove_filename();
|
||||
//// if not root directory, must also remove "/" if any
|
||||
@ -471,8 +438,7 @@ namespace filesystem
|
||||
//}
|
||||
|
||||
iterator next(itr);
|
||||
if (temp.empty() && ++next != stop
|
||||
&& next == last && *last == detail::dot_path())
|
||||
if (temp.empty() && ++next != stop && next == last && *last == detail::dot_path())
|
||||
{
|
||||
temp /= detail::dot_path();
|
||||
}
|
||||
@ -497,16 +463,14 @@ namespace filesystem
|
||||
// //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
// is_root_separator ---------------------------------------------------------------//
|
||||
|
||||
bool is_root_separator(const string_type & str, size_type pos)
|
||||
// pos is position of the separator
|
||||
bool is_root_separator(string_type const& str, size_type pos)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!str.empty() && fs::detail::is_directory_separator(str[pos]),
|
||||
"precondition violation");
|
||||
BOOST_ASSERT_MSG(!str.empty() && fs::detail::is_directory_separator(str[pos]), "precondition violation");
|
||||
|
||||
// subsequent logic expects pos to be for leftmost slash of a set
|
||||
while (pos > 0 && fs::detail::is_directory_separator(str[pos - 1]))
|
||||
@ -523,8 +487,7 @@ namespace
|
||||
#endif
|
||||
|
||||
// "//" name "/"
|
||||
if (pos < 3 || !fs::detail::is_directory_separator(str[0])
|
||||
|| !fs::detail::is_directory_separator(str[1]))
|
||||
if (pos < 3 || !fs::detail::is_directory_separator(str[0]) || !fs::detail::is_directory_separator(str[1]))
|
||||
return false;
|
||||
|
||||
return str.find_first_of(separators, 2) == pos;
|
||||
@ -532,14 +495,13 @@ namespace
|
||||
|
||||
// filename_pos --------------------------------------------------------------------//
|
||||
|
||||
size_type filename_pos(const string_type & str,
|
||||
size_type end_pos) // end_pos is past-the-end position
|
||||
// end_pos is past-the-end position
|
||||
// return 0 if str itself is filename (or empty)
|
||||
size_type filename_pos(string_type const& str, size_type end_pos)
|
||||
{
|
||||
// case: "//"
|
||||
if (end_pos == 2
|
||||
&& fs::detail::is_directory_separator(str[0])
|
||||
&& fs::detail::is_directory_separator(str[1])) return 0;
|
||||
if (end_pos == 2 && fs::detail::is_directory_separator(str[0]) && fs::detail::is_directory_separator(str[1]))
|
||||
return 0;
|
||||
|
||||
// case: ends in "/"
|
||||
if (end_pos && fs::detail::is_directory_separator(str[end_pos - 1]))
|
||||
@ -555,35 +517,31 @@ namespace
|
||||
|
||||
return (pos == string_type::npos // path itself must be a filename (or empty)
|
||||
|| (pos == 1 && fs::detail::is_directory_separator(str[0]))) // or net
|
||||
? 0 // so filename is entire string
|
||||
: pos + 1; // or starts after delimiter
|
||||
?
|
||||
0 // so filename is entire string
|
||||
:
|
||||
pos + 1; // or starts after delimiter
|
||||
}
|
||||
|
||||
// root_directory_start ------------------------------------------------------------//
|
||||
|
||||
size_type root_directory_start(const string_type & path, size_type size)
|
||||
// return npos if no root_directory found
|
||||
size_type root_directory_start(string_type const& path, size_type size)
|
||||
{
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
// case "c:/"
|
||||
if (size > 2
|
||||
&& path[1] == colon
|
||||
&& fs::detail::is_directory_separator(path[2])) return 2;
|
||||
if (size > 2 && path[1] == colon && fs::detail::is_directory_separator(path[2]))
|
||||
return 2;
|
||||
#endif
|
||||
|
||||
// case "//"
|
||||
if (size == 2
|
||||
&& fs::detail::is_directory_separator(path[0])
|
||||
&& fs::detail::is_directory_separator(path[1])) return string_type::npos;
|
||||
if (size == 2 && fs::detail::is_directory_separator(path[0]) && fs::detail::is_directory_separator(path[1]))
|
||||
return string_type::npos;
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
// case "\\?\"
|
||||
if (size > 4
|
||||
&& fs::detail::is_directory_separator(path[0])
|
||||
&& fs::detail::is_directory_separator(path[1])
|
||||
&& path[2] == questionmark
|
||||
&& fs::detail::is_directory_separator(path[3]))
|
||||
if (size > 4 && fs::detail::is_directory_separator(path[0]) && fs::detail::is_directory_separator(path[1]) && path[2] == questionmark && fs::detail::is_directory_separator(path[3]))
|
||||
{
|
||||
string_type::size_type pos(path.find_first_of(separators, 4));
|
||||
return pos < size ? pos : string_type::npos;
|
||||
@ -591,44 +549,40 @@ namespace
|
||||
#endif
|
||||
|
||||
// case "//net {/}"
|
||||
if (size > 3
|
||||
&& fs::detail::is_directory_separator(path[0])
|
||||
&& fs::detail::is_directory_separator(path[1])
|
||||
&& !fs::detail::is_directory_separator(path[2]))
|
||||
if (size > 3 && fs::detail::is_directory_separator(path[0]) && fs::detail::is_directory_separator(path[1]) && !fs::detail::is_directory_separator(path[2]))
|
||||
{
|
||||
string_type::size_type pos(path.find_first_of(separators, 2));
|
||||
return pos < size ? pos : string_type::npos;
|
||||
}
|
||||
|
||||
// case "/"
|
||||
if (size > 0 && fs::detail::is_directory_separator(path[0])) return 0;
|
||||
if (size > 0 && fs::detail::is_directory_separator(path[0]))
|
||||
return 0;
|
||||
|
||||
return string_type::npos;
|
||||
}
|
||||
|
||||
// first_element --------------------------------------------------------------------//
|
||||
|
||||
// sets pos and len of first element, excluding extra separators
|
||||
// if src.empty(), sets pos,len, to 0,0.
|
||||
|
||||
void first_element(
|
||||
const string_type & src,
|
||||
string_type const& src,
|
||||
size_type& element_pos,
|
||||
size_type& element_size,
|
||||
size_type size
|
||||
)
|
||||
size_type size)
|
||||
{
|
||||
if (size == string_type::npos) size = src.size();
|
||||
if (size == string_type::npos)
|
||||
size = src.size();
|
||||
element_pos = 0;
|
||||
element_size = 0;
|
||||
if (src.empty()) return;
|
||||
if (src.empty())
|
||||
return;
|
||||
|
||||
string_type::size_type cur(0);
|
||||
|
||||
// deal with // [network]
|
||||
if (size >= 2 && fs::detail::is_directory_separator(src[0])
|
||||
&& fs::detail::is_directory_separator(src[1])
|
||||
&& (size == 2
|
||||
|| !fs::detail::is_directory_separator(src[2])))
|
||||
if (size >= 2 && fs::detail::is_directory_separator(src[0]) && fs::detail::is_directory_separator(src[1]) && (size == 2 || !fs::detail::is_directory_separator(src[2])))
|
||||
{
|
||||
cur += 2;
|
||||
element_size += 2;
|
||||
@ -639,8 +593,7 @@ namespace
|
||||
{
|
||||
++element_size;
|
||||
// bypass extra leading separators
|
||||
while (cur+1 < size
|
||||
&& fs::detail::is_directory_separator(src[cur+1]))
|
||||
while (cur + 1 < size && fs::detail::is_directory_separator(src[cur + 1]))
|
||||
{
|
||||
++cur;
|
||||
++element_pos;
|
||||
@ -663,30 +616,31 @@ namespace
|
||||
}
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
if (cur == size) return;
|
||||
if (cur == size)
|
||||
return;
|
||||
// include device delimiter
|
||||
if (src[cur] == colon)
|
||||
{ ++element_size; }
|
||||
{
|
||||
++element_size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
namespace detail {
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
BOOST_FILESYSTEM_DECL
|
||||
int lex_compare(path::iterator first1, path::iterator last1,
|
||||
path::iterator first2, path::iterator last2)
|
||||
int lex_compare(path::iterator first1, path::iterator last1, path::iterator first2, path::iterator last2)
|
||||
{
|
||||
for (; first1 != last1 && first2 != last2;)
|
||||
{
|
||||
if (first1->native() < first2->native()) return -1;
|
||||
if (first2->native() < first1->native()) return 1;
|
||||
if (first1->native() < first2->native())
|
||||
return -1;
|
||||
if (first2->native() < first1->native())
|
||||
return 1;
|
||||
BOOST_ASSERT(first2->native() == first1->native());
|
||||
++first1;
|
||||
++first2;
|
||||
@ -717,7 +671,8 @@ namespace filesystem
|
||||
#endif
|
||||
return dot_dot;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// //
|
||||
@ -747,8 +702,7 @@ namespace filesystem
|
||||
|
||||
BOOST_FILESYSTEM_DECL void path::m_path_iterator_increment(path::iterator& it)
|
||||
{
|
||||
BOOST_ASSERT_MSG(it.m_pos < it.m_path_ptr->m_pathname.size(),
|
||||
"path::basic_iterator increment past end()");
|
||||
BOOST_ASSERT_MSG(it.m_pos < it.m_path_ptr->m_pathname.size(), "path::basic_iterator increment past end()");
|
||||
|
||||
// increment to position past current element; if current element is implicit dot,
|
||||
// this will cause it.m_pos to represent the end iterator
|
||||
@ -762,10 +716,10 @@ namespace filesystem
|
||||
}
|
||||
|
||||
// both POSIX and Windows treat paths that begin with exactly two separators specially
|
||||
bool was_net(it.m_element.m_pathname.size() > 2
|
||||
&& detail::is_directory_separator(it.m_element.m_pathname[0])
|
||||
&& detail::is_directory_separator(it.m_element.m_pathname[1])
|
||||
&& !detail::is_directory_separator(it.m_element.m_pathname[2]));
|
||||
bool was_net = it.m_element.m_pathname.size() > 2 &&
|
||||
detail::is_directory_separator(it.m_element.m_pathname[0]) &&
|
||||
detail::is_directory_separator(it.m_element.m_pathname[1]) &&
|
||||
!detail::is_directory_separator(it.m_element.m_pathname[2]);
|
||||
|
||||
// process separator (Windows drive spec is only case not a separator)
|
||||
if (detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos]))
|
||||
@ -783,13 +737,13 @@ namespace filesystem
|
||||
}
|
||||
|
||||
// skip separators until it.m_pos points to the start of the next element
|
||||
while (it.m_pos != it.m_path_ptr->m_pathname.size()
|
||||
&& detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos]))
|
||||
{ ++it.m_pos; }
|
||||
while (it.m_pos != it.m_path_ptr->m_pathname.size() && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos]))
|
||||
{
|
||||
++it.m_pos;
|
||||
}
|
||||
|
||||
// detect trailing separator, and treat it as ".", per POSIX spec
|
||||
if (it.m_pos == it.m_path_ptr->m_pathname.size()
|
||||
&& !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1))
|
||||
if (it.m_pos == it.m_path_ptr->m_pathname.size() && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos - 1))
|
||||
{
|
||||
--it.m_pos;
|
||||
it.m_element = detail::dot_path();
|
||||
@ -798,7 +752,7 @@ namespace filesystem
|
||||
}
|
||||
|
||||
// get m_element
|
||||
size_type end_pos(it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos));
|
||||
size_type end_pos = it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos);
|
||||
if (end_pos == string_type::npos)
|
||||
end_pos = it.m_path_ptr->m_pathname.size();
|
||||
it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
|
||||
@ -808,30 +762,24 @@ namespace filesystem
|
||||
{
|
||||
BOOST_ASSERT_MSG(it.m_pos, "path::iterator decrement past begin()");
|
||||
|
||||
size_type end_pos(it.m_pos);
|
||||
size_type end_pos = it.m_pos;
|
||||
|
||||
// if at end and there was a trailing non-root '/', return "."
|
||||
if (it.m_pos == it.m_path_ptr->m_pathname.size()
|
||||
&& it.m_path_ptr->m_pathname.size() > 1
|
||||
&& detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos-1])
|
||||
&& !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1)
|
||||
)
|
||||
if (it.m_pos == it.m_path_ptr->m_pathname.size() && it.m_path_ptr->m_pathname.size() > 1 && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos - 1]) && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos - 1))
|
||||
{
|
||||
--it.m_pos;
|
||||
it.m_element = detail::dot_path();
|
||||
return;
|
||||
}
|
||||
|
||||
size_type root_dir_pos(root_directory_start(it.m_path_ptr->m_pathname, end_pos));
|
||||
size_type root_dir_pos = root_directory_start(it.m_path_ptr->m_pathname, end_pos);
|
||||
|
||||
// skip separators unless root directory
|
||||
for (
|
||||
;
|
||||
end_pos > 0
|
||||
&& (end_pos-1) != root_dir_pos
|
||||
&& detail::is_directory_separator(it.m_path_ptr->m_pathname[end_pos-1])
|
||||
;
|
||||
--end_pos) {}
|
||||
for (;
|
||||
end_pos > 0 && (end_pos - 1) != root_dir_pos && detail::is_directory_separator(it.m_path_ptr->m_pathname[end_pos - 1]);
|
||||
--end_pos)
|
||||
{
|
||||
}
|
||||
|
||||
it.m_pos = filename_pos(it.m_path_ptr->m_pathname, end_pos);
|
||||
it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
|
||||
@ -842,8 +790,7 @@ namespace filesystem
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
//------------------------------------------------------------------------------------//
|
||||
// locale helpers //
|
||||
@ -870,8 +817,7 @@ namespace
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
std::locale global_loc = std::locale();
|
||||
return std::locale(global_loc, new windows_file_codecvt);
|
||||
# elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \
|
||||
|| defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
// "All BSD system functions expect their string parameters to be in UTF-8 encoding
|
||||
// and nothing else." See
|
||||
// http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
|
||||
@ -900,7 +846,6 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
std::locale& path_locale()
|
||||
// std::locale("") construction, needed on non-Apple POSIX systems, can throw
|
||||
// (if environmental variables LC_MESSAGES or LANG are wrong, for example), so
|
||||
// path_locale() provides lazy initialization via a local static to ensure that any
|
||||
@ -908,6 +853,7 @@ namespace
|
||||
// path_locale() is only called if path::codecvt() or path::imbue() are themselves
|
||||
// actually called, ensuring that an exception will only be thrown if std::locale("")
|
||||
// is really needed.
|
||||
std::locale& path_locale()
|
||||
{
|
||||
// [locale] paragraph 6: Once a facet reference is obtained from a locale object by
|
||||
// calling use_facet<>, that reference remains usable, and the results from member
|
||||
@ -919,17 +865,15 @@ namespace
|
||||
#endif
|
||||
return loc;
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// path::codecvt() and path::imbue() implementation //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
// See comments above
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
BOOST_FILESYSTEM_DECL const path::codecvt_type& path::codecvt()
|
||||
{
|
||||
|
@ -11,12 +11,16 @@
|
||||
|
||||
#include "platform_config.hpp"
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/path_traits.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 <cstring> // for strlen
|
||||
#include <cwchar> // for wcslen
|
||||
#include <cstddef>
|
||||
|
||||
namespace pt = boost::filesystem::path_traits;
|
||||
namespace fs = boost::filesystem;
|
||||
@ -32,8 +36,7 @@ namespace bs = boost::system;
|
||||
|
||||
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;
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// //
|
||||
@ -51,7 +54,7 @@ namespace {
|
||||
const char* from_end,
|
||||
wchar_t* to, wchar_t* to_end,
|
||||
std::wstring& target,
|
||||
const pt::codecvt_type & cvt)
|
||||
pt::codecvt_type const& cvt)
|
||||
{
|
||||
//std::cout << std::hex
|
||||
// << " from=" << std::size_t(from)
|
||||
@ -66,12 +69,10 @@ namespace {
|
||||
|
||||
std::codecvt_base::result res;
|
||||
|
||||
if ((res=cvt.in(state, from, from_end, from_next,
|
||||
to, to_end, to_next)) != std::codecvt_base::ok)
|
||||
if ((res = cvt.in(state, from, from_end, from_next, to, to_end, to_next)) != std::codecvt_base::ok)
|
||||
{
|
||||
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(),
|
||||
"boost::filesystem::path codecvt to wstring"));
|
||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(), "boost::filesystem::path codecvt to wstring"));
|
||||
}
|
||||
target.append(to, to_next);
|
||||
}
|
||||
@ -85,7 +86,7 @@ namespace {
|
||||
const wchar_t* from_end,
|
||||
char* to, char* to_end,
|
||||
std::string& target,
|
||||
const pt::codecvt_type & cvt)
|
||||
pt::codecvt_type const& cvt)
|
||||
{
|
||||
//std::cout << std::hex
|
||||
// << " from=" << std::size_t(from)
|
||||
@ -100,12 +101,10 @@ namespace {
|
||||
|
||||
std::codecvt_base::result res;
|
||||
|
||||
if ((res=cvt.out(state, from, from_end, from_next,
|
||||
to, to_end, to_next)) != std::codecvt_base::ok)
|
||||
if ((res = cvt.out(state, from, from_end, from_next, to, to_end, to_next)) != std::codecvt_base::ok)
|
||||
{
|
||||
//std::cout << " result is " << static_cast<int>(res) << std::endl;
|
||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(),
|
||||
"boost::filesystem::path codecvt to string"));
|
||||
BOOST_FILESYSTEM_THROW(bs::system_error(res, fs::codecvt_error_category(), "boost::filesystem::path codecvt to string"));
|
||||
}
|
||||
target.append(to, to_next);
|
||||
}
|
||||
@ -116,7 +115,9 @@ namespace {
|
||||
// path_traits //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace boost { namespace filesystem { namespace path_traits {
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
namespace path_traits {
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// convert const char* to wstring //
|
||||
@ -125,8 +126,7 @@ namespace boost { namespace filesystem { namespace path_traits {
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
std::wstring & to,
|
||||
const codecvt_type & cvt)
|
||||
std::wstring& to, codecvt_type const& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
|
||||
@ -135,7 +135,8 @@ namespace boost { namespace filesystem { namespace path_traits {
|
||||
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
|
||||
|
||||
@ -159,8 +160,7 @@ namespace boost { namespace filesystem { namespace path_traits {
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const wchar_t* from,
|
||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||
std::string & to,
|
||||
const codecvt_type & cvt)
|
||||
std::string& to, codecvt_type const& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
|
||||
@ -169,7 +169,8 @@ namespace boost { namespace filesystem { namespace path_traits {
|
||||
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
|
||||
// understand them either. Thus this code is just a guess; if it turns
|
||||
@ -190,4 +191,7 @@ namespace boost { namespace filesystem { namespace path_traits {
|
||||
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
|
||||
|
@ -11,21 +11,25 @@
|
||||
|
||||
#include "platform_config.hpp"
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#include <cstring> // SGI MIPSpro compilers need this
|
||||
#include <string>
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::strerror; }
|
||||
namespace std {
|
||||
using ::strerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
namespace
|
||||
{
|
||||
const char invalid_chars[] =
|
||||
namespace {
|
||||
|
||||
BOOST_CONSTEXPR_OR_CONST char invalid_chars[] =
|
||||
"\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"
|
||||
"<>:\"/\\|";
|
||||
@ -38,10 +42,8 @@ namespace
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
// name_check functions ----------------------------------------------//
|
||||
|
||||
@ -53,57 +55,34 @@ namespace boost
|
||||
#else
|
||||
BOOST_FILESYSTEM_DECL bool native(const std::string& name)
|
||||
{
|
||||
return !name.empty()
|
||||
&& name[0] != ' '
|
||||
&& name.find('/') == std::string::npos;
|
||||
return !name.empty() && name[0] != ' ' && name.find('/') == std::string::npos;
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string& name)
|
||||
{
|
||||
return !name.empty()
|
||||
&& name.find_first_not_of(valid_posix) == std::string::npos;
|
||||
return !name.empty() && name.find_first_not_of(valid_posix) == std::string::npos;
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool windows_name(const std::string& name)
|
||||
{
|
||||
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 == "..");
|
||||
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 == "..");
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_name(const std::string& name)
|
||||
{
|
||||
return !name.empty()
|
||||
&& (name == "."
|
||||
|| name == ".."
|
||||
|| (windows_name(name)
|
||||
&& portable_posix_name(name)
|
||||
&& name[0] != '.' && name[0] != '-'));
|
||||
return !name.empty() && (name == "." || name == ".." || (windows_name(name) && portable_posix_name(name) && name[0] != '.' && name[0] != '-'));
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string& name)
|
||||
{
|
||||
return
|
||||
name == "."
|
||||
|| name == ".."
|
||||
|| (portable_name(name)
|
||||
&& name.find('.') == std::string::npos);
|
||||
return name == "." || name == ".." || (portable_name(name) && name.find('.') == std::string::npos);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string& name)
|
||||
{
|
||||
std::string::size_type pos;
|
||||
return
|
||||
portable_name(name)
|
||||
&& name != "."
|
||||
&& name != ".."
|
||||
&& ((pos = name.find('.')) == std::string::npos
|
||||
|| (name.find('.', pos+1) == std::string::npos
|
||||
&& (pos + 5) > name.size()));
|
||||
return portable_name(name) && name != "." && name != ".." && ((pos = name.find('.')) == std::string::npos || (name.find('.', pos + 1) == std::string::npos && (pos + 5) > name.size()));
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
|
@ -17,17 +17,23 @@
|
||||
#include <boost/predef/os/bsd/free.h>
|
||||
|
||||
#ifdef BOOST_POSIX_API
|
||||
|
||||
#include <cerrno>
|
||||
#include <stddef.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef BOOST_HAS_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#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
|
||||
|
||||
#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)
|
||||
|
||||
#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
|
||||
@ -40,12 +46,14 @@
|
||||
#if __GLIBC_PREREQ(2, 25)
|
||||
#define BOOST_FILESYSTEM_HAS_GETRANDOM
|
||||
#endif
|
||||
# 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,
|
||||
@ -53,6 +61,7 @@
|
||||
// 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>
|
||||
@ -70,9 +79,11 @@
|
||||
#endif
|
||||
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED) && defined(_MSC_VER)
|
||||
#endif // defined(BOOST_FILESYSTEM_HAS_BCRYPT)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_POSIX_API
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include "error_handling.hpp"
|
||||
|
||||
@ -83,7 +94,9 @@
|
||||
#endif
|
||||
#endif // defined(BOOST_POSIX_API)
|
||||
|
||||
namespace boost { namespace filesystem { namespace detail {
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
namespace detail {
|
||||
|
||||
namespace {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}}}
|
||||
} // namespace detail
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
@ -5,10 +5,17 @@
|
||||
|
||||
#include "platform_config.hpp"
|
||||
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace filesystem { namespace detail {
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#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
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
|
@ -27,8 +27,7 @@ std::codecvt_base::result windows_file_codecvt::do_in(
|
||||
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
int count;
|
||||
if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
|
||||
static_cast<int>(from_end - from), to, static_cast<int>(to_end - to))) == 0)
|
||||
if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from, static_cast< int >(from_end - from), to, static_cast< int >(to_end - to))) == 0)
|
||||
{
|
||||
return error; // conversion failed
|
||||
}
|
||||
@ -47,8 +46,7 @@ std::codecvt_base::result windows_file_codecvt::do_out(
|
||||
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
int count;
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return error; // conversion failed
|
||||
}
|
||||
|
@ -23,34 +23,25 @@
|
||||
// //
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE windows_file_codecvt
|
||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||
class BOOST_SYMBOL_VISIBLE windows_file_codecvt :
|
||||
public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||
{
|
||||
public:
|
||||
explicit windows_file_codecvt(std::size_t refs = 0)
|
||||
: std::codecvt<wchar_t, char, std::mbstate_t>(refs) {}
|
||||
protected:
|
||||
explicit windows_file_codecvt(std::size_t refs = 0) :
|
||||
std::codecvt< wchar_t, char, std::mbstate_t >(refs)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool do_always_noconv() const throw() { return false; }
|
||||
|
||||
// seems safest to assume variable number of characters since we don't
|
||||
// actually know what codepage is active
|
||||
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_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 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_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; }
|
||||
};
|
||||
|
||||
|
@ -24,8 +24,7 @@ namespace detail {
|
||||
|
||||
inline bool equal_extension(wchar_t const* p, wchar_t const (&x1)[5], wchar_t const (&x2)[5])
|
||||
{
|
||||
return
|
||||
(p[0] == x1[0] || p[0] == x2[0]) &&
|
||||
return (p[0] == x1[0] || p[0] == x2[0]) &&
|
||||
(p[1] == x1[1] || p[1] == x2[1]) &&
|
||||
(p[2] == x1[2] || p[2] == x2[2]) &&
|
||||
(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;
|
||||
boost::filesystem::path ext = p.extension();
|
||||
wchar_t const* q = ext.c_str();
|
||||
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"))
|
||||
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"))
|
||||
prms |= boost::filesystem::owner_exe | boost::filesystem::group_exe | boost::filesystem::others_exe;
|
||||
return prms;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Verify macro reporting works correctly\n";
|
||||
@ -47,6 +46,5 @@ int main()
|
||||
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
||||
//cout << " : " << BOOST_MACRO_VALUE() << endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,12 +37,14 @@ namespace fs = boost::filesystem;
|
||||
using fs::path;
|
||||
namespace sys = boost::system;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
template< typename F >
|
||||
bool throws_fs_error(F func)
|
||||
{
|
||||
try { func(); }
|
||||
try
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
@ -55,7 +57,7 @@ namespace
|
||||
{
|
||||
fs::recursive_directory_iterator it(ph);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// ------------------------------------------------------------------------------------//
|
||||
|
||||
@ -117,7 +119,9 @@ int cpp_main(int, char*[])
|
||||
|
||||
for (it = fs::recursive_directory_iterator(unique_dir);
|
||||
it != fs::recursive_directory_iterator(); ++it)
|
||||
{ std::cout << it->path() << '\n'; }
|
||||
{
|
||||
std::cout << it->path() << '\n';
|
||||
}
|
||||
|
||||
it = fs::recursive_directory_iterator(unique_dir);
|
||||
BOOST_TEST(it->path() == unique_yy);
|
||||
@ -169,8 +173,7 @@ int cpp_main(int, char*[])
|
||||
ec.clear();
|
||||
BOOST_TEST(!ec);
|
||||
// check that two argument failed constructor creates the end iterator
|
||||
BOOST_TEST(fs::recursive_directory_iterator("nosuchdir", ec)
|
||||
== fs::recursive_directory_iterator());
|
||||
BOOST_TEST(fs::recursive_directory_iterator("nosuchdir", ec) == fs::recursive_directory_iterator());
|
||||
BOOST_TEST(ec);
|
||||
|
||||
fs::remove_all(unique_dir); // clean up behind ourselves
|
||||
|
@ -25,8 +25,7 @@
|
||||
|
||||
// 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()
|
||||
#if defined(BOOST_WINDOWS_API) \
|
||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405) // not Dinkumware || no wide overloads
|
||||
#if defined(BOOST_WINDOWS_API) && (!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
|
||||
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
||||
#define BOOST_FILESYSTEM_C_STR c_str()
|
||||
@ -88,7 +87,9 @@ directory_tree collect_directory_tree(fs::path const& root_dir)
|
||||
std::cout << "Collecting directory tree in: " << root_dir << '\n';
|
||||
|
||||
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)
|
||||
{
|
||||
fs::path p = fs::relative(it->path(), root_dir);
|
||||
@ -312,17 +313,18 @@ int main()
|
||||
{
|
||||
fs::create_symlink("f1", root_dir / "s1");
|
||||
symlinks_supported = true;
|
||||
std::cout <<
|
||||
" *** For information only ***\n"
|
||||
" create_symlink() attempt succeeded" << std::endl;
|
||||
std::cout << " *** For information only ***\n"
|
||||
" create_symlink() attempt succeeded"
|
||||
<< std::endl;
|
||||
}
|
||||
catch (fs::filesystem_error& e)
|
||||
{
|
||||
std::cout <<
|
||||
" *** For information only ***\n"
|
||||
std::cout << " *** For information only ***\n"
|
||||
" create_symlink() attempt failed\n"
|
||||
" filesystem_error.what() reports: " << e.what() << "\n"
|
||||
" create_symlink() may not be supported on this operating system or file system" << std::endl;
|
||||
" filesystem_error.what() reports: "
|
||||
<< e.what() << "\n"
|
||||
" create_symlink() may not be supported on this operating system or file system"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
if (symlinks_supported)
|
||||
|
@ -28,14 +28,13 @@ using boost::filesystem::path;
|
||||
|
||||
#define PATH_CHECK(a, b) check(a, b, __LINE__)
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
std::string platform(BOOST_PLATFORM);
|
||||
|
||||
void check(const fs::path & source,
|
||||
const std::string & expected, int line)
|
||||
void check(const fs::path& source, const std::string& expected, int line)
|
||||
{
|
||||
if (source.generic_string()== expected) return;
|
||||
if (source.generic_string() == expected)
|
||||
return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -186,7 +185,6 @@ namespace
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
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
|
||||
// so that compile errors for all platforms will be detected even though
|
||||
// only the current platform is runtime tested.
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
|
||||
? "Windows"
|
||||
: "POSIX";
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||
std::cout << "Platform is " << platform << '\n';
|
||||
|
||||
BOOST_TEST(fs::initial_path() == fs::current_path());
|
||||
|
@ -35,14 +35,15 @@ namespace fs = boost::filesystem;
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::remove; }
|
||||
namespace std {
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
bool cleanup = true;
|
||||
|
||||
void test(const fs::path& p)
|
||||
@ -140,7 +141,8 @@ namespace
|
||||
|
||||
int cpp_main(int argc, char*[])
|
||||
{
|
||||
if (argc > 1) cleanup = false;
|
||||
if (argc > 1)
|
||||
cleanup = false;
|
||||
|
||||
std::cout << "BOOST_FILESYSTEM_C_STR defined as \""
|
||||
<< BOOST_STRINGIZE(BOOST_FILESYSTEM_C_STR) << "\"\n";
|
||||
@ -149,7 +151,6 @@ int cpp_main(int argc, char*[])
|
||||
std::cout << "narrow character tests:\n";
|
||||
test("narrow_fstream_test");
|
||||
|
||||
|
||||
// So that tests are run with known encoding, use Boost UTF-8 codecvt
|
||||
std::locale global_loc = std::locale();
|
||||
std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
|
||||
|
@ -5,4 +5,3 @@ int main(void)
|
||||
boost::filesystem::copy_file("a", "b");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,12 @@ int main(int argc, char** argv)
|
||||
cout << "current path is " << my_path << endl;
|
||||
cout << "parent path is " << my_path.parent_path() << endl;
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
cerr << endl << "Error during execution: " << e.what() << endl << endl;
|
||||
catch (std::exception& e)
|
||||
{
|
||||
cerr << endl
|
||||
<< "Error during execution: " << e.what() << endl
|
||||
<< endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,8 @@ void remover()
|
||||
|
||||
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()
|
||||
@ -24,15 +25,16 @@ int main()
|
||||
boost::filesystem::remove(FNAME);
|
||||
boost::filesystem::remove(FNAME);
|
||||
|
||||
std::cout <<
|
||||
"If you got this far, it's OK to remove a file that doesn't exist\n"
|
||||
std::cout << "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"
|
||||
"This is likely to crash after just a few seconds at most." <<
|
||||
std::endl;
|
||||
"This is likely to crash after just a few seconds at most."
|
||||
<< std::endl;
|
||||
|
||||
boost::thread c(creater), r1(remover), r2(remover);
|
||||
|
||||
c.join();
|
||||
r1.interrupt(); r1.join();
|
||||
r2.interrupt(); r2.join();
|
||||
r1.interrupt();
|
||||
r1.join();
|
||||
r2.interrupt();
|
||||
r2.join();
|
||||
}
|
||||
|
@ -8,17 +8,16 @@
|
||||
namespace fs = boost::filesystem;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
fs::recursive_directory_iterator beg("."), end;
|
||||
|
||||
auto fileFilter = [](fs::path const & path)
|
||||
{
|
||||
auto fileFilter = [](fs::path const& path) {
|
||||
return is_regular_file(path);
|
||||
};
|
||||
|
||||
std::vector< fs::path > paths;
|
||||
copy(boost::make_iterator_range(beg, end) | filtered(fileFilter),
|
||||
std::back_inserter(paths));
|
||||
copy(boost::make_iterator_range(beg, end) | filtered(fileFilter), std::back_inserter(paths));
|
||||
|
||||
for (auto& p : paths)
|
||||
std::cout << p << "\n";
|
||||
|
@ -6,20 +6,20 @@
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
|
||||
std::locale global_loc = std::locale();
|
||||
std::locale loc(global_loc, new stdext::cvt::codecvt_cp950< wchar_t >);
|
||||
fs::path::imbue(loc);
|
||||
|
||||
std::cout <<
|
||||
"HEADS UP! PIPE OUTPUT TO FILE AND INSPECT WITH HEX OR CP950 EDITOR.\n"
|
||||
std::cout << "HEADS UP! PIPE OUTPUT TO FILE AND INSPECT WITH HEX OR CP950 EDITOR.\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 iter
|
||||
("C:/boost/test-files/utf-8");
|
||||
fs::recursive_directory_iterator iter("C:/boost/test-files/utf-8");
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
|
@ -16,5 +16,3 @@ int main()
|
||||
std::cout << path("a/b/c/d/e/").stem() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Before running this test: export LANG=foo
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
boost::filesystem::path("/abc").root_directory();
|
||||
}
|
||||
|
||||
|
@ -7,4 +7,3 @@ int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@ namespace fs = boost::filesystem;
|
||||
struct TmpDir
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -82,4 +83,3 @@ int main()
|
||||
}
|
||||
|
||||
#endif // defined(BOOST_FILESYSTEM_HAS_MKLINK)
|
||||
|
||||
|
@ -24,7 +24,10 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
{ std::ofstream file("out"); file << "contents"; }
|
||||
{
|
||||
std::ofstream file("out");
|
||||
file << "contents";
|
||||
}
|
||||
|
||||
assert(!::symlink("out", "sym"));
|
||||
|
||||
|
@ -41,8 +41,7 @@ using std::endl;
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
#include <windows.h>
|
||||
#endif
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
typedef int errno_t;
|
||||
std::string platform(BOOST_PLATFORM);
|
||||
bool report_throws = false;
|
||||
|
@ -27,12 +27,15 @@
|
||||
// https://docs.microsoft.com/en-us/windows/compatibility/placeholder-files?redirectedfrom=MSDN
|
||||
|
||||
#if !defined(__MINGW32__) || defined(__MINGW64__)
|
||||
typedef struct _REPARSE_DATA_BUFFER {
|
||||
typedef struct _REPARSE_DATA_BUFFER
|
||||
{
|
||||
ULONG ReparseTag;
|
||||
USHORT ReparseDataLength;
|
||||
USHORT Reserved;
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
USHORT SubstituteNameOffset;
|
||||
USHORT SubstituteNameLength;
|
||||
USHORT PrintNameOffset;
|
||||
@ -40,14 +43,16 @@ typedef struct _REPARSE_DATA_BUFFER {
|
||||
ULONG Flags;
|
||||
WCHAR PathBuffer[1];
|
||||
} SymbolicLinkReparseBuffer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
USHORT SubstituteNameOffset;
|
||||
USHORT SubstituteNameLength;
|
||||
USHORT PrintNameOffset;
|
||||
USHORT PrintNameLength;
|
||||
WCHAR PathBuffer[1];
|
||||
} MountPointReparseBuffer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
UCHAR DataBuffer[1];
|
||||
} GenericReparseBuffer;
|
||||
};
|
||||
@ -104,9 +109,7 @@ bool create_io_reparse_file_placeholder(const wchar_t* name)
|
||||
return false;
|
||||
}
|
||||
|
||||
HANDLE hHandle = CreateFileW(name, GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
||||
FILE_FLAG_OPEN_REPARSE_POINT, 0);
|
||||
HANDLE hHandle = CreateFileW(name, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_FLAG_OPEN_REPARSE_POINT, 0);
|
||||
|
||||
if (hHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -119,9 +122,7 @@ bool create_io_reparse_file_placeholder(const wchar_t* name)
|
||||
pReparse->ReparseTag = IO_REPARSE_TAG_FILE_PLACEHOLDER;
|
||||
|
||||
DWORD dwLen;
|
||||
bool ret = DeviceIoControl(hHandle, FSCTL_SET_REPARSE_POINT, pReparse,
|
||||
pReparse->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE,
|
||||
NULL, 0, &dwLen, NULL) != 0;
|
||||
bool ret = DeviceIoControl(hHandle, FSCTL_SET_REPARSE_POINT, pReparse, pReparse->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, NULL, 0, &dwLen, NULL) != 0;
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
@ -16,15 +16,12 @@ using namespace std;
|
||||
#pragma warning(disable : 4996) // ... Function call with parameters that may be unsafe
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
void facet_info(const locale& loc, const char* msg)
|
||||
{
|
||||
cout << "has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >("
|
||||
<< msg << ") is "
|
||||
<< (has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)
|
||||
? "true\n"
|
||||
: "false\n");
|
||||
<< (has_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc) ? "true\n" : "false\n");
|
||||
}
|
||||
|
||||
void default_info()
|
||||
@ -68,7 +65,7 @@ namespace
|
||||
cout << "\nlocale(locale::clasic()) copy construction threw: " << ex.what() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -20,8 +20,7 @@ using namespace boost::filesystem;
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
} // unnamed namespace
|
||||
|
||||
int cpp_main(int, char*[])
|
||||
@ -30,8 +29,7 @@ int cpp_main(int, char*[])
|
||||
std::string prefix("d:\\temp\\");
|
||||
std::cout << "prefix is " << prefix << '\n';
|
||||
|
||||
const std::size_t safe_size
|
||||
= 260 - prefix.size() - 100; // Windows MAX_PATH is 260
|
||||
const std::size_t safe_size = 260 - prefix.size() - 100; // Windows MAX_PATH is 260
|
||||
|
||||
std::string safe_x_string(safe_size, 'x');
|
||||
std::string safe_y_string(safe_size, 'y');
|
||||
|
@ -25,7 +25,6 @@
|
||||
#error BOOST_FILESYSTEM_STATIC_LINK not set by default
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_SYSTEM_STATIC_LINK
|
||||
#error BOOST_SYSTEM_STATIC_LINK not set by default
|
||||
#endif
|
||||
|
@ -9,13 +9,11 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
void tu2();
|
||||
}
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -9,10 +9,12 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace boost
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
|
||||
void tu2()
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
void tu2() {}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
@ -100,8 +100,7 @@ inline void unsetenv_(const char* name)
|
||||
|
||||
// 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()
|
||||
#if defined(BOOST_WINDOWS_API) \
|
||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405) // not Dinkumware || no wide overloads
|
||||
#if defined(BOOST_WINDOWS_API) && (!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
|
||||
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
||||
#define BOOST_FILESYSTEM_C_STR c_str()
|
||||
@ -109,8 +108,7 @@ inline void unsetenv_(const char* name)
|
||||
|
||||
#define CHECK_EXCEPTION(Functor, Expect) throws_fs_error(Functor, Expect, __LINE__)
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
typedef int errno_t;
|
||||
std::string platform(BOOST_PLATFORM);
|
||||
bool report_throws = false;
|
||||
@ -137,38 +135,40 @@ namespace
|
||||
{
|
||||
std::ofstream f(ph.BOOST_FILESYSTEM_C_STR);
|
||||
if (!f)
|
||||
throw fs::filesystem_error("operations_test create_file",
|
||||
ph, error_code(errno, system_category()));
|
||||
if (!contents.empty()) f << contents;
|
||||
throw fs::filesystem_error("operations_test create_file", ph, error_code(errno, system_category()));
|
||||
if (!contents.empty())
|
||||
f << contents;
|
||||
}
|
||||
|
||||
void verify_file(const fs::path& ph, const std::string& expected)
|
||||
{
|
||||
std::ifstream f(ph.BOOST_FILESYSTEM_C_STR);
|
||||
if (!f)
|
||||
throw fs::filesystem_error("operations_test verify_file",
|
||||
ph, error_code(errno, system_category()));
|
||||
throw fs::filesystem_error("operations_test verify_file", ph, error_code(errno, system_category()));
|
||||
std::string contents;
|
||||
f >> contents;
|
||||
if (contents != expected)
|
||||
throw fs::filesystem_error("operations_test verify_file contents \""
|
||||
+ contents + "\" != \"" + expected + "\"", ph, error_code());
|
||||
throw fs::filesystem_error("operations_test verify_file contents \"" + contents + "\" != \"" + expected + "\"", ph, error_code());
|
||||
}
|
||||
|
||||
template< typename F >
|
||||
bool throws_fs_error(F func, errno_t en, int line)
|
||||
{
|
||||
try { func(); }
|
||||
try
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
if (report_throws)
|
||||
{
|
||||
// use the what() convenience function to display exceptions
|
||||
cout << "\n" << ex.what() << "\n";
|
||||
cout << "\n"
|
||||
<< ex.what() << "\n";
|
||||
}
|
||||
if (en == 0
|
||||
|| en == ex.code().default_error_condition().value()) return true;
|
||||
if (en == 0 || en == ex.code().default_error_condition().value())
|
||||
return true;
|
||||
cout
|
||||
<< "\nWarning: line " << line
|
||||
<< " exception reports default_error_condition().value() "
|
||||
@ -249,12 +249,13 @@ namespace
|
||||
class renamer
|
||||
{
|
||||
public:
|
||||
renamer(const fs::path & p1, const fs::path & p2)
|
||||
: from(p1), to(p2) {}
|
||||
renamer(const fs::path& p1, const fs::path& p2) :
|
||||
from(p1), to(p2) {}
|
||||
void operator()()
|
||||
{
|
||||
fs::rename(from, to);
|
||||
}
|
||||
|
||||
private:
|
||||
fs::path from;
|
||||
fs::path to;
|
||||
@ -323,13 +324,12 @@ namespace
|
||||
catch (std::runtime_error x)
|
||||
{
|
||||
exception_thrown = true;
|
||||
if (report_throws) cout << x.what() << endl;
|
||||
if (report_throws)
|
||||
cout << x.what() << endl;
|
||||
if (platform == "Windows" && language_id == 0x0409) // English (United States)
|
||||
// the stdcxx standard library apparently appends additional info
|
||||
// to what(), so check only the initial portion:
|
||||
BOOST_TEST(std::strncmp(x.what(),
|
||||
"boost::filesystem::create_directory",
|
||||
sizeof("boost::filesystem::create_directory")-1) == 0);
|
||||
BOOST_TEST(std::strncmp(x.what(), "boost::filesystem::create_directory", sizeof("boost::filesystem::create_directory") - 1) == 0);
|
||||
}
|
||||
BOOST_TEST(exception_thrown);
|
||||
|
||||
@ -344,10 +344,10 @@ namespace
|
||||
catch (system_error x)
|
||||
{
|
||||
exception_thrown = true;
|
||||
if (report_throws) cout << x.what() << endl;
|
||||
if (report_throws)
|
||||
cout << x.what() << endl;
|
||||
if (platform == "Windows" && language_id == 0x0409) // English (United States)
|
||||
BOOST_TEST(std::strcmp(x.what(),
|
||||
"boost::filesystem::create_directory: The system cannot find the path specified") == 0);
|
||||
BOOST_TEST(std::strcmp(x.what(), "boost::filesystem::create_directory: The system cannot find the path specified") == 0);
|
||||
}
|
||||
BOOST_TEST(exception_thrown);
|
||||
|
||||
@ -362,11 +362,11 @@ namespace
|
||||
catch (fs::filesystem_error x)
|
||||
{
|
||||
exception_thrown = true;
|
||||
if (report_throws) cout << x.what() << endl;
|
||||
if (report_throws)
|
||||
cout << x.what() << endl;
|
||||
if (platform == "Windows" && language_id == 0x0409) // English (United States)
|
||||
{
|
||||
bool ok (std::strcmp(x.what(),
|
||||
"boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
|
||||
bool ok(std::strcmp(x.what(), "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
|
||||
BOOST_TEST(ok);
|
||||
if (!ok)
|
||||
{
|
||||
@ -387,11 +387,11 @@ namespace
|
||||
catch (const fs::filesystem_error& x)
|
||||
{
|
||||
exception_thrown = true;
|
||||
if (report_throws) cout << x.what() << endl;
|
||||
if (report_throws)
|
||||
cout << x.what() << endl;
|
||||
if (platform == "Windows" && language_id == 0x0409) // English (United States)
|
||||
{
|
||||
bool ok (std::strcmp(x.what(),
|
||||
"boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
|
||||
bool ok(std::strcmp(x.what(), "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
|
||||
BOOST_TEST(ok);
|
||||
if (!ok)
|
||||
{
|
||||
@ -486,8 +486,14 @@ namespace
|
||||
cout << "directory_iterator_tests..." << endl;
|
||||
|
||||
bool dir_itr_exception(false);
|
||||
try { fs::directory_iterator it(""); }
|
||||
catch (const fs::filesystem_error &) { dir_itr_exception = true; }
|
||||
try
|
||||
{
|
||||
fs::directory_iterator it("");
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
dir_itr_exception = true;
|
||||
}
|
||||
BOOST_TEST(dir_itr_exception);
|
||||
|
||||
error_code ec;
|
||||
@ -497,8 +503,14 @@ namespace
|
||||
BOOST_TEST(ec);
|
||||
|
||||
dir_itr_exception = false;
|
||||
try { fs::directory_iterator itx("nosuchdirectory"); }
|
||||
catch (const fs::filesystem_error &) { dir_itr_exception = true; }
|
||||
try
|
||||
{
|
||||
fs::directory_iterator itx("nosuchdirectory");
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
dir_itr_exception = true;
|
||||
}
|
||||
BOOST_TEST(dir_itr_exception);
|
||||
|
||||
ec.clear();
|
||||
@ -513,7 +525,10 @@ namespace
|
||||
BOOST_TEST(ecx);
|
||||
BOOST_TEST(ecx == boost::system::errc::no_such_file_or_directory);
|
||||
}
|
||||
catch (const fs::filesystem_error &) { dir_itr_exception = true; }
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
dir_itr_exception = true;
|
||||
}
|
||||
BOOST_TEST(!dir_itr_exception);
|
||||
|
||||
// create a second directory named d2
|
||||
@ -655,8 +670,7 @@ namespace
|
||||
//cout << " walk_tree" << endl;
|
||||
error_code ec;
|
||||
int d1f1_count = 0;
|
||||
for (fs::recursive_directory_iterator it (dir,
|
||||
recursive ? (fs::directory_options::follow_directory_symlink | fs::directory_options::skip_dangling_symlinks) : fs::directory_options::none);
|
||||
for (fs::recursive_directory_iterator it(dir, recursive ? (fs::directory_options::follow_directory_symlink | fs::directory_options::skip_dangling_symlinks) : fs::directory_options::none);
|
||||
it != fs::recursive_directory_iterator();
|
||||
it.increment(ec))
|
||||
{
|
||||
@ -707,8 +721,7 @@ namespace
|
||||
fs::create_symlink(dir / "f0", dir / "f0_symlink", ec);
|
||||
fs::create_symlink(dir / "no such file", dir / "dangling_symlink", ec);
|
||||
fs::create_directory_symlink(dir / "d1", dir / "d1_symlink", ec);
|
||||
fs::create_directory_symlink(dir/"no such directory",
|
||||
dir/"dangling_directory_symlink", ec);
|
||||
fs::create_directory_symlink(dir / "no such directory", dir / "dangling_directory_symlink", ec);
|
||||
|
||||
for (fs::directory_iterator it(dir);
|
||||
it != fs::directory_iterator(); ++it)
|
||||
@ -787,14 +800,18 @@ namespace
|
||||
BOOST_TEST(!fs::exists(from_ph));
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
bool create_hard_link_ok(true);
|
||||
try { fs::create_hard_link(f1x, from_ph); }
|
||||
try
|
||||
{
|
||||
fs::create_hard_link(f1x, from_ph);
|
||||
}
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
create_hard_link_ok = false;
|
||||
cout
|
||||
<< " *** For information only ***\n"
|
||||
" create_hard_link() attempt failed\n"
|
||||
" filesystem_error.what() reports: " << ex.what() << "\n"
|
||||
" filesystem_error.what() reports: "
|
||||
<< ex.what() << "\n"
|
||||
" create_hard_link() may not be supported on this file system\n";
|
||||
}
|
||||
|
||||
@ -816,8 +833,7 @@ namespace
|
||||
BOOST_TEST(create_hard_link_ok);
|
||||
|
||||
error_code ec;
|
||||
fs::create_hard_link(fs::path("doesnotexist"),
|
||||
fs::path("shouldnotwork"), ec);
|
||||
fs::create_hard_link(fs::path("doesnotexist"), fs::path("shouldnotwork"), ec);
|
||||
BOOST_TEST(ec);
|
||||
}
|
||||
|
||||
@ -831,14 +847,18 @@ namespace
|
||||
fs::path f1x(dir / "f1");
|
||||
BOOST_TEST(!fs::exists(from_ph));
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
try { fs::create_symlink(f1x, from_ph); }
|
||||
try
|
||||
{
|
||||
fs::create_symlink(f1x, from_ph);
|
||||
}
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
create_symlink_ok = false;
|
||||
cout
|
||||
<< " *** For information only ***\n"
|
||||
" create_symlink() attempt failed\n"
|
||||
" filesystem_error.what() reports: " << ex.what() << "\n"
|
||||
" filesystem_error.what() reports: "
|
||||
<< ex.what() << "\n"
|
||||
" create_symlink() may not be supported on this operating system or file system\n";
|
||||
}
|
||||
|
||||
@ -926,7 +946,6 @@ namespace
|
||||
cout << " status(p2).permissions(): " << fs::status(p2).permissions() << endl;
|
||||
cout << std::dec;
|
||||
}
|
||||
|
||||
}
|
||||
else // Windows
|
||||
{
|
||||
@ -1113,7 +1132,8 @@ namespace
|
||||
catch (const fs::filesystem_error& x)
|
||||
{
|
||||
cout << x.what() << "\n\n"
|
||||
"***** Creating directory " << dir << " failed. *****\n"
|
||||
"***** Creating directory "
|
||||
<< dir << " failed. *****\n"
|
||||
"***** This is a serious error that will prevent further tests *****\n"
|
||||
"***** from returning useful results. Further testing is aborted. *****\n\n";
|
||||
std::exit(1);
|
||||
@ -1122,7 +1142,8 @@ namespace
|
||||
catch (...)
|
||||
{
|
||||
cout << "\n\n"
|
||||
"***** Creating directory " << dir << " failed. *****\n"
|
||||
"***** Creating directory "
|
||||
<< dir << " failed. *****\n"
|
||||
"***** This is a serious error that will prevent further tests *****\n"
|
||||
"***** from returning useful results. Further testing is aborted. *****\n\n";
|
||||
std::exit(1);
|
||||
@ -1508,7 +1529,6 @@ namespace
|
||||
BOOST_TEST_EQ(fs::absolute(fs::path("./foo"), "/abc"), "/abc/./foo");
|
||||
BOOST_TEST_EQ(fs::absolute(fs::path("../foo"), "/abc"), "/abc/../foo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// canonical_basic_tests -----------------------------------------------------------//
|
||||
@ -1526,8 +1546,14 @@ namespace
|
||||
fs::canonical("no-such-file", "x", ec);
|
||||
BOOST_TEST(ec);
|
||||
bool ok(false);
|
||||
try { fs::canonical("no-such-file"); }
|
||||
catch (const fs::filesystem_error&) { ok = true; }
|
||||
try
|
||||
{
|
||||
fs::canonical("no-such-file");
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
BOOST_TEST(ok);
|
||||
|
||||
// non-symlink tests; also see canonical_symlink_tests()
|
||||
@ -1609,15 +1635,27 @@ namespace
|
||||
|
||||
bool copy_ex_ok = false;
|
||||
file_copied = false;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2"); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2");
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = true;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(!file_copied);
|
||||
|
||||
file_copied = false;
|
||||
copy_ex_ok = false;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::none); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::none);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = true;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(!file_copied);
|
||||
|
||||
@ -1626,8 +1664,14 @@ namespace
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U);
|
||||
file_copied = false;
|
||||
copy_ex_ok = true;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::skip_existing); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::skip_existing);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = false;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(!file_copied);
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U);
|
||||
@ -1635,8 +1679,14 @@ namespace
|
||||
|
||||
file_copied = false;
|
||||
copy_ex_ok = true;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2-non-existing", fs::copy_options::skip_existing); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2-non-existing", fs::copy_options::skip_existing);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = false;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(file_copied);
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2-non-existing"), 7U);
|
||||
@ -1645,8 +1695,14 @@ namespace
|
||||
|
||||
file_copied = false;
|
||||
copy_ex_ok = true;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::update_existing); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::update_existing);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = false;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(!file_copied);
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U);
|
||||
@ -1663,8 +1719,14 @@ namespace
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2-more-recent"), 1U);
|
||||
file_copied = false;
|
||||
copy_ex_ok = true;
|
||||
try { file_copied = fs::copy_file(d1x / "f2-more-recent", d1x / "f2", fs::copy_options::update_existing); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(d1x / "f2-more-recent", d1x / "f2", fs::copy_options::update_existing);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = false;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(file_copied);
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 1U);
|
||||
@ -1676,8 +1738,14 @@ namespace
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U);
|
||||
file_copied = false;
|
||||
copy_ex_ok = true;
|
||||
try { file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::overwrite_existing); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
try
|
||||
{
|
||||
file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::overwrite_existing);
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = false;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST(file_copied);
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 7U);
|
||||
@ -1769,13 +1837,25 @@ namespace
|
||||
//BOOST_TEST(fs::is_symlink(sym3));
|
||||
|
||||
bool copy_ex_ok = false;
|
||||
try { fs::copy_symlink("no-such-file", "new-symlink1"); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
try
|
||||
{
|
||||
fs::copy_symlink("no-such-file", "new-symlink1");
|
||||
}
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = true;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
|
||||
copy_ex_ok = false;
|
||||
try { fs::copy_symlink(f1x, "new-symlink2"); } // should fail; f1x not symlink
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
try
|
||||
{
|
||||
fs::copy_symlink(f1x, "new-symlink2");
|
||||
} // should fail; f1x not symlink
|
||||
catch (const fs::filesystem_error&)
|
||||
{
|
||||
copy_ex_ok = true;
|
||||
}
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
}
|
||||
|
||||
@ -1889,13 +1969,11 @@ namespace
|
||||
|
||||
BOOST_TEST(!fs::exists("tools/jam/src/:sys:stat.h")); // !exists() if ERROR_INVALID_NAME
|
||||
BOOST_TEST(!fs::exists(":sys:stat.h")); // !exists() if ERROR_INVALID_PARAMETER
|
||||
BOOST_TEST(dir.string().size() > 1
|
||||
&& dir.string()[1] == ':'); // verify path includes drive
|
||||
BOOST_TEST(dir.string().size() > 1 && dir.string()[1] == ':'); // verify path includes drive
|
||||
|
||||
BOOST_TEST(fs::system_complete("").empty());
|
||||
BOOST_TEST(fs::system_complete("/") == fs::initial_path().root_path());
|
||||
BOOST_TEST(fs::system_complete("foo")
|
||||
== fs::initial_path() / "foo");
|
||||
BOOST_TEST(fs::system_complete("foo") == fs::initial_path() / "foo");
|
||||
|
||||
fs::path p1(fs::system_complete("/foo"));
|
||||
BOOST_TEST_EQ(p1.string().size(), 6U); // this failed during v3 development due to bug
|
||||
@ -1903,16 +1981,11 @@ namespace
|
||||
std::string s2(fs::initial_path().root_path().string() + "foo");
|
||||
BOOST_TEST_EQ(s1, s2);
|
||||
|
||||
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name()))
|
||||
== fs::initial_path());
|
||||
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name().string()
|
||||
+ "foo")).string() == fs::initial_path() / "foo");
|
||||
BOOST_TEST(fs::system_complete(fs::path("c:/")).generic_string()
|
||||
== "c:/");
|
||||
BOOST_TEST(fs::system_complete(fs::path("c:/foo")).generic_string()
|
||||
== "c:/foo");
|
||||
BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string()
|
||||
== "//share");
|
||||
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name())) == fs::initial_path());
|
||||
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name().string() + "foo")).string() == fs::initial_path() / "foo");
|
||||
BOOST_TEST(fs::system_complete(fs::path("c:/")).generic_string() == "c:/");
|
||||
BOOST_TEST(fs::system_complete(fs::path("c:/foo")).generic_string() == "c:/foo");
|
||||
BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string() == "//share");
|
||||
|
||||
#if defined(BOOST_FILESYSTEM_HAS_MKLINK)
|
||||
// Issue 9016 asked that NTFS directory junctions be recognized as directories.
|
||||
@ -1987,10 +2060,8 @@ namespace
|
||||
BOOST_TEST(fs::system_complete("").empty());
|
||||
BOOST_TEST(fs::initial_path().root_path().string() == "/");
|
||||
BOOST_TEST(fs::system_complete("/").string() == "/");
|
||||
BOOST_TEST(fs::system_complete("foo").string()
|
||||
== fs::initial_path().string()+"/foo");
|
||||
BOOST_TEST(fs::system_complete("/foo").string()
|
||||
== fs::initial_path().root_path().string()+"foo");
|
||||
BOOST_TEST(fs::system_complete("foo").string() == fs::initial_path().string() + "/foo");
|
||||
BOOST_TEST(fs::system_complete("/foo").string() == fs::initial_path().root_path().string() + "foo");
|
||||
} // POSIX
|
||||
}
|
||||
|
||||
@ -2006,8 +2077,7 @@ namespace
|
||||
BOOST_TEST(fs::initial_path() == fs::current_path());
|
||||
BOOST_TEST(fs::initial_path().is_absolute());
|
||||
BOOST_TEST(fs::current_path().is_absolute());
|
||||
BOOST_TEST(fs::initial_path().string()
|
||||
== fs::current_path().string());
|
||||
BOOST_TEST(fs::initial_path().string() == fs::current_path().string());
|
||||
}
|
||||
|
||||
// space_tests ---------------------------------------------------------------------//
|
||||
@ -2072,9 +2142,8 @@ namespace
|
||||
std::string m_string;
|
||||
bool m_empty;
|
||||
|
||||
previous_value(const char* name)
|
||||
: m_name(name)
|
||||
, m_empty (true)
|
||||
previous_value(const char* name) :
|
||||
m_name(name), m_empty(true)
|
||||
{
|
||||
if (const char* value = getenv(name))
|
||||
{
|
||||
@ -2088,15 +2157,14 @@ namespace
|
||||
}
|
||||
~previous_value()
|
||||
{
|
||||
m_empty? unsetenv_(m_name.c_str())
|
||||
: setenv_(m_name.c_str(), m_string.c_str(), 1);
|
||||
m_empty ? unsetenv_(m_name.c_str()) : setenv_(m_name.c_str(), m_string.c_str(), 1);
|
||||
}
|
||||
};
|
||||
|
||||
previous_value m_previous_value;
|
||||
|
||||
guarded_env_var(const char* name, const char* value)
|
||||
: m_previous_value(name)
|
||||
guarded_env_var(const char* name, const char* value) :
|
||||
m_previous_value(name)
|
||||
{
|
||||
// std::cout << name << " old value is \"" << getenv(name) << "\"" << std::endl;
|
||||
value ? setenv_(name, value, 1) : unsetenv_(name);
|
||||
@ -2119,7 +2187,8 @@ namespace
|
||||
|
||||
#if defined(__CYGWIN__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ == 4
|
||||
cout << "Bug in GCC 4.9 getenv() when !defined(__GXX_EXPERIMENTAL_CXX0X__) makes these"
|
||||
"tests meaningless, so skip them" << endl;
|
||||
"tests meaningless, so skip them"
|
||||
<< endl;
|
||||
return;
|
||||
#endif
|
||||
// Test ticket #5300, temp_directory_path failure on Windows with path length > 130.
|
||||
@ -2156,7 +2225,8 @@ namespace
|
||||
BOOST_TEST(exists(fs::temp_directory_path()));
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path("temp_directory_path_test_%%%%_%%%%.txt");
|
||||
{
|
||||
if(exists(ph)) remove(ph);
|
||||
if (exists(ph))
|
||||
remove(ph);
|
||||
std::ofstream f(ph.BOOST_FILESYSTEM_C_STR);
|
||||
f << "passed";
|
||||
}
|
||||
@ -2182,17 +2252,10 @@ namespace
|
||||
guarded_env_var m_temp;
|
||||
guarded_env_var m_tempdir;
|
||||
|
||||
guarded_tmp_vars
|
||||
( const fs::path::value_type* tmpdir
|
||||
, const fs::path::value_type* tmp
|
||||
, const fs::path::value_type* temp
|
||||
, const fs::path::value_type* tempdir
|
||||
)
|
||||
: m_tmpdir ("TMPDIR" , tmpdir )
|
||||
, m_tmp ("TMP" , tmp )
|
||||
, m_temp ("TEMP" , temp )
|
||||
, m_tempdir("TEMPDIR", tempdir)
|
||||
{}
|
||||
guarded_tmp_vars(const fs::path::value_type* tmpdir, const fs::path::value_type* tmp, const fs::path::value_type* temp, const fs::path::value_type* tempdir) :
|
||||
m_tmpdir("TMPDIR", tmpdir), m_tmp("TMP", tmp), m_temp("TEMP", temp), m_tempdir("TEMPDIR", tempdir)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
@ -2227,17 +2290,10 @@ namespace
|
||||
guarded_env_var m_localappdata;
|
||||
guarded_env_var m_userprofile;
|
||||
|
||||
guarded_tmp_vars
|
||||
( const char* tmp
|
||||
, const char* temp
|
||||
, const char* localappdata
|
||||
, const char* userprofile
|
||||
)
|
||||
: m_tmp ("TMP" , tmp )
|
||||
, m_temp ("TEMP" , temp )
|
||||
, m_localappdata ("LOCALAPPDATA" , localappdata)
|
||||
, m_userprofile ("USERPROFILE" , userprofile )
|
||||
{}
|
||||
guarded_tmp_vars(const char* tmp, const char* temp, const char* localappdata, const char* userprofile) :
|
||||
m_tmp("TMP", tmp), m_temp("TEMP", temp), m_localappdata("LOCALAPPDATA", localappdata), m_userprofile("USERPROFILE", userprofile)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// test the GetWindowsDirectoryW()/Temp fallback
|
||||
@ -2288,8 +2344,7 @@ namespace
|
||||
BOOST_TEST_EQ(fs::weakly_canonical(dir), dir);
|
||||
BOOST_TEST_EQ(fs::weakly_canonical(dir / "no-such/foo/bar"), dir / "no-such/foo/bar");
|
||||
BOOST_TEST_EQ(fs::weakly_canonical(dir / "no-such/foo/../bar"), dir / "no-such/bar");
|
||||
BOOST_TEST_EQ(fs::weakly_canonical(dir/"../no-such/foo/../bar"),
|
||||
dir.parent_path()/"no-such/bar");
|
||||
BOOST_TEST_EQ(fs::weakly_canonical(dir / "../no-such/foo/../bar"), dir.parent_path() / "no-such/bar");
|
||||
BOOST_TEST_EQ(fs::weakly_canonical("c:/no-such/foo/bar"), "c:/no-such/foo/bar");
|
||||
|
||||
fs::create_directory_symlink(dir / "d1", dir / "sld1");
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
// ------------------------------------------------------------------------------------//
|
||||
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
// See deprecated_test for tests of deprecated features
|
||||
@ -44,13 +43,13 @@ using std::string;
|
||||
|
||||
#define CHECK(x) check(x, __FILE__, __LINE__)
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
bool cleanup = true;
|
||||
|
||||
void check(bool ok, const char* file, int line)
|
||||
{
|
||||
if (ok) return;
|
||||
if (ok)
|
||||
return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -262,8 +261,7 @@ namespace
|
||||
{
|
||||
cout << "directory_entry test..." << endl;
|
||||
|
||||
directory_entry de("foo.bar",
|
||||
file_status(regular_file, owner_all), file_status(directory_file, group_all));
|
||||
directory_entry de("foo.bar", file_status(regular_file, owner_all), file_status(directory_file, group_all));
|
||||
|
||||
CHECK(de.path() == "foo.bar");
|
||||
CHECK(de.status() == file_status(regular_file, owner_all));
|
||||
@ -300,7 +298,8 @@ namespace
|
||||
{
|
||||
threw = true;
|
||||
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 (...)
|
||||
{
|
||||
|
@ -81,12 +81,10 @@ using boost::prior;
|
||||
|
||||
#define PATH_TEST_EQ(a, b) check(a, b, __FILE__, __LINE__)
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
std::string platform(BOOST_PLATFORM);
|
||||
|
||||
void check(const fs::path & source,
|
||||
const std::string & expected, const char* file, int line)
|
||||
void check(const fs::path& source, const std::string& expected, const char* file, int line)
|
||||
{
|
||||
if (source.string() == expected)
|
||||
return;
|
||||
@ -112,7 +110,10 @@ namespace
|
||||
std::cout << "exception_tests..." << std::endl;
|
||||
const std::string str_1("string-1");
|
||||
boost::system::error_code ec(12345, boost::system::system_category());
|
||||
try { throw fs::filesystem_error(str_1, ec); }
|
||||
try
|
||||
{
|
||||
throw fs::filesystem_error(str_1, ec);
|
||||
}
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
//std::cout << ex.what() << "*" << std::endl;
|
||||
@ -121,7 +122,10 @@ namespace
|
||||
BOOST_TEST(ex.code() == ec);
|
||||
}
|
||||
|
||||
try { throw fs::filesystem_error(str_1, "p1", "p2", ec); }
|
||||
try
|
||||
{
|
||||
throw fs::filesystem_error(str_1, "p1", "p2", ec);
|
||||
}
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
//std::cout << ex.what() << "*" << std::endl;
|
||||
@ -1389,7 +1393,6 @@ namespace
|
||||
void composition_tests()
|
||||
{
|
||||
std::cout << "composition_tests..." << std::endl;
|
||||
|
||||
}
|
||||
|
||||
// construction_tests ---------------------------------------------------------------//
|
||||
@ -1605,7 +1608,6 @@ namespace
|
||||
PATH_TEST_EQ(path("foo/") / "bar", "foo/bar");
|
||||
append_test_aux("foo/", "bar", "foo/bar");
|
||||
|
||||
|
||||
if (platform == "Windows")
|
||||
{
|
||||
PATH_TEST_EQ(path("foo") / "bar", "foo\\bar");
|
||||
@ -1681,7 +1683,6 @@ namespace
|
||||
PATH_TEST_EQ(p.append(p.c_str() + 5, p.c_str() + 7), "snafubar" BOOST_DIR_SEP "ba");
|
||||
}
|
||||
|
||||
|
||||
// name_function_tests -------------------------------------------------------------//
|
||||
|
||||
void name_function_tests()
|
||||
@ -1793,8 +1794,7 @@ namespace
|
||||
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
|
||||
BOOST_TEST(path("foo.txt").replace_extension("exe") == "foo.exe"); // ticket 5118
|
||||
BOOST_TEST(path("foo.txt").replace_extension(".tar.bz2")
|
||||
== "foo.tar.bz2"); // ticket 5118
|
||||
BOOST_TEST(path("foo.txt").replace_extension(".tar.bz2") == "foo.tar.bz2"); // ticket 5118
|
||||
}
|
||||
|
||||
// make_preferred_tests ------------------------------------------------------------//
|
||||
@ -1805,13 +1805,11 @@ namespace
|
||||
|
||||
if (platform == "Windows")
|
||||
{
|
||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native()
|
||||
== path("\\\\abc\\def\\ghi").native());
|
||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native() == path("\\\\abc\\def\\ghi").native());
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native()
|
||||
== path("//abc\\def/ghi").native());
|
||||
BOOST_TEST(path("//abc\\def/ghi").make_preferred().native() == path("//abc\\def/ghi").native());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1958,9 +1956,7 @@ int cpp_main(int, char*[])
|
||||
// The choice of platform is make at runtime rather than compile-time
|
||||
// so that compile errors for all platforms will be detected even though
|
||||
// only the current platform is runtime tested.
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
|
||||
? "Windows"
|
||||
: "POSIX";
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||
std::cout << "Platform is " << platform << '\n';
|
||||
|
||||
BOOST_TEST(p1.string() != p3.string());
|
||||
|
@ -36,8 +36,7 @@ using namespace boost::timer;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
boost::int64_t max_cycles;
|
||||
|
||||
template< class STD_STRING >
|
||||
|
@ -64,8 +64,7 @@ using std::wstring;
|
||||
#pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
boost::system::error_code ec;
|
||||
const boost::system::error_code ok;
|
||||
@ -73,10 +72,10 @@ namespace
|
||||
|
||||
std::string platform(BOOST_PLATFORM);
|
||||
|
||||
void check_path(const path& source,
|
||||
const wstring& expected, const char* file, int line)
|
||||
void check_path(const path& source, const wstring& expected, const char* file, int line)
|
||||
{
|
||||
if (source == expected) return;
|
||||
if (source == expected)
|
||||
return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -88,19 +87,19 @@ namespace
|
||||
}
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
void check_native(const path& p,
|
||||
const string&, const wstring& expected, const char* file, int line)
|
||||
void check_native(const path& p, const string&, const wstring& expected, const char* file, int line)
|
||||
#else
|
||||
void check_native(const path& p,
|
||||
const string& expected, const wstring&, const char* file, int line)
|
||||
void check_native(const path& p, 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();
|
||||
|
||||
std::cout << file << '(' << line << "): native() is not equal expected\n"
|
||||
" native---: " << std::hex;
|
||||
" native---: "
|
||||
<< std::hex;
|
||||
path::string_type nat(p.native());
|
||||
for (path::string_type::const_iterator it = nat.begin(); it != nat.end(); ++it)
|
||||
std::cout << long(*it) << ' ';
|
||||
@ -111,10 +110,10 @@ namespace
|
||||
}
|
||||
|
||||
template< class T1, class T2 >
|
||||
void check_equal(const T1& value,
|
||||
const T2& expected, const char* file, int line)
|
||||
void check_equal(const T1& value, const T2& expected, const char* file, int line)
|
||||
{
|
||||
if (value == expected) return;
|
||||
if (value == expected)
|
||||
return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -127,7 +126,8 @@ namespace
|
||||
|
||||
void check(bool ok_, const char* file, int line)
|
||||
{
|
||||
if (ok_) return;
|
||||
if (ok_)
|
||||
return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -141,9 +141,15 @@ namespace
|
||||
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
|
||||
|
||||
class Base {};
|
||||
class Derived : public Base {};
|
||||
void fun(const boost::shared_ptr< Base >&) {}
|
||||
class Base
|
||||
{
|
||||
};
|
||||
class Derived : public Base
|
||||
{
|
||||
};
|
||||
void fun(const boost::shared_ptr< Base >&)
|
||||
{
|
||||
}
|
||||
|
||||
// test_constructors ---------------------------------------------------------------//
|
||||
|
||||
@ -299,10 +305,8 @@ namespace
|
||||
if (!from2.empty())
|
||||
cout << "Note: move assignment did not result in empty rhs path" << endl;
|
||||
#else
|
||||
std::cout <<
|
||||
"Test skipped because compiler does not support move semantics" << std::endl;
|
||||
std::cout << "Test skipped because compiler does not support move semantics" << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// test_appends --------------------------------------------------------------------//
|
||||
@ -819,7 +823,6 @@ namespace
|
||||
CHECK(p2.has_extension());
|
||||
CHECK(p2.is_absolute());
|
||||
CHECK(!p2.is_relative());
|
||||
|
||||
}
|
||||
|
||||
// test_imbue_locale ---------------------------------------------------------------//
|
||||
@ -958,43 +961,45 @@ namespace
|
||||
|
||||
// test_error_handling -------------------------------------------------------------//
|
||||
|
||||
class error_codecvt
|
||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||
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:
|
||||
explicit error_codecvt() :
|
||||
std::codecvt< wchar_t, char, std::mbstate_t >()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool do_always_noconv() const throw() { return false; }
|
||||
virtual int do_encoding() const throw() { return 0; }
|
||||
|
||||
virtual std::codecvt_base::result do_in(std::mbstate_t&,
|
||||
const char*, const char*, const char*&,
|
||||
wchar_t*, wchar_t*, wchar_t*&) const
|
||||
virtual std::codecvt_base::result do_in(std::mbstate_t&, const char*, const char*, const char*&, wchar_t*, wchar_t*, wchar_t*&) const
|
||||
{
|
||||
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
||||
if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
|
||||
else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
|
||||
else r = std::codecvt_base::partial;
|
||||
if (r == std::codecvt_base::partial)
|
||||
r = std::codecvt_base::error;
|
||||
else if (r == std::codecvt_base::error)
|
||||
r = std::codecvt_base::noconv;
|
||||
else
|
||||
r = std::codecvt_base::partial;
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual std::codecvt_base::result do_out(std::mbstate_t &,
|
||||
const wchar_t*, const wchar_t*, const wchar_t*&,
|
||||
char*, char*, char*&) const
|
||||
virtual std::codecvt_base::result do_out(std::mbstate_t&, const wchar_t*, const wchar_t*, const wchar_t*&, char*, char*, char*&) const
|
||||
{
|
||||
static std::codecvt_base::result r = std::codecvt_base::noconv;
|
||||
if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
|
||||
else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
|
||||
else r = std::codecvt_base::partial;
|
||||
if (r == std::codecvt_base::partial)
|
||||
r = std::codecvt_base::error;
|
||||
else if (r == std::codecvt_base::error)
|
||||
r = std::codecvt_base::noconv;
|
||||
else
|
||||
r = std::codecvt_base::partial;
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual std::codecvt_base::result do_unshift(std::mbstate_t&,
|
||||
char*, char*, char* &) const { return ok; }
|
||||
virtual int do_length(std::mbstate_t &,
|
||||
const char*, const char*, std::size_t) const { return 0; }
|
||||
virtual std::codecvt_base::result do_unshift(std::mbstate_t&, 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_max_length() const throw() { return 0; }
|
||||
};
|
||||
|
||||
@ -1019,42 +1024,57 @@ namespace
|
||||
{
|
||||
std::cout << " testing std::codecvt_base::partial error..." << std::endl;
|
||||
bool exception_thrown(false);
|
||||
try { path(STRING_FOO_); }
|
||||
try
|
||||
{
|
||||
path(STRING_FOO_);
|
||||
}
|
||||
catch (const bs::system_error& ex)
|
||||
{
|
||||
exception_thrown = true;
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial,
|
||||
fs::codecvt_error_category()));
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial, fs::codecvt_error_category()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||
}
|
||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
||||
BOOST_TEST(exception_thrown);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << " testing std::codecvt_base::error error..." << std::endl;
|
||||
bool exception_thrown(false);
|
||||
try { path(STRING_FOO_); }
|
||||
try
|
||||
{
|
||||
path(STRING_FOO_);
|
||||
}
|
||||
catch (const bs::system_error& ex)
|
||||
{
|
||||
exception_thrown = true;
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error,
|
||||
fs::codecvt_error_category()));
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error, fs::codecvt_error_category()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||
}
|
||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
||||
BOOST_TEST(exception_thrown);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << " testing std::codecvt_base::noconv error..." << std::endl;
|
||||
bool exception_thrown(false);
|
||||
try { path(STRING_FOO_); }
|
||||
try
|
||||
{
|
||||
path(STRING_FOO_);
|
||||
}
|
||||
catch (const bs::system_error& ex)
|
||||
{
|
||||
exception_thrown = true;
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv,
|
||||
fs::codecvt_error_category()));
|
||||
BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv, fs::codecvt_error_category()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "***** unexpected exception type *****" << std::endl;
|
||||
}
|
||||
catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
|
||||
BOOST_TEST(exception_thrown);
|
||||
}
|
||||
|
||||
@ -1079,12 +1099,10 @@ namespace
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
namespace path_traits
|
||||
{
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
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; };
|
||||
@ -1112,21 +1130,19 @@ namespace filesystem
|
||||
#endif
|
||||
|
||||
template<>
|
||||
user_string convert<user_string>(const string_type & source,
|
||||
system::error_code & ec)
|
||||
user_string convert< user_string >(string_type const& source, system::error_code& ec)
|
||||
{
|
||||
user_string temp;
|
||||
for (string_type::const_iterator it = source.begin();
|
||||
it != source.end(); ++it)
|
||||
for (string_type::const_iterator it = source.begin(); it != source.end(); ++it)
|
||||
temp += *it - 1;
|
||||
return temp;
|
||||
}
|
||||
|
||||
} // namespace path_traits
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
void test_user_supplied_type()
|
||||
{
|
||||
@ -1158,9 +1174,7 @@ namespace
|
||||
//}
|
||||
//return not_defined;
|
||||
|
||||
return 0 == strcmp(name, value + 1)
|
||||
? not_defined
|
||||
: (value[1] ? value : no_value);
|
||||
return 0 == strcmp(name, value + 1) ? not_defined : (value[1] ? value : no_value);
|
||||
}
|
||||
|
||||
#define BOOST_MACRO_VALUE(X) macro_value(#X, BOOST_STRINGIZE(=X))
|
||||
@ -1239,9 +1253,7 @@ int test_main(int, char*[])
|
||||
test_error_handling();
|
||||
|
||||
#if 0
|
||||
|
||||
test_user_supplied_type();
|
||||
|
||||
#endif
|
||||
|
||||
std::string foo("\\abc");
|
||||
|
@ -22,8 +22,8 @@ using boost::filesystem::path;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
void lexically_relative_test()
|
||||
{
|
||||
cout << "lexically_relative_test..." << endl;
|
||||
@ -93,6 +93,7 @@ namespace
|
||||
// paths unrelated
|
||||
BOOST_TEST(path("a/b/c").lexically_proximate("x") == "a/b/c");
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
@ -30,8 +30,7 @@ using std::endl;
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
bool cleanup = true;
|
||||
}
|
||||
|
||||
|
@ -27,21 +27,20 @@
|
||||
// //
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
class test_codecvt
|
||||
: public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||
class test_codecvt :
|
||||
public std::codecvt< wchar_t, char, std::mbstate_t >
|
||||
{
|
||||
public:
|
||||
explicit test_codecvt()
|
||||
: std::codecvt<wchar_t, char, std::mbstate_t>() {}
|
||||
explicit test_codecvt() :
|
||||
std::codecvt< wchar_t, char, std::mbstate_t >()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool do_always_noconv() const throw() { return false; }
|
||||
|
||||
virtual int do_encoding() const throw() { return 0; }
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
for (; from != from_end && to != to_end; ++from, ++to)
|
||||
*to = wchar_t(*from + 1);
|
||||
@ -53,9 +52,7 @@
|
||||
return ok;
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
for (; from != from_end && to != to_end; ++from, ++to)
|
||||
*to = static_cast< char >(*from - 1);
|
||||
@ -67,12 +64,8 @@
|
||||
return ok;
|
||||
}
|
||||
|
||||
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 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; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user