mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Fix possible encoding problem on non-utf8 systems
This commit is contained in:
parent
c3322cdc91
commit
4614764552
@ -1286,7 +1286,7 @@ void QBtSession::loadSessionState() {
|
|||||||
}
|
}
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
std::vector<char> in;
|
std::vector<char> in;
|
||||||
if (load_file(state_path.toLocal8Bit().constData(), in) == 0)
|
if (load_file(state_path.toUtf8().constData(), in) == 0)
|
||||||
{
|
{
|
||||||
lazy_entry e;
|
lazy_entry e;
|
||||||
#if LIBTORRENT_VERSION_MINOR > 15
|
#if LIBTORRENT_VERSION_MINOR > 15
|
||||||
@ -1300,7 +1300,7 @@ void QBtSession::loadSessionState() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
boost::filesystem::ifstream ses_state_file(state_path.toLocal8Bit().constData()
|
boost::filesystem::ifstream ses_state_file(state_path.toUtf8().constData()
|
||||||
, std::ios_base::binary);
|
, std::ios_base::binary);
|
||||||
ses_state_file.unsetf(std::ios_base::skipws);
|
ses_state_file.unsetf(std::ios_base::skipws);
|
||||||
s->load_state(bdecode(
|
s->load_state(bdecode(
|
||||||
@ -1319,13 +1319,13 @@ void QBtSession::saveSessionState() {
|
|||||||
bencode(std::back_inserter(out), session_state);
|
bencode(std::back_inserter(out), session_state);
|
||||||
file f;
|
file f;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if (!f.open(state_path.toLocal8Bit().constData(), file::write_only, ec)) return;
|
if (!f.open(state_path.toUtf8().constData(), file::write_only, ec)) return;
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
file::iovec_t b = {&out[0], out.size()};
|
file::iovec_t b = {&out[0], out.size()};
|
||||||
f.writev(0, &b, 1, ec);
|
f.writev(0, &b, 1, ec);
|
||||||
#else
|
#else
|
||||||
entry session_state = s->state();
|
entry session_state = s->state();
|
||||||
boost::filesystem::ofstream out(state_path.toLocal8Bit().constData()
|
boost::filesystem::ofstream out(state_path.toUtf8().constData()
|
||||||
, std::ios_base::binary);
|
, std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), session_state);
|
bencode(std::ostream_iterator<char>(out), session_state);
|
||||||
@ -1340,7 +1340,7 @@ bool QBtSession::enableDHT(bool b) {
|
|||||||
entry dht_state;
|
entry dht_state;
|
||||||
const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state");
|
const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state");
|
||||||
if(QFile::exists(dht_state_path)) {
|
if(QFile::exists(dht_state_path)) {
|
||||||
boost::filesystem::ifstream dht_state_file(dht_state_path.toLocal8Bit().constData(), std::ios_base::binary);
|
boost::filesystem::ifstream dht_state_file(dht_state_path.toUtf8().constData(), std::ios_base::binary);
|
||||||
dht_state_file.unsetf(std::ios_base::skipws);
|
dht_state_file.unsetf(std::ios_base::skipws);
|
||||||
try{
|
try{
|
||||||
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
|
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user