Browse Source

Fix torrent creator when saving to a non-latin path in Windows.

adaptive-webui-19844
sledgehammer999 12 years ago
parent
commit
e7125d21cb
  1. 2
      src/torrentcreator/torrentcreatordlg.cpp
  2. 7
      src/torrentcreator/torrentcreatorthread.cpp

2
src/torrentcreator/torrentcreatordlg.cpp

@ -141,7 +141,7 @@ void TorrentCreatorDlg::on_createButton_clicked() {
connect(creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString))); connect(creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString))); connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int))); connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize()); creatorThread->create(input, QDir::toNativeSeparators(destination), trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
} }
void TorrentCreatorDlg::handleCreationFailure(QString msg) { void TorrentCreatorDlg::handleCreationFailure(QString msg) {

7
src/torrentcreator/torrentcreatorthread.cpp

@ -129,7 +129,14 @@ void TorrentCreatorThread::run() {
if (abort) return; if (abort) return;
// create the torrent and print it to out // create the torrent and print it to out
qDebug("Saving to %s", qPrintable(save_path)); qDebug("Saving to %s", qPrintable(save_path));
#ifdef _MSC_VER
wchar_t *wsave_path = new wchar_t[save_path.length()];
save_path.toWCharArray(wsave_path);
std::ofstream outfile(wsave_path, std::ios_base::out|std::ios_base::binary);
delete[] wsave_path;
#else
std::ofstream outfile(save_path.toLocal8Bit().constData(), std::ios_base::out|std::ios_base::binary); std::ofstream outfile(save_path.toLocal8Bit().constData(), std::ios_base::out|std::ios_base::binary);
#endif
if (outfile.fail()) if (outfile.fail())
throw std::exception(); throw std::exception();
bencode(std::ostream_iterator<char>(outfile), t.generate()); bencode(std::ostream_iterator<char>(outfile), t.generate());

Loading…
Cancel
Save