wpath fix

This commit is contained in:
Marcos Pinto 2008-06-19 01:24:19 +00:00
commit 062e4d2a8a

View file

@ -1,4 +1,4 @@
/* a/*
Copyright (c) 2003, Arvid Norberg, Daniel Wallin Copyright (c) 2003, Arvid Norberg, Daniel Wallin
All rights reserved. All rights reserved.
@ -252,52 +252,52 @@ namespace
namespace libtorrent namespace libtorrent
{ {
template <class Path> template <class Path>
void recursive_copy(Path const& old_path, Path const& new_path, std::string& error) void recursive_copy(Path const& old_path, Path const& new_path, std::string& error)
{ {
using boost::filesystem::directory_iterator; using boost::filesystem::basic_directory_iterator;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
try { try {
#endif #endif
TORRENT_ASSERT(error.empty()); TORRENT_ASSERT(error.empty());
if (is_directory(old_path)) if (is_directory(old_path))
{ {
create_directory(new_path); create_directory(new_path);
for (directory_iterator i(old_path), end; i != end; ++i) for (basic_directory_iterator<Path> i(old_path), end; i != end; ++i)
{ {
recursive_copy(i->path(), new_path / i->leaf(), error); recursive_copy(i->path(), new_path / i->leaf(), error);
if (!error.empty()) return; if (!error.empty()) return;
} }
} }
else else
{ {
copy_file(old_path, new_path); copy_file(old_path, new_path);
} }
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
} catch (std::exception& e) { error = e.what(); } } catch (std::exception& e) { error = e.what(); }
#endif #endif
} }
template <class Path> template <class Path>
void recursive_remove(Path const& old_path) void recursive_remove(Path const& old_path)
{ {
using boost::filesystem::directory_iterator; using boost::filesystem::basic_directory_iterator;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
try { try {
#endif #endif
if (is_directory(old_path)) if (is_directory(old_path))
{ {
for (directory_iterator i(old_path), end; i != end; ++i) for (basic_directory_iterator<Path> i(old_path), end; i != end; ++i)
recursive_remove(i->path()); recursive_remove(i->path());
remove(old_path); remove(old_path);
} }
else else
{ {
remove(old_path); remove(old_path);
} }
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
} catch (std::exception& e) {} } catch (std::exception& e) {}
#endif #endif
} }
std::vector<std::pair<size_type, std::time_t> > get_filesizes( std::vector<std::pair<size_type, std::time_t> > get_filesizes(
torrent_info const& t, fs::path p) torrent_info const& t, fs::path p)
@ -716,13 +716,13 @@ namespace libtorrent
} }
catch (std::exception& e) catch (std::exception& e)
{ {
std::string err; std::string err;
recursive_copy(old_path, new_path, err); recursive_copy(old_path, new_path, err);
if (!err.empty()) if (!err.empty())
{ {
return true; return true;
} }
m_save_path = save_path; m_save_path = save_path;
recursive_remove(old_path); recursive_remove(old_path);
} }
} }