attempt to fix removal of files on windows with unicode (to fix #216)

This commit is contained in:
Arvid Norberg 2008-05-15 16:38:04 +00:00
parent 1c77083186
commit 8909aeaadc
1 changed files with 22 additions and 0 deletions

View File

@ -527,12 +527,23 @@ namespace libtorrent
std::pair<iter_t, bool> ret = directories.insert((m_save_path / bp).string());
bp = bp.branch_path();
}
#elif defined(_WIN32) && defined(UNICODE)
try
{ fs::remove(safe_convert(p)); }
catch (std::exception& e)
{
error = e.what();
error_file = p;
result = 1;
}
#else
if (std::remove(p.c_str()) != 0 && errno != ENOENT)
{
error = std::strerror(errno);
error_file = p;
result = errno;
}
#else
}
// remove the directories. Reverse order to delete
@ -541,12 +552,23 @@ namespace libtorrent
for (std::set<std::string>::reverse_iterator i = directories.rbegin()
, end(directories.rend()); i != end; ++i)
{
#elif defined(_WIN32) && defined(UNICODE)
try
{ fs::remove(safe_convert(*i)); }
catch (std::exception& e)
{
error = e.what();
error_file = *i;
result = 1;
}
#else
if (std::remove(i->c_str()) != 0 && errno != ENOENT)
{
error = std::strerror(errno);
error_file = *i;
result = errno;
}
#else
}
if (!error.empty())