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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
131 changed files with 2252 additions and 1868 deletions

View file

@ -42,14 +42,14 @@ const int MAX_REDIRECTIONS = 20; // the common value for web browsers
namespace
{
nonstd::expected<QString, QString> saveToTempFile(const QByteArray &data)
nonstd::expected<Path, QString> saveToTempFile(const QByteArray &data)
{
QTemporaryFile file {Utils::Fs::tempPath()};
QTemporaryFile file {Utils::Fs::tempPath().data()};
if (!file.open() || (file.write(data) != data.length()) || !file.flush())
return nonstd::make_unexpected(file.errorString());
file.setAutoRemove(false);
return file.fileName();
return Path(file.fileName());
}
}
@ -127,10 +127,10 @@ void DownloadHandlerImpl::processFinishedDownload()
if (m_downloadRequest.saveToFile())
{
const QString destinationPath = m_downloadRequest.destFileName();
const Path destinationPath = m_downloadRequest.destFileName();
if (destinationPath.isEmpty())
{
const nonstd::expected<QString, QString> result = saveToTempFile(m_result.data);
const nonstd::expected<Path, QString> result = saveToTempFile(m_result.data);
if (result)
m_result.filePath = result.value();
else