Kstars

downloadhelper.cpp
1#include "downloadhelper.h"
2
3ActionReply DownloadHelper::saveindexfile(const QVariantMap &args)
4{
5 ActionReply reply;
6 QString filename = args["filename"].toString();
7 QFile file(filename);
8
9 if (!file.open(QIODevice::WriteOnly))
10 {
12 reply.setErrorDescription(file.errorString());
13 return reply;
14 }
15
16 QByteArray array = args["contents"].toByteArray();
17
18 file.write(array.data(), array.size());
19 file.close();
20
21 return reply;
22}
23
24ActionReply DownloadHelper::removeindexfileset(const QVariantMap &args)
25{
26 ActionReply reply;
27 QString indexSetName = args["indexSetName"].toString();
28 QString astrometryDataDir = args["astrometryDataDir"].toString();
29
30 QStringList nameFilter("*.fits");
31 QDir directory(astrometryDataDir);
32 QStringList indexList = directory.entryList(nameFilter);
33 for (auto& fileName : indexList)
34 {
35 if (fileName.contains(indexSetName.left(10)))
36 {
37 if (!directory.remove(fileName))
38 {
40 reply.setErrorDescription("File did not delete");
41 return reply;
42 }
43 }
44 }
45
46 return reply;
47}
48
49KAUTH_HELPER_MAIN("org.kde.kf5auth.kstars", DownloadHelper);
void setErrorDescription(const QString &error)
static const ActionReply HelperErrorReply()
char * data()
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:25 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.