|
|
@ -362,24 +362,29 @@ int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentInfo::hasRootFolder() const |
|
|
|
QString TorrentInfo::rootFolder() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString testRootFolder; |
|
|
|
QString rootFolder; |
|
|
|
for (int i = 0; i < filesCount(); ++i) { |
|
|
|
for (int i = 0; i < filesCount(); ++i) { |
|
|
|
const QString filePath = this->filePath(i); |
|
|
|
const QString filePath = this->filePath(i); |
|
|
|
if (QDir::isAbsolutePath(filePath)) continue; |
|
|
|
if (QDir::isAbsolutePath(filePath)) continue; |
|
|
|
|
|
|
|
|
|
|
|
const auto filePathElements = filePath.splitRef('/'); |
|
|
|
const auto filePathElements = filePath.splitRef('/'); |
|
|
|
// if at least one file has no root folder, no common root folder exists
|
|
|
|
// if at least one file has no root folder, no common root folder exists
|
|
|
|
if (filePathElements.count() <= 1) return false; |
|
|
|
if (filePathElements.count() <= 1) return ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rootFolder.isEmpty()) |
|
|
|
|
|
|
|
rootFolder = filePathElements.at(0).toString(); |
|
|
|
|
|
|
|
else if (rootFolder != filePathElements.at(0)) |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (testRootFolder.isEmpty()) |
|
|
|
return rootFolder; |
|
|
|
testRootFolder = filePathElements.at(0).toString(); |
|
|
|
|
|
|
|
else if (testRootFolder != filePathElements.at(0)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
bool TorrentInfo::hasRootFolder() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return !rootFolder().isEmpty(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentInfo::stripRootFolder() |
|
|
|
void TorrentInfo::stripRootFolder() |
|
|
|