Implement class for handling filesystem paths

PR #15915.
This commit is contained in:
Vladimir Golovnev
2022-02-08 06:03:48 +03:00
committed by GitHub
parent facfa26eed
commit dd1bd8ad10
131 changed files with 2252 additions and 1868 deletions

View File

@@ -37,13 +37,13 @@ const QString OPTION_DOWNLOADPATH {QStringLiteral("download_path")};
BitTorrent::CategoryOptions BitTorrent::CategoryOptions::fromJSON(const QJsonObject &jsonObj)
{
CategoryOptions options;
options.savePath = jsonObj.value(OPTION_SAVEPATH).toString();
options.savePath = Path(jsonObj.value(OPTION_SAVEPATH).toString());
const QJsonValue downloadPathValue = jsonObj.value(OPTION_DOWNLOADPATH);
if (downloadPathValue.isBool())
options.downloadPath = {downloadPathValue.toBool(), {}};
else if (downloadPathValue.isString())
options.downloadPath = {true, downloadPathValue.toString()};
options.downloadPath = {true, Path(downloadPathValue.toString())};
return options;
}
@@ -54,13 +54,13 @@ QJsonObject BitTorrent::CategoryOptions::toJSON() const
if (downloadPath)
{
if (downloadPath->enabled)
downloadPathValue = downloadPath->path;
downloadPathValue = downloadPath->path.data();
else
downloadPathValue = false;
}
return {
{OPTION_SAVEPATH, savePath},
{OPTION_SAVEPATH, savePath.data()},
{OPTION_DOWNLOADPATH, downloadPathValue}
};
}