Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
/*
* SPDX-FileCopyrightText: 2023 Sharaf Zaman <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "KisAndroidFileProxy.h"
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <kis_debug.h>
QString KisAndroidFileProxy::getFileFromContentUri(QString contentUri)
{
QFile file(contentUri);
const QString savePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
QDir dirPath = savePath;
QString filename = file.fileName();
if (dirPath.exists(filename)) {
// if the file already exists, delete it
dirPath.remove(filename);
}
bool copyResult = file.copy(savePath + "/" + filename);
if (!copyResult) {
qWarning() << "Failed to copy file from content uri" << contentUri << "to" << savePath + "/" + filename;
qWarning() << " " << ppVar(file.error()) << ppVar(file.errorString());
return "";
}
return savePath + "/" + filename;
}