Упрощение и правка автоопределения в /opt

This commit is contained in:
Andrei Astafev 2021-06-11 08:21:00 +03:00
parent 360b2b41d1
commit a29cea6f61

View File

@ -14,8 +14,8 @@ namespace myx {
namespace filesystem {
MYXLIB_INLINE Paths::Paths() :
m_binDirRegex ( "/s*bin$" ),
m_unityBinDirRegex( "/bin/unity$" )
m_binDirRegex ( QStringLiteral( "/s*bin$" ) ),
m_unityBinDirRegex( QStringLiteral( "/bin/unity$" ) )
{
QFileInfo procSelfExe( QStringLiteral( "/proc/self/exe" ) );
QFileInfo currentExecutable = procSelfExe.canonicalFilePath();
@ -211,11 +211,11 @@ MYXLIB_INLINE void Paths::calculatePaths( HierarchyType hType )
break;
case HierarchyType::kHome:
m_projectDirectory = m_homeDirectory;
m_systemConfigDirectory = m_userConfigDirectory;
m_systemConstDataDirectory = m_userConstDataDirectory;
m_systemVarDataDirectory = m_userVarDataDirectory;
m_systemLogDirectory = m_userLogDirectory;
setupSystemDirectories( m_homeDirectory,
m_userConfigDirectory,
m_userConstDataDirectory,
m_userVarDataDirectory,
m_userLogDirectory );
break;
case HierarchyType::kDevelopment:
@ -241,30 +241,29 @@ MYXLIB_INLINE void Paths::processOptHierarhy()
if ( m_autodetect )
{
QRegularExpression regex( "^/opt/(.+?)-(.+?)/(.+?)/" );
QRegularExpression regex( QStringLiteral( "^/opt/(.+?)/(.+?)/" ) );
QRegularExpressionMatch match = regex.match( m_executableDirectory );
if ( match.hasMatch() )
{
m_organizationName = match.captured( 1 );
m_themeName = match.captured( 2 );
m_projectName = match.captured( 3 );
QRegularExpression vr( "(.+?)\\.(.+)" );
QRegularExpressionMatch vm = vr.match( m_themeName );
if ( vm.hasMatch() )
{
m_themeName = vm.captured( 1 );
m_version = vm.captured( 2 );
}
}
else
{
regex.setPattern( "^/opt/(.+?)/(.+?)/" );
match = regex.match( m_executableDirectory );
if ( match.hasMatch() )
{
m_organizationName = match.captured( 1 );
m_projectName = match.captured( 2 );
QRegularExpression themeRegex( QStringLiteral( "(.+?)-(.+)" ) );
QRegularExpressionMatch themeMatch = themeRegex.match( m_organizationName );
if ( themeMatch.hasMatch() )
{
m_themeName = themeMatch.captured( 2 );
m_organizationName = themeMatch.captured( 1 );
m_systemThemeDirectory = "/opt/" + m_organizationName + "-" + m_themeName;
}
QRegularExpression versionRegex( QStringLiteral( "(.+?)\\.(.+)" ) );
QRegularExpressionMatch versionMatch = versionRegex.match( m_projectName );
if ( versionMatch.hasMatch() )
{
m_projectName = versionMatch.captured( 1 );
m_version = versionMatch.captured( 2 );
}
}
}