MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / runPrivileged

Method runPrivileged

launcher/FileSystem.cpp:504–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504void create_link::runPrivileged(const QString& offset)
505{
506 m_linked = 0; // reset counter
507 m_path_results.clear();
508 m_links_to_make.clear();
509
510 bool gotResults = false;
511
512 make_link_list(offset);
513
514 QString serverName = BuildConfig.LAUNCHER_APP_BINARY_NAME + "_filelink_server" + StringUtils::getRandomAlphaNumeric();
515
516 connect(&m_linkServer, &QLocalServer::newConnection, this, [this, &gotResults]() {
517 qDebug() << "Client connected, sending out pairs";
518 // construct block of data to send
519 QByteArray block;
520 QDataStream out(&block, QIODevice::WriteOnly);
521
522 qint32 blocksize = quint32(sizeof(quint32));
523 for (auto link : m_links_to_make) {
524 blocksize += quint32(link.src.size());
525 blocksize += quint32(link.dst.size());
526 }
527 qDebug() << "About to write block of size:" << blocksize;
528 out << blocksize;
529
530 out << quint32(m_links_to_make.length());
531 for (auto link : m_links_to_make) {
532 out << link.src;
533 out << link.dst;
534 }
535
536 QLocalSocket* clientConnection = m_linkServer.nextPendingConnection();
537 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
538
539 connect(clientConnection, &QLocalSocket::readyRead, this, [&, clientConnection]() {
540 QDataStream in;
541 quint32 blockSize = 0;
542 in.setDevice(clientConnection);
543
544 qDebug() << "Reading path results from client";
545 qDebug() << "bytes available" << clientConnection->bytesAvailable();
546
547 // Relies on the fact that QDataStream serializes a quint32 into
548 // sizeof(quint32) bytes
549 if (clientConnection->bytesAvailable() < (int)sizeof(quint32))
550 return;
551 qDebug() << "reading block size";
552 in >> blockSize;
553
554 qDebug() << "blocksize is" << blockSize;
555 qDebug() << "bytes available" << clientConnection->bytesAvailable();
556 if (clientConnection->bytesAvailable() < blockSize || in.atEnd())
557 return;
558
559 quint32 numResults;
560 in >> numResults;
561 qDebug() << "numResults" << numResults;

Callers 2

executeTaskMethod · 0.45
executeTaskMethod · 0.45

Calls 9

appendMethod · 0.80
listenMethod · 0.80
errorStringMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
startMethod · 0.45

Tested by 1

executeTaskMethod · 0.36