From 4614764552ee2204f2877f88edf983a94b040a3a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 18 Dec 2010 18:51:24 +0000 Subject: [PATCH] Fix possible encoding problem on non-utf8 systems --- src/qtlibtorrent/qbtsession.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 953b808fe..67514bb9a 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1286,7 +1286,7 @@ void QBtSession::loadSessionState() { } #if LIBTORRENT_VERSION_MINOR > 14 std::vector in; - if (load_file(state_path.toLocal8Bit().constData(), in) == 0) + if (load_file(state_path.toUtf8().constData(), in) == 0) { lazy_entry e; #if LIBTORRENT_VERSION_MINOR > 15 @@ -1300,7 +1300,7 @@ void QBtSession::loadSessionState() { #endif } #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); ses_state_file.unsetf(std::ios_base::skipws); s->load_state(bdecode( @@ -1319,13 +1319,13 @@ void QBtSession::saveSessionState() { bencode(std::back_inserter(out), session_state); file f; 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; file::iovec_t b = {&out[0], out.size()}; f.writev(0, &b, 1, ec); #else 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); out.unsetf(std::ios_base::skipws); bencode(std::ostream_iterator(out), session_state); @@ -1340,7 +1340,7 @@ bool QBtSession::enableDHT(bool b) { entry dht_state; const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state"); 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); try{ dht_state = bdecode(std::istream_iterator(dht_state_file), std::istream_iterator());