From f794e49bb6eadd70c52683e60a700a1d7e9cd17b Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Mon, 6 Feb 2023 23:05:06 -0800
Subject: we want to make links!
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/filelink/FileLink.cpp | 119 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100644 launcher/filelink/FileLink.cpp
(limited to 'launcher/filelink/FileLink.cpp')
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
new file mode 100644
index 00000000..9b5589ab
--- /dev/null
+++ b/launcher/filelink/FileLink.cpp
@@ -0,0 +1,119 @@
+// 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 .
+ *
+ */
+
+#include "FileLink.h"
+#include "BuildConfig.h"
+
+
+#include
+
+#include
+#include
+
+#include
+
+
+#include
+#include
+
+#include
+
+#if defined Q_OS_WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include
+#include
+#endif
+
+
+
+
+FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv)
+{
+#if defined Q_OS_WIN32
+ // attach the parent console
+ if(AttachConsole(ATTACH_PARENT_PROCESS))
+ {
+ // if attach succeeds, reopen and sync all the i/o
+ if(freopen("CON", "w", stdout))
+ {
+ std::cout.sync_with_stdio();
+ }
+ if(freopen("CON", "w", stderr))
+ {
+ std::cerr.sync_with_stdio();
+ }
+ if(freopen("CON", "r", stdin))
+ {
+ std::cin.sync_with_stdio();
+ }
+ auto out = GetStdHandle (STD_OUTPUT_HANDLE);
+ DWORD written;
+ const char * endline = "\n";
+ WriteConsole(out, endline, strlen(endline), &written, NULL);
+ consoleAttached = true;
+ }
+#endif
+ setOrganizationName(BuildConfig.LAUNCHER_NAME);
+ setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
+ setApplicationName(BuildConfig.LAUNCHER_NAME + "FileLink");
+ setApplicationVersion(BuildConfig.printableVersionString() + "\n" + BuildConfig.GIT_COMMIT);
+
+ // Commandline parsing
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QObject::tr("a batch MKLINK program for windows to be useed with prismlauncher"));
+
+ parser.addOptions({
+
+ });
+ parser.addHelpOption();
+ parser.addVersionOption();
+
+ parser.process(arguments());
+
+ qDebug() << "link program launched";
+
+}
+
+
+FileLinkApp::~FileLinkApp()
+{
+ qDebug() << "link program shutting down";
+ // Shut down logger by setting the logger function to nothing
+ qInstallMessageHandler(nullptr);
+
+#if defined Q_OS_WIN32
+ // Detach from Windows console
+ if(consoleAttached)
+ {
+ fclose(stdout);
+ fclose(stdin);
+ fclose(stderr);
+ FreeConsole();
+ }
+#endif
+}
+
+
+
+
--
cgit
From 6d160a7b7e31034c7a657f30003562c20f9b9c21 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Wed, 8 Feb 2023 00:35:03 -0800
Subject: feat: successful process elevation and comunication!
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/filelink/FileLink.cpp | 106 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 101 insertions(+), 5 deletions(-)
(limited to 'launcher/filelink/FileLink.cpp')
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
index 9b5589ab..78486507 100644
--- a/launcher/filelink/FileLink.cpp
+++ b/launcher/filelink/FileLink.cpp
@@ -31,8 +31,6 @@
#include
-
-#include
#include
#include
@@ -48,7 +46,7 @@
-FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv)
+FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv), socket(new QLocalSocket(this))
{
#if defined Q_OS_WIN32
// attach the parent console
@@ -81,18 +79,116 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv)
// Commandline parsing
QCommandLineParser parser;
- parser.setApplicationDescription(QObject::tr("a batch MKLINK program for windows to be useed with prismlauncher"));
+ parser.setApplicationDescription(QObject::tr("a batch MKLINK program for windows to be used with prismlauncher"));
parser.addOptions({
-
+ {{"s", "server"}, "Join the specified server on launch", "pipe name"}
});
parser.addHelpOption();
parser.addVersionOption();
parser.process(arguments());
+ QString serverToJoin = parser.value("server");
+
qDebug() << "link program launched";
+ if (!serverToJoin.isEmpty()) {
+ qDebug() << "joining server" << serverToJoin;
+ joinServer(serverToJoin);
+ } else {
+ qDebug() << "no server to join";
+ exit();
+ }
+
+}
+
+void FileLinkApp::joinServer(QString server)
+{
+
+ blockSize = 0;
+
+ in.setDevice(&socket);
+ in.setVersion(QDataStream::Qt_5_15);
+
+ connect(&socket, &QLocalSocket::connected, this, [&](){
+ qDebug() << "connected to server";
+ });
+
+ connect(&socket, &QLocalSocket::readyRead, this, &FileLinkApp::readPathPairs);
+
+ connect(&socket, &QLocalSocket::errorOccurred, this, [&](QLocalSocket::LocalSocketError socketError){
+ switch (socketError) {
+ case QLocalSocket::ServerNotFoundError:
+ qDebug() << tr("The host was not found. Please make sure "
+ "that the server is running and that the "
+ "server name is correct.");
+ break;
+ case QLocalSocket::ConnectionRefusedError:
+ qDebug() << tr("The connection was refused by the peer. "
+ "Make sure the server is running, "
+ "and check that the server name "
+ "is correct.");
+ break;
+ case QLocalSocket::PeerClosedError:
+ break;
+ default:
+ qDebug() << tr("The following error occurred: %1.").arg(socket.errorString());
+ }
+ });
+
+ connect(&socket, &QLocalSocket::disconnected, this, [&](){
+ qDebug() << "dissconnected from server";
+ });
+
+ socket.connectToServer(server);
+
+
+}
+
+void FileLinkApp::runLink()
+{
+ qDebug() << "creating link";
+ FS::create_link lnk(m_path_pairs);
+ lnk.debug(true);
+ if (!lnk()) {
+ qDebug() << "Link Failed!" << lnk.getOSError().value() << lnk.getOSError().message().c_str();
+ }
+ //exit();
+ qDebug() << "done, should exit";
+}
+
+void FileLinkApp::readPathPairs()
+{
+ m_path_pairs.clear();
+ qDebug() << "Reading path pairs from server";
+ qDebug() << "bytes avalible" << socket.bytesAvailable();
+ if (blockSize == 0) {
+ // Relies on the fact that QDataStream serializes a quint32 into
+ // sizeof(quint32) bytes
+ if (socket.bytesAvailable() < (int)sizeof(quint32))
+ return;
+ qDebug() << "reading block size";
+ in >> blockSize;
+ }
+ qDebug() << "blocksize is" << blockSize;
+ qDebug() << "bytes avalible" << socket.bytesAvailable();
+ if (socket.bytesAvailable() < blockSize || in.atEnd())
+ return;
+
+ quint32 numPairs;
+ in >> numPairs;
+ qDebug() << "numPairs" << numPairs;
+
+ for(int i = 0; i < numPairs; i++) {
+ FS::LinkPair pair;
+ in >> pair.src;
+ in >> pair.dst;
+ qDebug() << "link" << pair.src << "to" << pair.dst;
+ m_path_pairs.append(pair);
+ }
+
+ runLink();
}
--
cgit
From 8ba51c790098ec9ebe3d2ef686f823b61c8a3645 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Wed, 8 Feb 2023 12:36:15 -0800
Subject: refactor: make complete list of links to make and send that.
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/filelink/FileLink.cpp | 134 +++++++++++++++++++++++++++++++++--------
1 file changed, 110 insertions(+), 24 deletions(-)
(limited to 'launcher/filelink/FileLink.cpp')
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
index 78486507..a731ecdb 100644
--- a/launcher/filelink/FileLink.cpp
+++ b/launcher/filelink/FileLink.cpp
@@ -23,6 +23,8 @@
#include "FileLink.h"
#include "BuildConfig.h"
+#include "StringUtils.h"
+
#include
@@ -43,6 +45,24 @@
#include
#endif
+// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
+
+#ifdef __APPLE__
+#include // for deployment target to support pre-catalina targets without std::fs
+#endif // __APPLE__
+
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
+#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
+#define GHC_USE_STD_FS
+#include
+namespace fs = std::filesystem;
+#endif // MacOS min version check
+#endif // Other OSes version check
+
+#ifndef GHC_USE_STD_FS
+#include
+namespace fs = ghc::filesystem;
+#endif
@@ -82,7 +102,8 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv),
parser.setApplicationDescription(QObject::tr("a batch MKLINK program for windows to be used with prismlauncher"));
parser.addOptions({
- {{"s", "server"}, "Join the specified server on launch", "pipe name"}
+ {{"s", "server"}, "Join the specified server on launch", "pipe name"},
+ {{"H", "hard"}, "use hard links insted of symbolic", "true/false"}
});
parser.addHelpOption();
parser.addVersionOption();
@@ -90,6 +111,7 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv),
parser.process(arguments());
QString serverToJoin = parser.value("server");
+ m_useHardLinks = QVariant(parser.value("hard")).toBool();
qDebug() << "link program launched";
@@ -109,7 +131,7 @@ void FileLinkApp::joinServer(QString server)
blockSize = 0;
in.setDevice(&socket);
- in.setVersion(QDataStream::Qt_5_15);
+ in.setVersion(QDataStream::Qt_5_0);
connect(&socket, &QLocalSocket::connected, this, [&](){
qDebug() << "connected to server";
@@ -120,25 +142,27 @@ void FileLinkApp::joinServer(QString server)
connect(&socket, &QLocalSocket::errorOccurred, this, [&](QLocalSocket::LocalSocketError socketError){
switch (socketError) {
case QLocalSocket::ServerNotFoundError:
- qDebug() << tr("The host was not found. Please make sure "
- "that the server is running and that the "
- "server name is correct.");
+ qDebug() << ("The host was not found. Please make sure "
+ "that the server is running and that the "
+ "server name is correct.");
break;
case QLocalSocket::ConnectionRefusedError:
- qDebug() << tr("The connection was refused by the peer. "
- "Make sure the server is running, "
- "and check that the server name "
- "is correct.");
+ qDebug() << ("The connection was refused by the peer. "
+ "Make sure the server is running, "
+ "and check that the server name "
+ "is correct.");
break;
case QLocalSocket::PeerClosedError:
+ qDebug() << ("The connection was closed by the peer. ");
break;
default:
- qDebug() << tr("The following error occurred: %1.").arg(socket.errorString());
+ qDebug() << "The following error occurred: " << socket.errorString();
}
});
connect(&socket, &QLocalSocket::disconnected, this, [&](){
- qDebug() << "dissconnected from server";
+ qDebug() << "dissconnected from server, should exit";
+ exit();
});
socket.connectToServer(server);
@@ -147,20 +171,82 @@ void FileLinkApp::joinServer(QString server)
}
void FileLinkApp::runLink()
+{
+
+ std::error_code os_err;
+
+ qDebug() << "creating links";
+
+ for (auto link : m_links_to_make) {
+
+ QString src_path = link.src;
+ QString dst_path = link.dst;
+
+ FS::ensureFilePathExists(dst_path);
+ if (m_useHardLinks) {
+ qDebug() << "making hard link:" << src_path << "to" << dst_path;
+ fs::create_hard_link(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), os_err);
+ } else if (fs::is_directory(StringUtils::toStdString(src_path))) {
+ qDebug() << "making directory_symlink:" << src_path << "to" << dst_path;
+ fs::create_directory_symlink(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), os_err);
+ } else {
+ qDebug() << "making symlink:" << src_path << "to" << dst_path;
+ fs::create_symlink(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), os_err);
+ }
+
+ if (os_err) {
+ qWarning() << "Failed to link files:" << QString::fromStdString(os_err.message());
+ qDebug() << "Source file:" << src_path;
+ qDebug() << "Destination file:" << dst_path;
+ qDebug() << "Error catagory:" << os_err.category().name();
+ qDebug() << "Error code:" << os_err.value();
+
+ FS::LinkResult result = {src_path, dst_path, QString::fromStdString(os_err.message()), os_err.value()};
+ m_path_results.append(result);
+ } else {
+ FS::LinkResult result = {src_path, dst_path};
+ m_path_results.append(result);
+ }
+ }
+
+ sendResults();
+ qDebug() << "done, should exit soon";
+
+}
+
+void FileLinkApp::sendResults()
{
- qDebug() << "creating link";
- FS::create_link lnk(m_path_pairs);
- lnk.debug(true);
- if (!lnk()) {
- qDebug() << "Link Failed!" << lnk.getOSError().value() << lnk.getOSError().message().c_str();
+ // construct block of data to send
+ QByteArray block;
+ QDataStream out(&block, QIODevice::WriteOnly);
+ out.setVersion(QDataStream::Qt_5_0);
+
+ qint32 blocksize = quint32(sizeof(quint32));
+ for (auto result : m_path_results) {
+ blocksize += quint32(result.src.size());
+ blocksize += quint32(result.dst.size());
+ blocksize += quint32(result.err_msg.size());
+ blocksize += quint32(sizeof(quint32));
}
- //exit();
- qDebug() << "done, should exit";
+ qDebug() << "About to write block of size:" << blocksize;
+ out << blocksize;
+
+ out << quint32(m_path_results.length());
+ for (auto result : m_path_results) {
+ out << result.src;
+ out << result.dst;
+ out << result.err_msg;
+ out << quint32(result.err_value);
+ }
+
+ qint64 byteswritten = socket.write(block);
+ bool bytesflushed = socket.flush();
+ qDebug() << "block flushed" << byteswritten << bytesflushed;
}
void FileLinkApp::readPathPairs()
{
- m_path_pairs.clear();
+ m_links_to_make.clear();
qDebug() << "Reading path pairs from server";
qDebug() << "bytes avalible" << socket.bytesAvailable();
if (blockSize == 0) {
@@ -176,16 +262,16 @@ void FileLinkApp::readPathPairs()
if (socket.bytesAvailable() < blockSize || in.atEnd())
return;
- quint32 numPairs;
- in >> numPairs;
- qDebug() << "numPairs" << numPairs;
+ quint32 numLinks;
+ in >> numLinks;
+ qDebug() << "numLinks" << numLinks;
- for(int i = 0; i < numPairs; i++) {
+ for(int i = 0; i < numLinks; i++) {
FS::LinkPair pair;
in >> pair.src;
in >> pair.dst;
qDebug() << "link" << pair.src << "to" << pair.dst;
- m_path_pairs.append(pair);
+ m_links_to_make.append(pair);
}
runLink();
--
cgit
From 0c986ba4d006740947603afb2e18dd9d2ffdfd2f Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Mon, 20 Mar 2023 16:38:40 -0700
Subject: spelling and formatting
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/filelink/FileLink.cpp | 110 +++++++++++++++++------------------------
1 file changed, 44 insertions(+), 66 deletions(-)
(limited to 'launcher/filelink/FileLink.cpp')
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
index a731ecdb..ded46061 100644
--- a/launcher/filelink/FileLink.cpp
+++ b/launcher/filelink/FileLink.cpp
@@ -25,7 +25,6 @@
#include "StringUtils.h"
-
#include
#include
@@ -41,53 +40,47 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
-#include
#include
+#include
#endif
// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
#ifdef __APPLE__
-#include // for deployment target to support pre-catalina targets without std::fs
-#endif // __APPLE__
+#include // for deployment target to support pre-catalina targets without std::fs
+#endif // __APPLE__
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include
namespace fs = std::filesystem;
-#endif // MacOS min version check
-#endif // Other OSes version check
+#endif // MacOS min version check
+#endif // Other OSes version check
#ifndef GHC_USE_STD_FS
#include
namespace fs = ghc::filesystem;
#endif
-
-
-FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv), socket(new QLocalSocket(this))
+FileLinkApp::FileLinkApp(int& argc, char** argv) : QCoreApplication(argc, argv), socket(new QLocalSocket(this))
{
#if defined Q_OS_WIN32
// attach the parent console
- if(AttachConsole(ATTACH_PARENT_PROCESS))
- {
+ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
// if attach succeeds, reopen and sync all the i/o
- if(freopen("CON", "w", stdout))
- {
+ if (freopen("CON", "w", stdout)) {
std::cout.sync_with_stdio();
}
- if(freopen("CON", "w", stderr))
- {
+ if (freopen("CON", "w", stderr)) {
std::cerr.sync_with_stdio();
}
- if(freopen("CON", "r", stdin))
- {
+ if (freopen("CON", "r", stdin)) {
std::cin.sync_with_stdio();
}
- auto out = GetStdHandle (STD_OUTPUT_HANDLE);
+ auto out = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD written;
- const char * endline = "\n";
+ const char* endline = "\n";
WriteConsole(out, endline, strlen(endline), &written, NULL);
consoleAttached = true;
}
@@ -101,10 +94,8 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv),
QCommandLineParser parser;
parser.setApplicationDescription(QObject::tr("a batch MKLINK program for windows to be used with prismlauncher"));
- parser.addOptions({
- {{"s", "server"}, "Join the specified server on launch", "pipe name"},
- {{"H", "hard"}, "use hard links insted of symbolic", "true/false"}
- });
+ parser.addOptions({ { { "s", "server" }, "Join the specified server on launch", "pipe name" },
+ { { "H", "hard" }, "use hard links instead of symbolic", "true/false" } });
parser.addHelpOption();
parser.addVersionOption();
@@ -122,63 +113,57 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv),
qDebug() << "no server to join";
exit();
}
-
}
void FileLinkApp::joinServer(QString server)
{
-
- blockSize = 0;
+ blockSize = 0;
in.setDevice(&socket);
in.setVersion(QDataStream::Qt_5_0);
- connect(&socket, &QLocalSocket::connected, this, [&](){
- qDebug() << "connected to server";
- });
+ connect(&socket, &QLocalSocket::connected, this, [&]() { qDebug() << "connected to server"; });
connect(&socket, &QLocalSocket::readyRead, this, &FileLinkApp::readPathPairs);
- connect(&socket, &QLocalSocket::errorOccurred, this, [&](QLocalSocket::LocalSocketError socketError){
+ connect(&socket, &QLocalSocket::errorOccurred, this, [&](QLocalSocket::LocalSocketError socketError) {
switch (socketError) {
- case QLocalSocket::ServerNotFoundError:
- qDebug() << ("The host was not found. Please make sure "
+ case QLocalSocket::ServerNotFoundError:
+ qDebug()
+ << ("The host was not found. Please make sure "
"that the server is running and that the "
"server name is correct.");
- break;
- case QLocalSocket::ConnectionRefusedError:
- qDebug() << ("The connection was refused by the peer. "
+ break;
+ case QLocalSocket::ConnectionRefusedError:
+ qDebug()
+ << ("The connection was refused by the peer. "
"Make sure the server is running, "
"and check that the server name "
"is correct.");
- break;
- case QLocalSocket::PeerClosedError:
- qDebug() << ("The connection was closed by the peer. ");
- break;
- default:
- qDebug() << "The following error occurred: " << socket.errorString();
+ break;
+ case QLocalSocket::PeerClosedError:
+ qDebug() << ("The connection was closed by the peer. ");
+ break;
+ default:
+ qDebug() << "The following error occurred: " << socket.errorString();
}
});
- connect(&socket, &QLocalSocket::disconnected, this, [&](){
- qDebug() << "dissconnected from server, should exit";
+ connect(&socket, &QLocalSocket::disconnected, this, [&]() {
+ qDebug() << "disconnected from server, should exit";
exit();
});
socket.connectToServer(server);
-
-
}
void FileLinkApp::runLink()
-{
-
+{
std::error_code os_err;
qDebug() << "creating links";
for (auto link : m_links_to_make) {
-
QString src_path = link.src;
QString dst_path = link.dst;
@@ -192,26 +177,25 @@ void FileLinkApp::runLink()
} else {
qDebug() << "making symlink:" << src_path << "to" << dst_path;
fs::create_symlink(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), os_err);
- }
+ }
if (os_err) {
qWarning() << "Failed to link files:" << QString::fromStdString(os_err.message());
qDebug() << "Source file:" << src_path;
qDebug() << "Destination file:" << dst_path;
- qDebug() << "Error catagory:" << os_err.category().name();
+ qDebug() << "Error category:" << os_err.category().name();
qDebug() << "Error code:" << os_err.value();
- FS::LinkResult result = {src_path, dst_path, QString::fromStdString(os_err.message()), os_err.value()};
+ FS::LinkResult result = { src_path, dst_path, QString::fromStdString(os_err.message()), os_err.value() };
m_path_results.append(result);
} else {
- FS::LinkResult result = {src_path, dst_path};
+ FS::LinkResult result = { src_path, dst_path };
m_path_results.append(result);
}
}
sendResults();
qDebug() << "done, should exit soon";
-
}
void FileLinkApp::sendResults()
@@ -245,10 +229,10 @@ void FileLinkApp::sendResults()
}
void FileLinkApp::readPathPairs()
-{
+{
m_links_to_make.clear();
qDebug() << "Reading path pairs from server";
- qDebug() << "bytes avalible" << socket.bytesAvailable();
+ qDebug() << "bytes available" << socket.bytesAvailable();
if (blockSize == 0) {
// Relies on the fact that QDataStream serializes a quint32 into
// sizeof(quint32) bytes
@@ -258,15 +242,15 @@ void FileLinkApp::readPathPairs()
in >> blockSize;
}
qDebug() << "blocksize is" << blockSize;
- qDebug() << "bytes avalible" << socket.bytesAvailable();
+ qDebug() << "bytes available" << socket.bytesAvailable();
if (socket.bytesAvailable() < blockSize || in.atEnd())
return;
-
+
quint32 numLinks;
in >> numLinks;
qDebug() << "numLinks" << numLinks;
- for(int i = 0; i < numLinks; i++) {
+ for (int i = 0; i < numLinks; i++) {
FS::LinkPair pair;
in >> pair.src;
in >> pair.dst;
@@ -277,17 +261,15 @@ void FileLinkApp::readPathPairs()
runLink();
}
-
FileLinkApp::~FileLinkApp()
-{
+{
qDebug() << "link program shutting down";
// Shut down logger by setting the logger function to nothing
qInstallMessageHandler(nullptr);
#if defined Q_OS_WIN32
// Detach from Windows console
- if(consoleAttached)
- {
+ if (consoleAttached) {
fclose(stdout);
fclose(stdin);
fclose(stderr);
@@ -295,7 +277,3 @@ FileLinkApp::~FileLinkApp()
}
#endif
}
-
-
-
-
--
cgit
From 197be9cfd0299edba57fe6fe1d7a7841ed0bb771 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Mon, 3 Apr 2023 18:00:56 -0700
Subject: fix: remove fixed datastream version
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/filelink/FileLink.cpp | 2 --
1 file changed, 2 deletions(-)
(limited to 'launcher/filelink/FileLink.cpp')
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
index ded46061..c9599b82 100644
--- a/launcher/filelink/FileLink.cpp
+++ b/launcher/filelink/FileLink.cpp
@@ -120,7 +120,6 @@ void FileLinkApp::joinServer(QString server)
blockSize = 0;
in.setDevice(&socket);
- in.setVersion(QDataStream::Qt_5_0);
connect(&socket, &QLocalSocket::connected, this, [&]() { qDebug() << "connected to server"; });
@@ -203,7 +202,6 @@ void FileLinkApp::sendResults()
// construct block of data to send
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_5_0);
qint32 blocksize = quint32(sizeof(quint32));
for (auto result : m_path_results) {
--
cgit