GH-1262 fix relative paths for java binaries
This commit is contained in:
@ -25,6 +25,18 @@ MULTIMC_UTIL_EXPORT QString PathCombine(QString path1, QString path2, QString pa
|
||||
|
||||
MULTIMC_UTIL_EXPORT QString AbsolutePath(QString path);
|
||||
|
||||
/**
|
||||
* Resolve an executable
|
||||
*
|
||||
* Will resolve:
|
||||
* single executable (by name)
|
||||
* relative path
|
||||
* absolute path
|
||||
*
|
||||
* @return absolute path to executable or null string
|
||||
*/
|
||||
MULTIMC_UTIL_EXPORT QString ResolveExecutable(QString path);
|
||||
|
||||
/**
|
||||
* Normalize path
|
||||
*
|
||||
@ -33,7 +45,7 @@ MULTIMC_UTIL_EXPORT QString AbsolutePath(QString path);
|
||||
*
|
||||
* Returns false if the path logic somehow filed (and normalizedPath in invalid)
|
||||
*/
|
||||
QString NormalizePath(QString path);
|
||||
MULTIMC_UTIL_EXPORT QString NormalizePath(QString path);
|
||||
|
||||
MULTIMC_UTIL_EXPORT QString RemoveInvalidFilenameChars(QString string, QChar replaceWith = '-');
|
||||
|
||||
|
@ -40,6 +40,24 @@ QString AbsolutePath(QString path)
|
||||
return QFileInfo(path).absolutePath();
|
||||
}
|
||||
|
||||
QString ResolveExecutable(QString path)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
if(!path.contains('/'))
|
||||
{
|
||||
path = QStandardPaths::findExecutable(path);
|
||||
}
|
||||
QFileInfo pathInfo(path);
|
||||
if(!pathInfo.exists() || !pathInfo.isExecutable())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
return pathInfo.absoluteFilePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize path
|
||||
*
|
||||
|
Reference in New Issue
Block a user