From a29cea6f61941af4d147a2d83bdd5d50500cb294 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 11 Jun 2021 08:21:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20/opt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/myx/filesystem/paths.cpp | 45 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/myx/filesystem/paths.cpp b/src/myx/filesystem/paths.cpp index 59b912b..8b99f42 100644 --- a/src/myx/filesystem/paths.cpp +++ b/src/myx/filesystem/paths.cpp @@ -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 ); + m_projectName = match.captured( 2 ); - QRegularExpression vr( "(.+?)\\.(.+)" ); - QRegularExpressionMatch vm = vr.match( m_themeName ); - if ( vm.hasMatch() ) + QRegularExpression themeRegex( QStringLiteral( "(.+?)-(.+)" ) ); + QRegularExpressionMatch themeMatch = themeRegex.match( m_organizationName ); + if ( themeMatch.hasMatch() ) { - m_themeName = vm.captured( 1 ); - m_version = vm.captured( 2 ); + m_themeName = themeMatch.captured( 2 ); + m_organizationName = themeMatch.captured( 1 ); + m_systemThemeDirectory = "/opt/" + m_organizationName + "-" + m_themeName; } - } - else - { - regex.setPattern( "^/opt/(.+?)/(.+?)/" ); - match = regex.match( m_executableDirectory ); - if ( match.hasMatch() ) + + QRegularExpression versionRegex( QStringLiteral( "(.+?)\\.(.+)" ) ); + QRegularExpressionMatch versionMatch = versionRegex.match( m_projectName ); + if ( versionMatch.hasMatch() ) { - m_organizationName = match.captured( 1 ); - m_projectName = match.captured( 2 ); + m_projectName = versionMatch.captured( 1 ); + m_version = versionMatch.captured( 2 ); } } }