Ensure directory is created

Fix #424
This commit is contained in:
Carl Schwan 2024-11-21 20:37:37 +01:00 committed by Devin Lin
parent 3a6a2f78da
commit 70ec403a55

View file

@ -6,12 +6,15 @@
#include "recordutil.h"
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <KFileUtils>
#include <KNotification>
using namespace Qt::StringLiterals;
RecordUtil::RecordUtil(QObject *parent)
: QObject{parent}
{
@ -19,7 +22,10 @@ RecordUtil::RecordUtil(QObject *parent)
QString RecordUtil::videoLocation(const QString &name)
{
QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
const QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
if (!QDir(path).mkpath(u"."_s)) {
qWarning() << "Unable to create directory" << path;
}
QString newPath(path + '/' + name);
if (QFile::exists(newPath)) {
newPath = path + '/' + KFileUtils::suggestName(QUrl::fromLocalFile(newPath), name);