attempt to fix removal of files on windows with unicode (to fix #216)
This commit is contained in:
parent
1c77083186
commit
8909aeaadc
|
@ -527,12 +527,23 @@ namespace libtorrent
|
||||||
std::pair<iter_t, bool> ret = directories.insert((m_save_path / bp).string());
|
std::pair<iter_t, bool> ret = directories.insert((m_save_path / bp).string());
|
||||||
bp = bp.branch_path();
|
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)
|
if (std::remove(p.c_str()) != 0 && errno != ENOENT)
|
||||||
{
|
{
|
||||||
error = std::strerror(errno);
|
error = std::strerror(errno);
|
||||||
error_file = p;
|
error_file = p;
|
||||||
result = errno;
|
result = errno;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the directories. Reverse order to delete
|
// remove the directories. Reverse order to delete
|
||||||
|
@ -541,12 +552,23 @@ namespace libtorrent
|
||||||
for (std::set<std::string>::reverse_iterator i = directories.rbegin()
|
for (std::set<std::string>::reverse_iterator i = directories.rbegin()
|
||||||
, end(directories.rend()); i != end; ++i)
|
, 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)
|
if (std::remove(i->c_str()) != 0 && errno != ENOENT)
|
||||||
{
|
{
|
||||||
error = std::strerror(errno);
|
error = std::strerror(errno);
|
||||||
error_file = *i;
|
error_file = *i;
|
||||||
result = errno;
|
result = errno;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error.empty())
|
if (!error.empty())
|
||||||
|
|
Loading…
Reference in New Issue