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

Function getExecutableForJarFile

src/spawn.cpp:731–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731QString getExecutableForJarFile(const QString& jarFile)
732{
733 const std::wstring jarFileW = jarFile.toStdWString();
734
735 WCHAR buffer[MAX_PATH];
736
737 const auto hinst = ::FindExecutableW(jarFileW.c_str(), nullptr, buffer);
738 const auto r = static_cast<int>(reinterpret_cast<std::uintptr_t>(hinst));
739
740 // anything <= 32 signals failure
741 if (r <= 32) {
742 log::warn("failed to find executable associated with file '{}', {}", jarFile,
743 shell::formatError(r));
744
745 return {};
746 }
747
748 DWORD binaryType = 0;
749
750 if (!::GetBinaryTypeW(buffer, &binaryType)) {
751 const auto e = ::GetLastError();
752
753 log::warn("failed to determine binary type of '{}', {}",
754 QString::fromWCharArray(buffer), formatSystemMessage(e));
755
756 return {};
757 }
758
759 if (binaryType != SCS_32BIT_BINARY && binaryType != SCS_64BIT_BINARY) {
760 log::warn("unexpected binary type {} for file '{}'", binaryType,
761 QString::fromWCharArray(buffer));
762
763 return {};
764 }
765
766 return QString::fromWCharArray(buffer);
767}
768
769QString getJavaHome()
770{

Callers 1

findJavaInstallationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected