From 002cfa0663b7eeabca65b756515aef4f044c54c6 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 17 Mar 2015 12:09:03 +0100 Subject: Create picture cache directory if needed Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/divepicturewidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 0bf3424bc..ce997fea1 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -65,7 +65,11 @@ void ImageDownloader::saveImage(QNetworkReply *reply) QByteArray imageData = reply->readAll(); QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(imageData); - QFile imageFile(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first().append("/").append(hash.result().toHex())); + QString path = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first(); + QDir dir(path); + if (!dir.exists()) + dir.mkpath(path); + QFile imageFile(path.append("/").append(hash.result().toHex())); if (imageFile.open(QIODevice::WriteOnly)) { QDataStream stream(&imageFile); stream.writeRawData(imageData.data(), imageData.length()); -- cgit v1.2.3-70-g09d2