Упрощение и правка автоопределения в /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 { namespace filesystem {
MYXLIB_INLINE Paths::Paths() : MYXLIB_INLINE Paths::Paths() :
m_binDirRegex ( "/s*bin$" ), m_binDirRegex ( QStringLiteral( "/s*bin$" ) ),
m_unityBinDirRegex( "/bin/unity$" ) m_unityBinDirRegex( QStringLiteral( "/bin/unity$" ) )
{ {
QFileInfo procSelfExe( QStringLiteral( "/proc/self/exe" ) ); QFileInfo procSelfExe( QStringLiteral( "/proc/self/exe" ) );
QFileInfo currentExecutable = procSelfExe.canonicalFilePath(); QFileInfo currentExecutable = procSelfExe.canonicalFilePath();
@ -211,11 +211,11 @@ MYXLIB_INLINE void Paths::calculatePaths( HierarchyType hType )
break; break;
case HierarchyType::kHome: case HierarchyType::kHome:
m_projectDirectory = m_homeDirectory; setupSystemDirectories( m_homeDirectory,
m_systemConfigDirectory = m_userConfigDirectory; m_userConfigDirectory,
m_systemConstDataDirectory = m_userConstDataDirectory; m_userConstDataDirectory,
m_systemVarDataDirectory = m_userVarDataDirectory; m_userVarDataDirectory,
m_systemLogDirectory = m_userLogDirectory; m_userLogDirectory );
break; break;
case HierarchyType::kDevelopment: case HierarchyType::kDevelopment:
@ -241,30 +241,29 @@ MYXLIB_INLINE void Paths::processOptHierarhy()
if ( m_autodetect ) if ( m_autodetect )
{ {
QRegularExpression regex( "^/opt/(.+?)-(.+?)/(.+?)/" ); QRegularExpression regex( QStringLiteral( "^/opt/(.+?)/(.+?)/" ) );
QRegularExpressionMatch match = regex.match( m_executableDirectory ); QRegularExpressionMatch match = regex.match( m_executableDirectory );
if ( match.hasMatch() ) if ( match.hasMatch() )
{ {
m_organizationName = match.captured( 1 ); m_organizationName = match.captured( 1 );
m_themeName = match.captured( 2 ); m_projectName = match.captured( 2 );
m_projectName = match.captured( 3 );
QRegularExpression vr( "(.+?)\\.(.+)" ); QRegularExpression themeRegex( QStringLiteral( "(.+?)-(.+)" ) );
QRegularExpressionMatch vm = vr.match( m_themeName ); QRegularExpressionMatch themeMatch = themeRegex.match( m_organizationName );
if ( vm.hasMatch() ) if ( themeMatch.hasMatch() )
{ {
m_themeName = vm.captured( 1 ); m_themeName = themeMatch.captured( 2 );
m_version = vm.captured( 2 ); m_organizationName = themeMatch.captured( 1 );
m_systemThemeDirectory = "/opt/" + m_organizationName + "-" + m_themeName;
} }
}
else QRegularExpression versionRegex( QStringLiteral( "(.+?)\\.(.+)" ) );
{ QRegularExpressionMatch versionMatch = versionRegex.match( m_projectName );
regex.setPattern( "^/opt/(.+?)/(.+?)/" ); if ( versionMatch.hasMatch() )
match = regex.match( m_executableDirectory );
if ( match.hasMatch() )
{ {
m_organizationName = match.captured( 1 ); m_projectName = versionMatch.captured( 1 );
m_projectName = match.captured( 2 ); m_version = versionMatch.captured( 2 );
} }
} }
} }