2023-02-07 07:05:06 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prism Launcher - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
|
|
|
#include <QApplication>
|
2023-03-20 23:38:40 +00:00
|
|
|
#include <QDataStream>
|
|
|
|
#include <QDateTime>
|
2023-02-07 07:05:06 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QFlag>
|
|
|
|
#include <QIcon>
|
2023-02-08 08:35:03 +00:00
|
|
|
#include <QLocalSocket>
|
2023-03-20 23:38:40 +00:00
|
|
|
#include <QUrl>
|
|
|
|
#include <memory>
|
2023-02-08 08:35:03 +00:00
|
|
|
|
|
|
|
#define PRISM_EXTERNAL_EXE
|
|
|
|
#include "FileSystem.h"
|
2023-02-07 07:05:06 +00:00
|
|
|
|
2023-03-20 23:38:40 +00:00
|
|
|
class FileLinkApp : public QCoreApplication {
|
2023-02-07 07:05:06 +00:00
|
|
|
// friends for the purpose of limiting access to deprecated stuff
|
|
|
|
Q_OBJECT
|
2023-03-20 23:38:40 +00:00
|
|
|
public:
|
2023-05-31 07:03:44 +01:00
|
|
|
enum Status {
|
|
|
|
Starting,
|
|
|
|
Failed,
|
|
|
|
Succeeded,
|
|
|
|
Initialized
|
|
|
|
};
|
2023-03-20 23:38:40 +00:00
|
|
|
FileLinkApp(int& argc, char** argv);
|
2023-02-07 07:05:06 +00:00
|
|
|
virtual ~FileLinkApp();
|
2023-05-31 07:03:44 +01:00
|
|
|
Status status() const {
|
|
|
|
return m_status;
|
|
|
|
}
|
2023-02-07 07:05:06 +00:00
|
|
|
|
2023-03-20 23:38:40 +00:00
|
|
|
private:
|
2023-02-08 08:35:03 +00:00
|
|
|
void joinServer(QString server);
|
|
|
|
void readPathPairs();
|
|
|
|
void runLink();
|
2023-02-08 20:36:15 +00:00
|
|
|
void sendResults();
|
|
|
|
|
2023-05-31 07:03:44 +01:00
|
|
|
Status m_status = Status::Starting;
|
|
|
|
|
2023-02-08 20:36:15 +00:00
|
|
|
bool m_useHardLinks = false;
|
2023-02-08 08:35:03 +00:00
|
|
|
|
2023-02-07 07:05:06 +00:00
|
|
|
QDateTime m_startTime;
|
2023-02-08 08:35:03 +00:00
|
|
|
QLocalSocket socket;
|
|
|
|
QDataStream in;
|
|
|
|
quint32 blockSize;
|
|
|
|
|
2023-02-08 20:36:15 +00:00
|
|
|
QList<FS::LinkPair> m_links_to_make;
|
|
|
|
QList<FS::LinkResult> m_path_results;
|
2023-02-07 07:05:06 +00:00
|
|
|
|
|
|
|
#if defined Q_OS_WIN32
|
|
|
|
// used on Windows to attach the standard IO streams
|
|
|
|
bool consoleAttached = false;
|
|
|
|
#endif
|
|
|
|
};
|