mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Clear warnings, including new warnings from VC++ 2015 preview.
This commit is contained in:
parent
f17852e98d
commit
bb5a0ff09d
@ -158,8 +158,8 @@ namespace filesystem
|
||||
{
|
||||
// convert requires contiguous string, so copy
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,8 +170,8 @@ namespace filesystem
|
||||
{
|
||||
// convert requires contiguous string, so copy
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname, cvt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,8 +219,8 @@ namespace filesystem
|
||||
if (begin != end)
|
||||
{
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -232,8 +232,8 @@ namespace filesystem
|
||||
if (begin != end)
|
||||
{
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname, cvt);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -286,8 +286,8 @@ namespace filesystem
|
||||
if (begin == end)
|
||||
return *this;
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -297,8 +297,8 @@ namespace filesystem
|
||||
if (begin == end)
|
||||
return *this;
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
|
||||
seq(begin, end);
|
||||
path_traits::convert(seq.c_str(), seq.c_str()+seq.size(), m_pathname, cvt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -739,8 +739,8 @@ namespace filesystem
|
||||
return *this;
|
||||
string_type::size_type sep_pos(m_append_separator_if_needed());
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname);
|
||||
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);
|
||||
return *this;
|
||||
@ -753,8 +753,8 @@ namespace filesystem
|
||||
return *this;
|
||||
string_type::size_type sep_pos(m_append_separator_if_needed());
|
||||
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
||||
s(begin, end);
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
|
||||
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);
|
||||
return *this;
|
||||
|
@ -318,8 +318,8 @@ namespace path_traits {
|
||||
{
|
||||
if (c.size())
|
||||
{
|
||||
std::basic_string<typename Container::value_type> s(c.begin(), c.end());
|
||||
convert(s.c_str(), s.c_str()+s.size(), to);
|
||||
std::basic_string<typename Container::value_type> seq(c.begin(), c.end());
|
||||
convert(seq.c_str(), seq.c_str()+seq.size(), to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -660,11 +660,11 @@ namespace filesystem
|
||||
const path& dot_path()
|
||||
{
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
static const fs::path dot(L".");
|
||||
static const fs::path dot_pth(L".");
|
||||
# else
|
||||
static const fs::path dot(".");
|
||||
static const fs::path dot_pth(".");
|
||||
# endif
|
||||
return dot;
|
||||
return dot_pth;
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
|
@ -453,21 +453,21 @@ namespace
|
||||
BOOST_TEST(ec);
|
||||
|
||||
dir_itr_exception = false;
|
||||
try { fs::directory_iterator it("nosuchdirectory"); }
|
||||
try { fs::directory_iterator itx("nosuchdirectory"); }
|
||||
catch (const fs::filesystem_error &) { dir_itr_exception = true; }
|
||||
BOOST_TEST(dir_itr_exception);
|
||||
|
||||
ec.clear();
|
||||
fs::directory_iterator it2("nosuchdirectory", ec);
|
||||
fs::directory_iterator it2x("nosuchdirectory", ec);
|
||||
BOOST_TEST(ec);
|
||||
|
||||
dir_itr_exception = false;
|
||||
try
|
||||
{
|
||||
error_code ec;
|
||||
fs::directory_iterator it("nosuchdirectory", ec);
|
||||
BOOST_TEST(ec);
|
||||
BOOST_TEST(ec == boost::system::errc::no_such_file_or_directory);
|
||||
error_code ecx;
|
||||
fs::directory_iterator itx("nosuchdirectory", ecx);
|
||||
BOOST_TEST(ecx);
|
||||
BOOST_TEST(ecx == boost::system::errc::no_such_file_or_directory);
|
||||
}
|
||||
catch (const fs::filesystem_error &) { dir_itr_exception = true; }
|
||||
BOOST_TEST(!dir_itr_exception);
|
||||
@ -553,14 +553,14 @@ namespace
|
||||
BOOST_TEST(dir_itr->path() != p);
|
||||
|
||||
// test case reported in comment to SourceForge bug tracker [937606]
|
||||
fs::directory_iterator it(dir);
|
||||
const fs::path p1 = (*it++).path();
|
||||
BOOST_TEST(it != fs::directory_iterator());
|
||||
const fs::path p2 = (*it++).path();
|
||||
fs::directory_iterator itx(dir);
|
||||
const fs::path p1 = (*itx++).path();
|
||||
BOOST_TEST(itx != fs::directory_iterator());
|
||||
const fs::path p2 = (*itx++).path();
|
||||
BOOST_TEST(p1 != p2);
|
||||
++it;
|
||||
++it;
|
||||
BOOST_TEST(it == fs::directory_iterator());
|
||||
++itx;
|
||||
++itx;
|
||||
BOOST_TEST(itx == fs::directory_iterator());
|
||||
}
|
||||
|
||||
// Windows has a tricky special case when just the root-name is given,
|
||||
@ -569,17 +569,17 @@ namespace
|
||||
if (platform == "Windows")
|
||||
{
|
||||
fs::path root_name_path(fs::current_path().root_name());
|
||||
fs::directory_iterator it(root_name_path);
|
||||
BOOST_TEST(it != fs::directory_iterator());
|
||||
// BOOST_TEST(fs::exists((*it).path()));
|
||||
BOOST_TEST(fs::exists(it->path()));
|
||||
BOOST_TEST(it->path().parent_path() == root_name_path);
|
||||
fs::directory_iterator itx(root_name_path);
|
||||
BOOST_TEST(itx != fs::directory_iterator());
|
||||
// BOOST_TEST(fs::exists((*itx).path()));
|
||||
BOOST_TEST(fs::exists(itx->path()));
|
||||
BOOST_TEST(itx->path().parent_path() == root_name_path);
|
||||
bool found(false);
|
||||
do
|
||||
{
|
||||
if (it->path().filename() == temp_dir.filename())
|
||||
if (itx->path().filename() == temp_dir.filename())
|
||||
found = true;
|
||||
} while (++it != fs::directory_iterator());
|
||||
} while (++itx != fs::directory_iterator());
|
||||
BOOST_TEST(found);
|
||||
}
|
||||
|
||||
@ -600,7 +600,7 @@ namespace
|
||||
|
||||
int walk_tree(bool recursive)
|
||||
{
|
||||
cout << " walk_tree" << endl;
|
||||
// cout << " walk_tree" << endl;
|
||||
error_code ec;
|
||||
int d1f1_count = 0;
|
||||
for (fs::recursive_directory_iterator it (dir,
|
||||
@ -608,7 +608,7 @@ namespace
|
||||
it != fs::recursive_directory_iterator();
|
||||
it.increment(ec))
|
||||
{
|
||||
cout << " " << it->path() << endl;
|
||||
// cout << " " << it->path() << endl;
|
||||
if (it->path().filename() == "d1f1")
|
||||
++d1f1_count;
|
||||
}
|
||||
@ -724,12 +724,12 @@ namespace
|
||||
cout << "create_hard_link_tests..." << endl;
|
||||
|
||||
fs::path from_ph(dir / "f3");
|
||||
fs::path f1(dir / "f1");
|
||||
fs::path f1x(dir / "f1");
|
||||
|
||||
BOOST_TEST(!fs::exists(from_ph));
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
bool create_hard_link_ok(true);
|
||||
try { fs::create_hard_link(f1, from_ph); }
|
||||
try { fs::create_hard_link(f1x, from_ph); }
|
||||
catch (const fs::filesystem_error & ex)
|
||||
{
|
||||
create_hard_link_ok = false;
|
||||
@ -746,10 +746,10 @@ namespace
|
||||
<< " *** For information only ***\n"
|
||||
" create_hard_link() succeeded\n";
|
||||
BOOST_TEST(fs::exists(from_ph));
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::equivalent(from_ph, f1));
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(fs::equivalent(from_ph, f1x));
|
||||
BOOST_TEST(fs::hard_link_count(from_ph) == 2);
|
||||
BOOST_TEST(fs::hard_link_count(f1) == 2);
|
||||
BOOST_TEST(fs::hard_link_count(f1x) == 2);
|
||||
}
|
||||
|
||||
// Although tests may be running on a FAT or other file system that does
|
||||
@ -770,10 +770,10 @@ namespace
|
||||
cout << "create_symlink_tests..." << endl;
|
||||
|
||||
fs::path from_ph(dir / "f4");
|
||||
fs::path f1(dir / "f1");
|
||||
fs::path f1x(dir / "f1");
|
||||
BOOST_TEST(!fs::exists(from_ph));
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
try { fs::create_symlink(f1, from_ph); }
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
try { fs::create_symlink(f1x, from_ph); }
|
||||
catch (const fs::filesystem_error & ex)
|
||||
{
|
||||
create_symlink_ok = false;
|
||||
@ -791,9 +791,9 @@ namespace
|
||||
" create_symlink() succeeded\n";
|
||||
BOOST_TEST(fs::exists(from_ph));
|
||||
BOOST_TEST(fs::is_symlink(from_ph));
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::equivalent(from_ph, f1));
|
||||
BOOST_TEST(fs::read_symlink(from_ph) == f1);
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(fs::equivalent(from_ph, f1x));
|
||||
BOOST_TEST(fs::read_symlink(from_ph) == f1x);
|
||||
|
||||
fs::file_status stat = fs::symlink_status(from_ph);
|
||||
BOOST_TEST(fs::exists(stat));
|
||||
@ -886,8 +886,8 @@ namespace
|
||||
{
|
||||
cout << "rename_tests..." << endl;
|
||||
|
||||
fs::path f1(dir / "f1");
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
fs::path f1x(dir / "f1");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
|
||||
// error: rename a non-existent old file
|
||||
BOOST_TEST(!fs::exists(d1 / "f99"));
|
||||
@ -898,7 +898,7 @@ namespace
|
||||
BOOST_TEST(CHECK_EXCEPTION(n1b, ENOENT));
|
||||
|
||||
// error: rename an existing file to ""
|
||||
renamer n2(f1, "");
|
||||
renamer n2(f1x, "");
|
||||
BOOST_TEST(CHECK_EXCEPTION(n2, ENOENT));
|
||||
|
||||
// rename an existing file to an existent file
|
||||
@ -1223,32 +1223,32 @@ namespace
|
||||
|
||||
// remove_tests --------------------------------------------------------------------//
|
||||
|
||||
void remove_tests(const fs::path& dir)
|
||||
void remove_tests(const fs::path& dirx)
|
||||
{
|
||||
cout << "remove_tests..." << endl;
|
||||
|
||||
// remove() file
|
||||
fs::path f1 = dir / "shortlife";
|
||||
BOOST_TEST(!fs::exists(f1));
|
||||
create_file(f1, "");
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(!fs::is_directory(f1));
|
||||
BOOST_TEST(fs::remove(f1));
|
||||
BOOST_TEST(!fs::exists(f1));
|
||||
fs::path f1x = dirx / "shortlife";
|
||||
BOOST_TEST(!fs::exists(f1x));
|
||||
create_file(f1x, "");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(!fs::is_directory(f1x));
|
||||
BOOST_TEST(fs::remove(f1x));
|
||||
BOOST_TEST(!fs::exists(f1x));
|
||||
BOOST_TEST(!fs::remove("no-such-file"));
|
||||
BOOST_TEST(!fs::remove("no-such-directory/no-such-file"));
|
||||
|
||||
// remove() directory
|
||||
fs::path d1 = dir / "shortlife_dir";
|
||||
BOOST_TEST(!fs::exists(d1));
|
||||
fs::create_directory(d1);
|
||||
BOOST_TEST(fs::exists(d1));
|
||||
BOOST_TEST(fs::is_directory(d1));
|
||||
BOOST_TEST(fs::is_empty(d1));
|
||||
bad_remove_dir = dir;
|
||||
fs::path d1x = dirx / "shortlife_dir";
|
||||
BOOST_TEST(!fs::exists(d1x));
|
||||
fs::create_directory(d1x);
|
||||
BOOST_TEST(fs::exists(d1x));
|
||||
BOOST_TEST(fs::is_directory(d1x));
|
||||
BOOST_TEST(fs::is_empty(d1x));
|
||||
bad_remove_dir = dirx;
|
||||
BOOST_TEST(CHECK_EXCEPTION(bad_remove, ENOTEMPTY));
|
||||
BOOST_TEST(fs::remove(d1));
|
||||
BOOST_TEST(!fs::exists(d1));
|
||||
BOOST_TEST(fs::remove(d1x));
|
||||
BOOST_TEST(!fs::exists(d1x));
|
||||
}
|
||||
|
||||
// remove_symlink_tests ------------------------------------------------------------//
|
||||
@ -1294,25 +1294,25 @@ namespace
|
||||
BOOST_TEST(!fs::is_symlink(link));
|
||||
|
||||
// remove() symbolic link to file
|
||||
fs::path f1 = "link_target";
|
||||
fs::remove(f1); // remove any residue from past tests
|
||||
BOOST_TEST(!fs::exists(f1));
|
||||
create_file(f1, "");
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(!fs::is_directory(f1));
|
||||
BOOST_TEST(fs::is_regular_file(f1));
|
||||
fs::path f1x = "link_target";
|
||||
fs::remove(f1x); // remove any residue from past tests
|
||||
BOOST_TEST(!fs::exists(f1x));
|
||||
create_file(f1x, "");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(!fs::is_directory(f1x));
|
||||
BOOST_TEST(fs::is_regular_file(f1x));
|
||||
link = "non_dangling_link";
|
||||
fs::create_symlink(f1, link);
|
||||
fs::create_symlink(f1x, link);
|
||||
BOOST_TEST(fs::exists(link));
|
||||
BOOST_TEST(!fs::is_directory(link));
|
||||
BOOST_TEST(fs::is_regular_file(link));
|
||||
BOOST_TEST(fs::is_symlink(link));
|
||||
BOOST_TEST(fs::remove(link));
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(!fs::exists(link));
|
||||
BOOST_TEST(!fs::is_symlink(link));
|
||||
BOOST_TEST(fs::remove(f1));
|
||||
BOOST_TEST(!fs::exists(f1));
|
||||
BOOST_TEST(fs::remove(f1x));
|
||||
BOOST_TEST(!fs::exists(f1x));
|
||||
}
|
||||
|
||||
// absolute_tests -----------------------------------------------------------------//
|
||||
@ -1469,40 +1469,40 @@ namespace
|
||||
|
||||
// copy_file_tests ------------------------------------------------------------------//
|
||||
|
||||
void copy_file_tests(const fs::path& f1, const fs::path& d1)
|
||||
void copy_file_tests(const fs::path& f1x, const fs::path& d1x)
|
||||
{
|
||||
cout << "copy_file_tests..." << endl;
|
||||
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
fs::remove(d1 / "f2"); // remove possible residue from prior testing
|
||||
BOOST_TEST(fs::exists(d1));
|
||||
BOOST_TEST(!fs::exists(d1 / "f2"));
|
||||
cout << " copy " << f1 << " to " << d1 / "f2" << endl;
|
||||
fs::copy_file(f1, d1 / "f2");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
fs::remove(d1x / "f2"); // remove possible residue from prior testing
|
||||
BOOST_TEST(fs::exists(d1x));
|
||||
BOOST_TEST(!fs::exists(d1x / "f2"));
|
||||
cout << " copy " << f1x << " to " << d1x / "f2" << endl;
|
||||
fs::copy_file(f1x, d1x / "f2");
|
||||
cout << " copy complete" << endl;
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::exists(d1 / "f2"));
|
||||
BOOST_TEST(!fs::is_directory(d1 / "f2"));
|
||||
verify_file(d1 / "f2", "file-f1");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(fs::exists(d1x / "f2"));
|
||||
BOOST_TEST(!fs::is_directory(d1x / "f2"));
|
||||
verify_file(d1x / "f2", "file-f1");
|
||||
|
||||
bool copy_ex_ok = false;
|
||||
try { fs::copy_file(f1, d1 / "f2"); }
|
||||
try { fs::copy_file(f1x, d1x / "f2"); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
|
||||
copy_ex_ok = false;
|
||||
try { fs::copy_file(f1, d1 / "f2", fs::copy_option::fail_if_exists); }
|
||||
try { fs::copy_file(f1x, d1x / "f2", fs::copy_option::fail_if_exists); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = true; }
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
|
||||
create_file(d1 / "f2", "1234567890");
|
||||
BOOST_TEST_EQ(fs::file_size(d1 / "f2"), 10U);
|
||||
create_file(d1x / "f2", "1234567890");
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U);
|
||||
copy_ex_ok = true;
|
||||
try { fs::copy_file(f1, d1 / "f2", fs::copy_option::overwrite_if_exists); }
|
||||
try { fs::copy_file(f1x, d1x / "f2", fs::copy_option::overwrite_if_exists); }
|
||||
catch (const fs::filesystem_error &) { copy_ex_ok = false; }
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
BOOST_TEST_EQ(fs::file_size(d1 / "f2"), 7U);
|
||||
verify_file(d1 / "f2", "file-f1");
|
||||
BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 7U);
|
||||
verify_file(d1x / "f2", "file-f1");
|
||||
}
|
||||
|
||||
// symlink_status_tests -------------------------------------------------------------//
|
||||
@ -1569,22 +1569,22 @@ namespace
|
||||
|
||||
// copy_symlink_tests ---------------------------------------------------------------//
|
||||
|
||||
void copy_symlink_tests(const fs::path& f1, const fs::path& d1)
|
||||
void copy_symlink_tests(const fs::path& f1x, const fs::path& d1x)
|
||||
{
|
||||
cout << "copy_symlink_tests..." << endl;
|
||||
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(fs::exists(d1));
|
||||
fs::path sym1(d1 / "symlink1");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(fs::exists(d1x));
|
||||
fs::path sym1(d1x / "symlink1");
|
||||
fs::remove(sym1); // remove possible residue from prior testing
|
||||
fs::create_symlink(f1, sym1);
|
||||
fs::create_symlink(f1x, sym1);
|
||||
BOOST_TEST(fs::exists(sym1));
|
||||
BOOST_TEST(fs::is_symlink(sym1));
|
||||
fs::path sym2(d1 / "symlink2");
|
||||
fs::path sym2(d1x / "symlink2");
|
||||
fs::copy_symlink(sym1, sym2);
|
||||
BOOST_TEST(fs::exists(sym2));
|
||||
BOOST_TEST(fs::is_symlink(sym2));
|
||||
//fs::path sym3(d1 / "symlink3");
|
||||
//fs::path sym3(d1x / "symlink3");
|
||||
//fs::copy(sym1, sym3);
|
||||
//BOOST_TEST(fs::exists(sym3));
|
||||
//BOOST_TEST(fs::is_symlink(sym3));
|
||||
@ -1595,30 +1595,30 @@ namespace
|
||||
BOOST_TEST(copy_ex_ok);
|
||||
|
||||
copy_ex_ok = false;
|
||||
try { fs::copy_symlink(f1, "new-symlink2"); } // should fail; f1 not symlink
|
||||
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);
|
||||
}
|
||||
|
||||
// write_time_tests ----------------------------------------------------------------//
|
||||
|
||||
void write_time_tests(const fs::path& dir)
|
||||
void write_time_tests(const fs::path& dirx)
|
||||
{
|
||||
cout << "write_time_tests..." << endl;
|
||||
|
||||
fs::path f1 = dir / "foobar2";
|
||||
create_file(f1, "foobar2");
|
||||
BOOST_TEST(fs::exists(f1));
|
||||
BOOST_TEST(!fs::is_directory(f1));
|
||||
BOOST_TEST(fs::is_regular_file(f1));
|
||||
BOOST_TEST(fs::file_size(f1) == 7);
|
||||
verify_file(f1, "foobar2");
|
||||
fs::path f1x = dirx / "foobar2";
|
||||
create_file(f1x, "foobar2");
|
||||
BOOST_TEST(fs::exists(f1x));
|
||||
BOOST_TEST(!fs::is_directory(f1x));
|
||||
BOOST_TEST(fs::is_regular_file(f1x));
|
||||
BOOST_TEST(fs::file_size(f1x) == 7);
|
||||
verify_file(f1x, "foobar2");
|
||||
|
||||
// Some file system report last write time as local (FAT), while
|
||||
// others (NTFS) report it as UTC. The C standard does not specify
|
||||
// if time_t is local or UTC.
|
||||
|
||||
std::time_t ft = fs::last_write_time(f1);
|
||||
std::time_t ft = fs::last_write_time(f1x);
|
||||
cout << "\n UTC last_write_time() for a file just created is "
|
||||
<< std::asctime(std::gmtime(&ft)) << endl;
|
||||
|
||||
@ -1626,15 +1626,15 @@ namespace
|
||||
cout << "\n Year is " << tmp->tm_year << endl;
|
||||
--tmp->tm_year;
|
||||
cout << " Change year to " << tmp->tm_year << endl;
|
||||
fs::last_write_time(f1, std::mktime(tmp));
|
||||
std::time_t ft2 = fs::last_write_time(f1);
|
||||
fs::last_write_time(f1x, std::mktime(tmp));
|
||||
std::time_t ft2 = fs::last_write_time(f1x);
|
||||
cout << " last_write_time() for the file is now "
|
||||
<< std::asctime(std::gmtime(&ft2)) << endl;
|
||||
BOOST_TEST(ft != fs::last_write_time(f1));
|
||||
BOOST_TEST(ft != fs::last_write_time(f1x));
|
||||
|
||||
cout << "\n Reset to current time" << endl;
|
||||
fs::last_write_time(f1, ft);
|
||||
double time_diff = std::difftime(ft, fs::last_write_time(f1));
|
||||
fs::last_write_time(f1x, ft);
|
||||
double time_diff = std::difftime(ft, fs::last_write_time(f1x));
|
||||
cout
|
||||
<< " original last_write_time() - current last_write_time() is "
|
||||
<< time_diff << " seconds" << endl;
|
||||
@ -1806,20 +1806,20 @@ namespace
|
||||
|
||||
// equivalent_tests ----------------------------------------------------------------//
|
||||
|
||||
void equivalent_tests(const fs::path& f1)
|
||||
void equivalent_tests(const fs::path& f1x)
|
||||
{
|
||||
cout << "equivalent_tests..." << endl;
|
||||
|
||||
BOOST_TEST(CHECK_EXCEPTION(bad_equivalent, ENOENT));
|
||||
BOOST_TEST(fs::equivalent(f1, dir / "f1"));
|
||||
BOOST_TEST(fs::equivalent(f1x, dir / "f1"));
|
||||
BOOST_TEST(fs::equivalent(dir, d1 / ".."));
|
||||
BOOST_TEST(!fs::equivalent(f1, dir));
|
||||
BOOST_TEST(!fs::equivalent(dir, f1));
|
||||
BOOST_TEST(!fs::equivalent(f1x, dir));
|
||||
BOOST_TEST(!fs::equivalent(dir, f1x));
|
||||
BOOST_TEST(!fs::equivalent(d1, d2));
|
||||
BOOST_TEST(!fs::equivalent(dir, ng));
|
||||
BOOST_TEST(!fs::equivalent(ng, dir));
|
||||
BOOST_TEST(!fs::equivalent(f1, ng));
|
||||
BOOST_TEST(!fs::equivalent(ng, f1));
|
||||
BOOST_TEST(!fs::equivalent(f1x, ng));
|
||||
BOOST_TEST(!fs::equivalent(ng, f1x));
|
||||
}
|
||||
|
||||
// temp_directory_path_tests -------------------------------------------------------//
|
||||
|
@ -31,7 +31,6 @@
|
||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
# endif
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
@ -160,10 +159,10 @@ namespace
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_FOREACH(directory_entry& x, directory_iterator("."))
|
||||
for (directory_iterator itr("."); itr != directory_iterator(); ++itr)
|
||||
{
|
||||
CHECK(!x.path().empty());
|
||||
//cout << " " << x.path() << "\n";
|
||||
CHECK(!itr->path().empty());
|
||||
//cout << " " << itr->path() << "\n";
|
||||
}
|
||||
|
||||
cout << "directory_iterator_test complete" << endl;
|
||||
@ -221,10 +220,11 @@ namespace
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_FOREACH(directory_entry& x, recursive_directory_iterator(".."))
|
||||
for (recursive_directory_iterator itr("..");
|
||||
itr != recursive_directory_iterator(); ++itr)
|
||||
{
|
||||
CHECK(!x.path().empty());
|
||||
//cout << " " << x.path() << "\n";
|
||||
CHECK(!itr->path().empty());
|
||||
//cout << " " << itr->path() << "\n";
|
||||
}
|
||||
|
||||
cout << "recursive_directory_iterator_test complete" << endl;
|
||||
|
@ -642,27 +642,27 @@ namespace
|
||||
|
||||
// operator == and != are implemented separately, so test separately
|
||||
|
||||
path p1("fe/fi/fo/fum");
|
||||
path p2(p1);
|
||||
path p3("fe/fi/fo/fumm");
|
||||
BOOST_TEST(p1.string() != p3.string());
|
||||
path p101("fe/fi/fo/fum");
|
||||
path p102(p101);
|
||||
path p103("fe/fi/fo/fumm");
|
||||
BOOST_TEST(p101.string() != p103.string());
|
||||
|
||||
// check each overload
|
||||
BOOST_TEST(p1 != p3);
|
||||
BOOST_TEST(p1 != p3.string());
|
||||
BOOST_TEST(p1 != p3.string().c_str());
|
||||
BOOST_TEST(p1.string() != p3);
|
||||
BOOST_TEST(p1.string().c_str() != p3);
|
||||
BOOST_TEST(p101 != p103);
|
||||
BOOST_TEST(p101 != p103.string());
|
||||
BOOST_TEST(p101 != p103.string().c_str());
|
||||
BOOST_TEST(p101.string() != p103);
|
||||
BOOST_TEST(p101.string().c_str() != p103);
|
||||
|
||||
p3 = p2;
|
||||
BOOST_TEST(p1.string() == p3.string());
|
||||
p103 = p102;
|
||||
BOOST_TEST(p101.string() == p103.string());
|
||||
|
||||
// check each overload
|
||||
BOOST_TEST(p1 == p3);
|
||||
BOOST_TEST(p1 == p3.string());
|
||||
BOOST_TEST(p1 == p3.string().c_str());
|
||||
BOOST_TEST(p1.string() == p3);
|
||||
BOOST_TEST(p1.string().c_str() == p3);
|
||||
BOOST_TEST(p101 == p103);
|
||||
BOOST_TEST(p101 == p103.string());
|
||||
BOOST_TEST(p101 == p103.string().c_str());
|
||||
BOOST_TEST(p101.string() == p103);
|
||||
BOOST_TEST(p101.string().c_str() == p103);
|
||||
|
||||
if (platform == "Windows")
|
||||
{
|
||||
@ -1803,10 +1803,10 @@ int cpp_main(int, char*[])
|
||||
p3 = p2;
|
||||
BOOST_TEST(p1.string() == p3.string());
|
||||
|
||||
path p4("foobar");
|
||||
BOOST_TEST(p4.string() == "foobar");
|
||||
p4 = p4; // self-assignment
|
||||
BOOST_TEST(p4.string() == "foobar");
|
||||
path p04("foobar");
|
||||
BOOST_TEST(p04.string() == "foobar");
|
||||
p04 = p04; // self-assignment
|
||||
BOOST_TEST(p04.string() == "foobar");
|
||||
|
||||
construction_tests();
|
||||
append_tests();
|
||||
|
@ -125,9 +125,9 @@ namespace
|
||||
<< L"\"\n" ;
|
||||
}
|
||||
|
||||
void check(bool ok, const char* file, int line)
|
||||
void check(bool ok_, const char* file, int line)
|
||||
{
|
||||
if (ok) return;
|
||||
if (ok_) return;
|
||||
|
||||
++::boost::detail::test_errors();
|
||||
|
||||
@ -826,17 +826,17 @@ namespace
|
||||
void test_overloads()
|
||||
{
|
||||
std::cout << "testing overloads..." << std::endl;
|
||||
std::string s("hello");
|
||||
std::string sto("hello");
|
||||
const char a[] = "goodbye";
|
||||
path p1(s);
|
||||
path p2(s.c_str());
|
||||
path p1(sto);
|
||||
path p2(sto.c_str());
|
||||
path p3(a);
|
||||
path p4("foo");
|
||||
|
||||
std::wstring ws(L"hello");
|
||||
std::wstring wsto(L"hello");
|
||||
const wchar_t wa[] = L"goodbye";
|
||||
path wp1(ws);
|
||||
path wp2(ws.c_str());
|
||||
path wp1(wsto);
|
||||
path wp2(wsto.c_str());
|
||||
path wp3(wa);
|
||||
path wp4(L"foo");
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
|
||||
{
|
||||
for (; from != from_end && to != to_end; ++from, ++to)
|
||||
*to = *from + 1;
|
||||
*to = wchar_t(*from + 1);
|
||||
if (to == to_end)
|
||||
return error;
|
||||
*to = L'\0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user