Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAndroidFileProxy.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Sharaf Zaman <shzam@sdf.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
9#include <QDebug>
10#include <QDir>
11#include <QFile>
12#include <QStandardPaths>
13#include <kis_debug.h>
14
16{
17 QFile file(contentUri);
18 const QString savePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
19
20 QDir dirPath = savePath;
21
22 QString filename = file.fileName();
23 if (dirPath.exists(filename)) {
24 // if the file already exists, delete it
25 dirPath.remove(filename);
26 }
27
28 bool copyResult = file.copy(savePath + "/" + filename);
29 if (!copyResult) {
30 qWarning() << "Failed to copy file from content uri" << contentUri << "to" << savePath + "/" + filename;
31 qWarning() << " " << ppVar(file.error()) << ppVar(file.errorString());
32 return "";
33 }
34 return savePath + "/" + filename;
35}
static QString getFileFromContentUri(QString contentUri)
#define ppVar(var)
Definition kis_debug.h:155