MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / splitExeAndArguments

Function splitExeAndArguments

src/env.cpp:735–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

733}
734
735std::pair<QString, QString> splitExeAndArguments(const QString& cmd)
736{
737 int exeBegin = 0;
738 int exeEnd = -1;
739
740 if (cmd[0] == '"') {
741 // surrounded by double-quotes, so find the next one
742 exeBegin = 1;
743 exeEnd = cmd.indexOf('"', exeBegin);
744
745 if (exeEnd == -1) {
746 log::error("missing terminating double-quote in command line '{}'", cmd);
747 return {};
748 }
749 } else {
750 // no double-quotes, find the first whitespace
751 exeEnd = cmd.indexOf(QRegularExpression("\\s"));
752 if (exeEnd == -1) {
753 exeEnd = cmd.size();
754 }
755 }
756
757 QString exe = cmd.mid(exeBegin, exeEnd - exeBegin).trimmed();
758 QString args = cmd.mid(exeEnd + 1).trimmed();
759
760 return {std::move(exe), std::move(args)};
761}
762
763Association getAssociation(const QFileInfo& targetInfo)
764{

Callers 1

getAssociationFunction · 0.85

Calls 2

indexOfMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected