1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 23:07:59 +00:00

Fix wrong root path generated on Windows

Fix cannot create torrent when the source file is at the root of a
drive.
Fix created torrent cannot be seeded when the source file is at the root
of a drive.

Fix up dd1bd8ad10.
Closes #17279.
This commit is contained in:
Chocobo1 2022-06-27 14:34:18 +08:00
parent aadf961184
commit 34091176d5
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -115,6 +115,11 @@ Path Path::rootItem() const
if (slashIndex == 0) // *nix absolute path if (slashIndex == 0) // *nix absolute path
return createUnchecked(u"/"_qs); return createUnchecked(u"/"_qs);
#ifdef Q_OS_WIN
// should be `c:/` instead of `c:`
if (m_pathStr.at(slashIndex - 1) == u':')
return createUnchecked(m_pathStr.left(slashIndex + 1));
#endif
return createUnchecked(m_pathStr.left(slashIndex)); return createUnchecked(m_pathStr.left(slashIndex));
} }
@ -127,6 +132,12 @@ Path Path::parentPath() const
if (slashIndex == 0) // *nix absolute path if (slashIndex == 0) // *nix absolute path
return (m_pathStr.size() == 1) ? Path() : createUnchecked(u"/"_qs); return (m_pathStr.size() == 1) ? Path() : createUnchecked(u"/"_qs);
#ifdef Q_OS_WIN
// should be `c:/` instead of `c:`
// Windows "drive letter" is limited to one alphabet
if ((slashIndex == 2) && (m_pathStr.at(1) == u':'))
return createUnchecked(m_pathStr.left(slashIndex + 1));
#endif
return createUnchecked(m_pathStr.left(slashIndex)); return createUnchecked(m_pathStr.left(slashIndex));
} }