mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
Initial port to libtorrent v0.16
This commit is contained in:
parent
4412476109
commit
3995af6489
15 changed files with 382 additions and 154 deletions
28
src/misc.cpp
28
src/misc.cpp
|
@ -356,23 +356,29 @@ QString misc::fixFileNames(QString path) {
|
|||
QString misc::truncateRootFolder(boost::intrusive_ptr<torrent_info> t) {
|
||||
if(t->num_files() == 1) {
|
||||
// Single file torrent
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
QString path = QString::fromUtf8(t->file_at(0).path.c_str());
|
||||
#else
|
||||
QString path = QString::fromUtf8(t->file_at(0).path.string().c_str());
|
||||
#endif
|
||||
// Remove possible subfolders
|
||||
path = fixFileNames(fileName(path));
|
||||
t->rename_file(0, path.toUtf8().data());
|
||||
return QString();
|
||||
}
|
||||
QString root_folder;
|
||||
int i = 0;
|
||||
for(torrent_info::file_iterator it = t->begin_files(); it < t->end_files(); it++) {
|
||||
QString path = QString::fromUtf8(it->path.string().c_str());
|
||||
for(int i=0; i<t->num_files(); ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
QString path = QString::fromUtf8(t->file_at(i).path.c_str());
|
||||
#else
|
||||
QString path = QString::fromUtf8(t->file_at(i).path.string().c_str());
|
||||
#endif
|
||||
QStringList path_parts = path.split("/", QString::SkipEmptyParts);
|
||||
if(path_parts.size() > 1) {
|
||||
root_folder = path_parts.takeFirst();
|
||||
}
|
||||
path = fixFileNames(path_parts.join("/"));
|
||||
t->rename_file(i, path.toUtf8().data());
|
||||
++i;
|
||||
}
|
||||
return root_folder;
|
||||
}
|
||||
|
@ -382,22 +388,28 @@ QString misc::truncateRootFolder(libtorrent::torrent_handle h) {
|
|||
if(t.num_files() == 1) {
|
||||
// Single file torrent
|
||||
// Remove possible subfolders
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
QString path = QString::fromUtf8(t.file_at(0).path.c_str());
|
||||
#else
|
||||
QString path = QString::fromUtf8(t.file_at(0).path.string().c_str());
|
||||
#endif
|
||||
path = fixFileNames(fileName(path));
|
||||
t.rename_file(0, path.toUtf8().data());
|
||||
return QString();
|
||||
}
|
||||
QString root_folder;
|
||||
int i = 0;
|
||||
for(torrent_info::file_iterator it = t.begin_files(); it < t.end_files(); it++) {
|
||||
QString path = QString::fromUtf8(it->path.string().c_str());
|
||||
for(int i=0; i<t.num_files(); ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
QString path = QString::fromUtf8(t.file_at(i).path.c_str());
|
||||
#else
|
||||
QString path = QString::fromUtf8(t.file_at(i).path.string().c_str());
|
||||
#endif
|
||||
QStringList path_parts = path.split("/", QString::SkipEmptyParts);
|
||||
if(path_parts.size() > 1) {
|
||||
root_folder = path_parts.takeFirst();
|
||||
}
|
||||
path = fixFileNames(path_parts.join("/"));
|
||||
h.rename_file(i, path.toUtf8().data());
|
||||
++i;
|
||||
}
|
||||
return root_folder;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue