spelling and formatting
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
a28193430c
commit
0c986ba4d0
@ -328,7 +328,7 @@ bool create_link::operator()(const QString& offset, bool dryRun)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief make a list off all the links ot make
|
||||
* @brief make a list off all the links to
|
||||
* @param offset subdirectory form src to link to dest
|
||||
* @return if there was an error during the attempt to link
|
||||
*/
|
||||
@ -363,7 +363,7 @@ void create_link::make_link_list(const QString& offset)
|
||||
link_file(src, "");
|
||||
} else {
|
||||
if (m_debug)
|
||||
qDebug() << "linking recursivly:" << src << "to" << dst << "max_depth:" << m_max_depth;
|
||||
qDebug() << "linking recursively:" << src << "to" << dst << "max_depth:" << m_max_depth;
|
||||
QDir src_dir(src);
|
||||
QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories);
|
||||
|
||||
@ -414,7 +414,7 @@ bool create_link::make_links()
|
||||
qWarning() << "Failed to link files:" << QString::fromStdString(m_os_err.message());
|
||||
qDebug() << "Source file:" << src_path;
|
||||
qDebug() << "Destination file:" << dst_path;
|
||||
qDebug() << "Error catagory:" << m_os_err.category().name();
|
||||
qDebug() << "Error category:" << m_os_err.category().name();
|
||||
qDebug() << "Error code:" << m_os_err.value();
|
||||
emit linkFailed(src_path, dst_path, QString::fromStdString(m_os_err.message()), m_os_err.value());
|
||||
} else {
|
||||
@ -469,7 +469,7 @@ void create_link::runPrivileged(const QString& offset)
|
||||
in.setDevice(clientConnection);
|
||||
in.setVersion(QDataStream::Qt_5_0);
|
||||
qDebug() << "Reading path results from client";
|
||||
qDebug() << "bytes avalible" << clientConnection->bytesAvailable();
|
||||
qDebug() << "bytes available" << clientConnection->bytesAvailable();
|
||||
|
||||
// Relies on the fact that QDataStream serializes a quint32 into
|
||||
// sizeof(quint32) bytes
|
||||
@ -479,7 +479,7 @@ void create_link::runPrivileged(const QString& offset)
|
||||
in >> blockSize;
|
||||
|
||||
qDebug() << "blocksize is" << blockSize;
|
||||
qDebug() << "bytes avalible" << clientConnection->bytesAvailable();
|
||||
qDebug() << "bytes available" << clientConnection->bytesAvailable();
|
||||
if (clientConnection->bytesAvailable() < blockSize || in.atEnd())
|
||||
return;
|
||||
|
||||
@ -506,7 +506,7 @@ void create_link::runPrivileged(const QString& offset)
|
||||
m_path_results.append(result);
|
||||
}
|
||||
gotResults = true;
|
||||
qDebug() << "results recieved, closing connection";
|
||||
qDebug() << "results received, closing connection";
|
||||
clientConnection->close();
|
||||
});
|
||||
|
||||
@ -981,7 +981,7 @@ FilesystemType getFilesystemType(const QString& name)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief path to the near ancestor that exsists
|
||||
* @brief path to the near ancestor that exists
|
||||
*
|
||||
*/
|
||||
QString NearestExistentAncestor(const QString& path)
|
||||
|
@ -44,9 +44,9 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFlags>
|
||||
#include <QLocalServer>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QLocalServer>
|
||||
|
||||
namespace FS {
|
||||
|
||||
@ -171,13 +171,10 @@ class ExternalLinkFileProcess : public QThread {
|
||||
class create_link : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
create_link(const QList<LinkPair> path_pairs, QObject* parent = nullptr) : QObject(parent)
|
||||
{
|
||||
m_path_pairs.append(path_pairs);
|
||||
}
|
||||
create_link(const QList<LinkPair> path_pairs, QObject* parent = nullptr) : QObject(parent) { m_path_pairs.append(path_pairs); }
|
||||
create_link(const QString& src, const QString& dst, QObject* parent = nullptr) : QObject(parent)
|
||||
{
|
||||
LinkPair pair = {src, dst};
|
||||
LinkPair pair = { src, dst };
|
||||
m_path_pairs.append(pair);
|
||||
}
|
||||
create_link& useHardLinks(const bool useHard)
|
||||
@ -211,28 +208,23 @@ class create_link : public QObject {
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::error_code getOSError() {
|
||||
return m_os_err;
|
||||
}
|
||||
std::error_code getOSError() { return m_os_err; }
|
||||
|
||||
bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
|
||||
|
||||
int totalLinked() { return m_linked; }
|
||||
|
||||
|
||||
void runPrivileged() { runPrivileged(QString()); }
|
||||
void runPrivileged(const QString& offset);
|
||||
|
||||
QList<LinkResult> getResults() { return m_path_results; }
|
||||
|
||||
|
||||
signals:
|
||||
void fileLinked(const QString& srcName, const QString& dstName);
|
||||
void linkFailed(const QString& srcName, const QString& dstName, const QString& err_msg, int err_value);
|
||||
void finished();
|
||||
void finishedPrivileged(bool gotResults);
|
||||
|
||||
|
||||
private:
|
||||
bool operator()(const QString& offset, bool dryRun = false);
|
||||
void make_link_list(const QString& offset);
|
||||
@ -274,7 +266,7 @@ bool deletePath(QString path);
|
||||
/**
|
||||
* Trash a folder / file
|
||||
*/
|
||||
bool trash(QString path, QString *pathInTrash = nullptr);
|
||||
bool trash(QString path, QString* pathInTrash = nullptr);
|
||||
|
||||
QString PathCombine(const QString& path1, const QString& path2);
|
||||
QString PathCombine(const QString& path1, const QString& path2, const QString& path3);
|
||||
@ -286,13 +278,12 @@ QString AbsolutePath(const QString& path);
|
||||
* @brief depth of path. "foo.txt" -> 0 , "bar/foo.txt" -> 1, /baz/bar/foo.txt -> 2, etc.
|
||||
*
|
||||
* @param path path to measure
|
||||
* @return int number of componants before base path
|
||||
* @return int number of components before base path
|
||||
*/
|
||||
int PathDepth(const QString& path);
|
||||
|
||||
|
||||
/**
|
||||
* @brief cut off segments of path untill it is a max of length depth
|
||||
* @brief cut off segments of path until it is a max of length depth
|
||||
*
|
||||
* @param path path to truncate
|
||||
* @param depth max depth of new path
|
||||
@ -363,64 +354,61 @@ enum class FilesystemType {
|
||||
|
||||
/**
|
||||
* @brief Ordered Mapping of enum types to reported filesystem names
|
||||
* this maping is non exsaustive, it just attempts to capture the filesystems which could be reasonalbly be in use .
|
||||
* this mapping is non exsaustive, it just attempts to capture the filesystems which could be reasonalbly be in use .
|
||||
* all string values are in uppercase, use `QString.toUpper()` or equivalent during lookup.
|
||||
*
|
||||
* QMap is ordered
|
||||
*
|
||||
*/
|
||||
static const QMap<FilesystemType, QString> s_filesystem_type_names = {
|
||||
{FilesystemType::FAT, QString("FAT")},
|
||||
{FilesystemType::NTFS, QString("NTFS")},
|
||||
{FilesystemType::REFS, QString("REFS")},
|
||||
{FilesystemType::EXT, QString("EXT")},
|
||||
{FilesystemType::EXT_2_OLD, QString("EXT_2_OLD")},
|
||||
{FilesystemType::EXT_2_3_4, QString("EXT2/3/4")},
|
||||
{FilesystemType::XFS, QString("XFS")},
|
||||
{FilesystemType::BTRFS, QString("BTRFS")},
|
||||
{FilesystemType::NFS, QString("NFS")},
|
||||
{FilesystemType::ZFS, QString("ZFS")},
|
||||
{FilesystemType::APFS, QString("APFS")},
|
||||
{FilesystemType::HFS, QString("HFS")},
|
||||
{FilesystemType::HFSPLUS, QString("HFSPLUS")},
|
||||
{FilesystemType::HFSX, QString("HFSX")},
|
||||
{FilesystemType::FUSEBLK, QString("FUSEBLK")},
|
||||
{FilesystemType::F2FS, QString("F2FS")},
|
||||
{FilesystemType::UNKNOWN, QString("UNKNOWN")}
|
||||
};
|
||||
|
||||
static const QMap<FilesystemType, QString> s_filesystem_type_names = { { FilesystemType::FAT, QString("FAT") },
|
||||
{ FilesystemType::NTFS, QString("NTFS") },
|
||||
{ FilesystemType::REFS, QString("REFS") },
|
||||
{ FilesystemType::EXT, QString("EXT") },
|
||||
{ FilesystemType::EXT_2_OLD, QString("EXT_2_OLD") },
|
||||
{ FilesystemType::EXT_2_3_4, QString("EXT2/3/4") },
|
||||
{ FilesystemType::XFS, QString("XFS") },
|
||||
{ FilesystemType::BTRFS, QString("BTRFS") },
|
||||
{ FilesystemType::NFS, QString("NFS") },
|
||||
{ FilesystemType::ZFS, QString("ZFS") },
|
||||
{ FilesystemType::APFS, QString("APFS") },
|
||||
{ FilesystemType::HFS, QString("HFS") },
|
||||
{ FilesystemType::HFSPLUS, QString("HFSPLUS") },
|
||||
{ FilesystemType::HFSX, QString("HFSX") },
|
||||
{ FilesystemType::FUSEBLK, QString("FUSEBLK") },
|
||||
{ FilesystemType::F2FS, QString("F2FS") },
|
||||
{ FilesystemType::UNKNOWN, QString("UNKNOWN") } };
|
||||
|
||||
/**
|
||||
* @brief Ordered Mapping of reported filesystem names to enum types
|
||||
* this maping is non exsaustive, it just attempts to capture the many way these filesystems could be reported.
|
||||
* this mapping is non exsaustive, it just attempts to capture the many way these filesystems could be reported.
|
||||
* all keys are in uppercase, use `QString.toUpper()` or equivalent during lookup.
|
||||
*
|
||||
* QMap is ordered
|
||||
*
|
||||
*/
|
||||
static const QMap<QString, FilesystemType> s_filesystem_type_names_inverse = {
|
||||
{QString("FAT"), FilesystemType::FAT},
|
||||
{QString("NTFS"), FilesystemType::NTFS},
|
||||
{QString("REFS"), FilesystemType::REFS},
|
||||
{QString("EXT2_OLD"), FilesystemType::EXT_2_OLD},
|
||||
{QString("EXT_2_OLD"), FilesystemType::EXT_2_OLD},
|
||||
{QString("EXT2"), FilesystemType::EXT_2_3_4},
|
||||
{QString("EXT3"), FilesystemType::EXT_2_3_4},
|
||||
{QString("EXT4"), FilesystemType::EXT_2_3_4},
|
||||
{QString("EXT2/3/4"), FilesystemType::EXT_2_3_4},
|
||||
{QString("EXT_2_3_4"), FilesystemType::EXT_2_3_4},
|
||||
{QString("EXT"), FilesystemType::EXT}, // must come after all other EXT variants to prevent greedy detection
|
||||
{QString("XFS"), FilesystemType::XFS},
|
||||
{QString("BTRFS"), FilesystemType::BTRFS},
|
||||
{QString("NFS"), FilesystemType::NFS},
|
||||
{QString("ZFS"), FilesystemType::ZFS},
|
||||
{QString("APFS"), FilesystemType::APFS},
|
||||
{QString("HFSPLUS"), FilesystemType::HFSPLUS},
|
||||
{QString("HFSX"), FilesystemType::HFSX},
|
||||
{QString("HFS"), FilesystemType::HFS},
|
||||
{QString("FUSEBLK"), FilesystemType::FUSEBLK},
|
||||
{QString("F2FS"), FilesystemType::F2FS},
|
||||
{QString("UNKNOWN"), FilesystemType::UNKNOWN}
|
||||
{ QString("FAT"), FilesystemType::FAT },
|
||||
{ QString("NTFS"), FilesystemType::NTFS },
|
||||
{ QString("REFS"), FilesystemType::REFS },
|
||||
{ QString("EXT2_OLD"), FilesystemType::EXT_2_OLD },
|
||||
{ QString("EXT_2_OLD"), FilesystemType::EXT_2_OLD },
|
||||
{ QString("EXT2"), FilesystemType::EXT_2_3_4 },
|
||||
{ QString("EXT3"), FilesystemType::EXT_2_3_4 },
|
||||
{ QString("EXT4"), FilesystemType::EXT_2_3_4 },
|
||||
{ QString("EXT2/3/4"), FilesystemType::EXT_2_3_4 },
|
||||
{ QString("EXT_2_3_4"), FilesystemType::EXT_2_3_4 },
|
||||
{ QString("EXT"), FilesystemType::EXT }, // must come after all other EXT variants to prevent greedy detection
|
||||
{ QString("XFS"), FilesystemType::XFS },
|
||||
{ QString("BTRFS"), FilesystemType::BTRFS },
|
||||
{ QString("NFS"), FilesystemType::NFS },
|
||||
{ QString("ZFS"), FilesystemType::ZFS },
|
||||
{ QString("APFS"), FilesystemType::APFS },
|
||||
{ QString("HFSPLUS"), FilesystemType::HFSPLUS },
|
||||
{ QString("HFSX"), FilesystemType::HFSX },
|
||||
{ QString("HFS"), FilesystemType::HFS },
|
||||
{ QString("FUSEBLK"), FilesystemType::FUSEBLK },
|
||||
{ QString("F2FS"), FilesystemType::F2FS },
|
||||
{ QString("UNKNOWN"), FilesystemType::UNKNOWN }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -449,7 +437,6 @@ FilesystemType getFilesystemType(const QString& name);
|
||||
*/
|
||||
FilesystemType getFilesystemTypeFuzzy(const QString& name);
|
||||
|
||||
|
||||
struct FilesystemInfo {
|
||||
FilesystemType fsType = FilesystemType::UNKNOWN;
|
||||
QString fsTypeName;
|
||||
@ -462,7 +449,7 @@ struct FilesystemInfo {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief path to the near ancestor that exsists
|
||||
* @brief path to the near ancestor that exists
|
||||
*
|
||||
*/
|
||||
QString NearestExistentAncestor(const QString& path);
|
||||
@ -473,10 +460,8 @@ QString NearestExistentAncestor(const QString& path);
|
||||
*/
|
||||
FilesystemInfo statFS(const QString& path);
|
||||
|
||||
static const QList<FilesystemType> s_clone_filesystems = {
|
||||
FilesystemType::BTRFS, FilesystemType::APFS, FilesystemType::ZFS,
|
||||
FilesystemType::XFS, FilesystemType::REFS
|
||||
};
|
||||
static const QList<FilesystemType> s_clone_filesystems = { FilesystemType::BTRFS, FilesystemType::APFS, FilesystemType::ZFS,
|
||||
FilesystemType::XFS, FilesystemType::REFS };
|
||||
|
||||
/**
|
||||
* @brief if the Filesystem is reflink/clone capable
|
||||
@ -567,4 +552,4 @@ bool canLink(const QString& src, const QString& dst);
|
||||
|
||||
uintmax_t hardLinkCount(const QString& path);
|
||||
|
||||
}
|
||||
} // namespace FS
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "InstanceCopyTask.h"
|
||||
#include "settings/INISettingsObject.h"
|
||||
#include <QDebug>
|
||||
#include <QtConcurrentRun>
|
||||
#include "FileSystem.h"
|
||||
#include "NullInstance.h"
|
||||
#include "pathmatcher/RegexpMatcher.h"
|
||||
#include <QtConcurrentRun>
|
||||
#include <QDebug>
|
||||
#include "settings/INISettingsObject.h"
|
||||
|
||||
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
|
||||
{
|
||||
@ -18,14 +18,14 @@ InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyP
|
||||
|
||||
QString filters = prefs.getSelectedFiltersAsRegex();
|
||||
if (m_useLinks || m_useHardLinks) {
|
||||
if (!filters.isEmpty()) filters += "|";
|
||||
if (!filters.isEmpty())
|
||||
filters += "|";
|
||||
filters += "instance.cfg";
|
||||
}
|
||||
|
||||
qDebug() << "CopyFilters:" << filters;
|
||||
|
||||
if (!filters.isEmpty())
|
||||
{
|
||||
if (!filters.isEmpty()) {
|
||||
// Set regex filter:
|
||||
// FIXME: get this from the original instance type...
|
||||
auto matcherReal = new RegexpMatcher(filters);
|
||||
@ -38,14 +38,14 @@ void InstanceCopyTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Copying instance %1").arg(m_origInstance->name()));
|
||||
|
||||
auto copySaves = [&](){
|
||||
FS::copy savesCopy(FS::PathCombine(m_origInstance->instanceRoot(), "saves") , FS::PathCombine(m_stagingPath, "saves"));
|
||||
auto copySaves = [&]() {
|
||||
FS::copy savesCopy(FS::PathCombine(m_origInstance->instanceRoot(), "saves"), FS::PathCombine(m_stagingPath, "saves"));
|
||||
savesCopy.followSymlinks(true);
|
||||
|
||||
return savesCopy();
|
||||
};
|
||||
|
||||
m_copyFuture = QtConcurrent::run(QThreadPool::globalInstance(), [this, copySaves]{
|
||||
m_copyFuture = QtConcurrent::run(QThreadPool::globalInstance(), [this, copySaves] {
|
||||
if (m_useClone) {
|
||||
FS::clone folderClone(m_origInstance->instanceRoot(), m_stagingPath);
|
||||
folderClone.matcher(m_matcher.get());
|
||||
@ -58,17 +58,17 @@ void InstanceCopyTask::executeTask()
|
||||
|
||||
bool there_were_errors = false;
|
||||
|
||||
if(!folderLink()){
|
||||
if (!folderLink()) {
|
||||
#if defined Q_OS_WIN32
|
||||
if (!m_useHardLinks) {
|
||||
qDebug() << "EXPECTED: Link failure, Windows requires permissions for symlinks";
|
||||
|
||||
qDebug() << "atempting to run with privelage";
|
||||
qDebug() << "attempting to run with privelage";
|
||||
|
||||
QEventLoop loop;
|
||||
bool got_priv_results = false;
|
||||
|
||||
connect(&folderLink, &FS::create_link::finishedPrivileged, this, [&](bool gotResults){
|
||||
connect(&folderLink, &FS::create_link::finishedPrivileged, this, [&](bool gotResults) {
|
||||
if (!gotResults) {
|
||||
qDebug() << "Privileged run exited without results!";
|
||||
}
|
||||
@ -119,8 +119,7 @@ void InstanceCopyTask::executeTask()
|
||||
void InstanceCopyTask::copyFinished()
|
||||
{
|
||||
auto successful = m_copyFuture.result();
|
||||
if(!successful)
|
||||
{
|
||||
if (!successful) {
|
||||
emitFailed(tr("Instance folder copy failed."));
|
||||
return;
|
||||
}
|
||||
@ -130,7 +129,7 @@ void InstanceCopyTask::copyFinished()
|
||||
InstancePtr inst(new NullInstance(m_globalSettings, instanceSettings, m_stagingPath));
|
||||
inst->setName(name());
|
||||
inst->setIconKey(m_instIcon);
|
||||
if(!m_keepPlaytime) {
|
||||
if (!m_keepPlaytime) {
|
||||
inst->resetTimePlayed();
|
||||
}
|
||||
if (m_useLinks)
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QAccessible>
|
||||
@ -41,8 +40,8 @@
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
|
||||
@ -64,30 +63,24 @@ namespace fs = std::filesystem;
|
||||
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,32 +113,30 @@ FileLinkApp::FileLinkApp(int &argc, char **argv) : QCoreApplication(argc, argv),
|
||||
qDebug() << "no server to join";
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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";
|
||||
});
|
||||
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 "
|
||||
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. "
|
||||
qDebug()
|
||||
<< ("The connection was refused by the peer. "
|
||||
"Make sure the server is running, "
|
||||
"and check that the server name "
|
||||
"is correct.");
|
||||
@ -160,25 +149,21 @@ void FileLinkApp::joinServer(QString server)
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
@ -198,20 +183,19 @@ void FileLinkApp::runLink()
|
||||
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()
|
||||
@ -248,7 +232,7 @@ 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,7 +242,7 @@ 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;
|
||||
|
||||
@ -266,7 +250,7 @@ void FileLinkApp::readPathPairs()
|
||||
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,7 +261,6 @@ void FileLinkApp::readPathPairs()
|
||||
runLink();
|
||||
}
|
||||
|
||||
|
||||
FileLinkApp::~FileLinkApp()
|
||||
{
|
||||
qDebug() << "link program shutting down";
|
||||
@ -286,8 +269,7 @@ FileLinkApp::~FileLinkApp()
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -25,30 +25,26 @@
|
||||
#include <QtCore>
|
||||
|
||||
#include <QApplication>
|
||||
#include <memory>
|
||||
#include <QDataStream>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QFlag>
|
||||
#include <QIcon>
|
||||
#include <QDateTime>
|
||||
#include <QUrl>
|
||||
#include <QDateTime>
|
||||
#include <QDataStream>
|
||||
#include <QLocalSocket>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
|
||||
#define PRISM_EXTERNAL_EXE
|
||||
#include "FileSystem.h"
|
||||
|
||||
class FileLinkApp : public QCoreApplication
|
||||
{
|
||||
class FileLinkApp : public QCoreApplication {
|
||||
// friends for the purpose of limiting access to deprecated stuff
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
FileLinkApp(int &argc, char **argv);
|
||||
public:
|
||||
FileLinkApp(int& argc, char** argv);
|
||||
virtual ~FileLinkApp();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
void joinServer(QString server);
|
||||
void readPathPairs();
|
||||
void runLink();
|
||||
|
@ -22,9 +22,8 @@
|
||||
|
||||
#include "FileLink.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
FileLinkApp ldh(argc, argv);
|
||||
|
||||
return ldh.exec();
|
||||
|
@ -43,15 +43,15 @@
|
||||
|
||||
#include "ui/dialogs/IconPickerDialog.h"
|
||||
|
||||
#include "BaseVersion.h"
|
||||
#include "icons/IconList.h"
|
||||
#include "BaseInstance.h"
|
||||
#include "InstanceList.h"
|
||||
#include "FileSystem.h"
|
||||
#include "BaseVersion.h"
|
||||
#include "DesktopServices.h"
|
||||
#include "FileSystem.h"
|
||||
#include "InstanceList.h"
|
||||
#include "icons/IconList.h"
|
||||
|
||||
CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
:QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original)
|
||||
CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
resize(minimumSizeHint());
|
||||
@ -74,8 +74,7 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
groupList.push_front("");
|
||||
ui->groupBox->addItems(groupList);
|
||||
int index = groupList.indexOf(APPLICATION->instances()->getInstanceGroup(m_original->id()));
|
||||
if(index == -1)
|
||||
{
|
||||
if (index == -1) {
|
||||
index = 0;
|
||||
}
|
||||
ui->groupBox->setCurrentIndex(index);
|
||||
@ -108,10 +107,8 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
ui->symbolicLinksCheckbox->setIcon(style()->standardIcon(QStyle::SP_VistaShield));
|
||||
ui->symbolicLinksCheckbox->setToolTip(
|
||||
tr("Use symbolic links instead of copying files.") +
|
||||
tr("\nOn windows symbolic links may require admin permision to create.")
|
||||
);
|
||||
ui->symbolicLinksCheckbox->setToolTip(tr("Use symbolic links instead of copying files.") +
|
||||
tr("\nOn windows symbolic links may require admin permission to create."));
|
||||
#endif
|
||||
|
||||
updateLinkOptions();
|
||||
@ -119,7 +116,6 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
|
||||
auto HelpButton = ui->buttonBox->button(QDialogButtonBox::Help);
|
||||
connect(HelpButton, &QPushButton::clicked, this, &CopyInstanceDialog::help);
|
||||
|
||||
}
|
||||
|
||||
CopyInstanceDialog::~CopyInstanceDialog()
|
||||
@ -131,8 +127,7 @@ void CopyInstanceDialog::updateDialogState()
|
||||
{
|
||||
auto allowOK = !instName().isEmpty();
|
||||
auto OkButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
if(OkButton->isEnabled() != allowOK)
|
||||
{
|
||||
if (OkButton->isEnabled() != allowOK) {
|
||||
OkButton->setEnabled(allowOK);
|
||||
}
|
||||
}
|
||||
@ -140,8 +135,7 @@ void CopyInstanceDialog::updateDialogState()
|
||||
QString CopyInstanceDialog::instName() const
|
||||
{
|
||||
auto result = ui->instNameTextBox->text().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
if (result.size()) {
|
||||
return result;
|
||||
}
|
||||
return QString();
|
||||
@ -162,7 +156,6 @@ const InstanceCopyPrefs& CopyInstanceDialog::getChosenOptions() const
|
||||
return m_selectedOptions;
|
||||
}
|
||||
|
||||
|
||||
void CopyInstanceDialog::help()
|
||||
{
|
||||
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("instance-copy")));
|
||||
@ -200,7 +193,8 @@ void CopyInstanceDialog::updateLinkOptions()
|
||||
ui->symbolicLinksCheckbox->setEnabled(m_linkSupported && !ui->hardLinksCheckbox->isChecked() && !ui->useCloneCheckbox->isChecked());
|
||||
ui->hardLinksCheckbox->setEnabled(m_linkSupported && !ui->symbolicLinksCheckbox->isChecked() && !ui->useCloneCheckbox->isChecked());
|
||||
|
||||
ui->symbolicLinksCheckbox->setChecked(m_linkSupported && m_selectedOptions.isUseSymLinksEnabled() && !ui->useCloneCheckbox->isChecked());
|
||||
ui->symbolicLinksCheckbox->setChecked(m_linkSupported && m_selectedOptions.isUseSymLinksEnabled() &&
|
||||
!ui->useCloneCheckbox->isChecked());
|
||||
ui->hardLinksCheckbox->setChecked(m_linkSupported && m_selectedOptions.isUseHardLinksEnabled() && !ui->useCloneCheckbox->isChecked());
|
||||
|
||||
bool linksInUse = (ui->symbolicLinksCheckbox->isChecked() || ui->hardLinksCheckbox->isChecked());
|
||||
@ -220,15 +214,13 @@ void CopyInstanceDialog::on_iconButton_clicked()
|
||||
IconPickerDialog dlg(this);
|
||||
dlg.execWithSelection(InstIconKey);
|
||||
|
||||
if (dlg.result() == QDialog::Accepted)
|
||||
{
|
||||
if (dlg.result() == QDialog::Accepted) {
|
||||
InstIconKey = dlg.selectedIconKey;
|
||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
@ -247,7 +239,6 @@ void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state)
|
||||
updateSelectAllCheckbox();
|
||||
}
|
||||
|
||||
|
||||
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
|
||||
{
|
||||
m_selectedOptions.enableKeepPlaytime(state == Qt::Checked);
|
||||
@ -311,7 +302,6 @@ void CopyInstanceDialog::on_recursiveLinkCheckbox_stateChanged(int state)
|
||||
{
|
||||
m_selectedOptions.enableLinkRecursively(state == Qt::Checked);
|
||||
updateLinkOptions();
|
||||
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_dontLinkSavesCheckbox_stateChanged(int state)
|
||||
|
@ -22,17 +22,15 @@
|
||||
|
||||
class BaseInstance;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class CopyInstanceDialog;
|
||||
}
|
||||
|
||||
class CopyInstanceDialog : public QDialog
|
||||
{
|
||||
class CopyInstanceDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CopyInstanceDialog(InstancePtr original, QWidget *parent = 0);
|
||||
public:
|
||||
explicit CopyInstanceDialog(InstancePtr original, QWidget* parent = 0);
|
||||
~CopyInstanceDialog();
|
||||
|
||||
void updateDialogState();
|
||||
@ -42,13 +40,12 @@ public:
|
||||
QString iconKey() const;
|
||||
const InstanceCopyPrefs& getChosenOptions() const;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void help();
|
||||
|
||||
private
|
||||
slots:
|
||||
private slots:
|
||||
void on_iconButton_clicked();
|
||||
void on_instNameTextBox_textChanged(const QString &arg1);
|
||||
void on_instNameTextBox_textChanged(const QString& arg1);
|
||||
// Checkboxes
|
||||
void on_selectAllCheckbox_stateChanged(int state);
|
||||
void on_copySavesCheckbox_stateChanged(int state);
|
||||
@ -65,14 +62,14 @@ slots:
|
||||
void on_dontLinkSavesCheckbox_stateChanged(int state);
|
||||
void on_useCloneCheckbox_stateChanged(int state);
|
||||
|
||||
private:
|
||||
private:
|
||||
void checkAllCheckboxes(const bool& b);
|
||||
void updateSelectAllCheckbox();
|
||||
void updateUseCloneCheckbox();
|
||||
void updateLinkOptions();
|
||||
|
||||
/* data */
|
||||
Ui::CopyInstanceDialog *ui;
|
||||
Ui::CopyInstanceDialog* ui;
|
||||
QString InstIconKey;
|
||||
InstancePtr m_original;
|
||||
InstanceCopyPrefs m_selectedOptions;
|
||||
|
Loading…
Reference in New Issue
Block a user