From e691d416d43620c094009948fcdf61725fc7220a Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 17 Mar 2015 12:09:03 +0100 Subject: [PATCH] Create picture cache directory if needed Signed-off-by: Robert C. Helling --- qt-ui/divepicturewidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 0bf3424..ce997fe 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()); -- 1.9.5 (Apple Git-50.3)