Browse Source

Fix save path encoding problem on Windows

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
d557410156
  1. 8
      src/bittorrent.cpp
  2. 2
      src/qtorrenthandle.cpp

8
src/bittorrent.cpp

@ -867,13 +867,13 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
qDebug("addMagnetURI: Temp folder is enabled."); qDebug("addMagnetURI: Temp folder is enabled.");
qDebug("addTorrent::Temp folder is enabled."); qDebug("addTorrent::Temp folder is enabled.");
QString torrent_tmp_path = defaultTempPath.replace("\\", "/"); QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
p.save_path = torrent_tmp_path.toLocal8Bit().constData(); p.save_path = torrent_tmp_path.toUtf8().constData();
// Check if save path exists, creating it otherwise // Check if save path exists, creating it otherwise
if(!QDir(torrent_tmp_path).exists()) if(!QDir(torrent_tmp_path).exists())
QDir().mkpath(torrent_tmp_path); QDir().mkpath(torrent_tmp_path);
qDebug("addMagnetURI: using save_path: %s", qPrintable(torrent_tmp_path)); qDebug("addMagnetURI: using save_path: %s", qPrintable(torrent_tmp_path));
} else { } else {
p.save_path = savePath.toLocal8Bit().constData(); p.save_path = savePath.toUtf8().constData();
// Check if save path exists, creating it otherwise // Check if save path exists, creating it otherwise
if(!QDir(savePath).exists()) if(!QDir(savePath).exists())
QDir().mkpath(savePath); QDir().mkpath(savePath);
@ -1121,13 +1121,13 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/"; if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
torrent_tmp_path += root_folder; torrent_tmp_path += root_folder;
} }
p.save_path = torrent_tmp_path.toLocal8Bit().constData(); p.save_path = torrent_tmp_path.toUtf8().constData();
// Check if save path exists, creating it otherwise // Check if save path exists, creating it otherwise
if(!QDir(torrent_tmp_path).exists()) if(!QDir(torrent_tmp_path).exists())
QDir().mkpath(torrent_tmp_path); QDir().mkpath(torrent_tmp_path);
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path)); qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
} else { } else {
p.save_path = savePath.toLocal8Bit().constData(); p.save_path = savePath.toUtf8().constData();
// Check if save path exists, creating it otherwise // Check if save path exists, creating it otherwise
if(!QDir(savePath).exists()) if(!QDir(savePath).exists())
QDir().mkpath(savePath); QDir().mkpath(savePath);

2
src/qtorrenthandle.cpp

@ -227,7 +227,7 @@ int QTorrentHandle::num_incomplete() const {
QString QTorrentHandle::save_path() const { QString QTorrentHandle::save_path() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return misc::toQString(h.save_path().string()).replace("\\", "/"); return misc::toQStringU(h.save_path().string()).replace("\\", "/");
} }
#if LIBTORRENT_VERSION_MINOR > 14 #if LIBTORRENT_VERSION_MINOR > 14

Loading…
Cancel
Save