Compare commits

..

No commits in common. "a29cea6f61941af4d147a2d83bdd5d50500cb294" and "297b04bd565bc034159d35d9c1d55da1b306e381" have entirely different histories.

2 changed files with 47 additions and 46 deletions

View File

@ -14,8 +14,8 @@ namespace myx {
namespace filesystem { namespace filesystem {
MYXLIB_INLINE Paths::Paths() : MYXLIB_INLINE Paths::Paths() :
m_binDirRegex ( QStringLiteral( "/s*bin$" ) ), m_binDirRegex ( "/s*bin$" ),
m_unityBinDirRegex( QStringLiteral( "/bin/unity$" ) ) m_unityBinDirRegex( "/bin/unity$" )
{ {
QFileInfo procSelfExe( QStringLiteral( "/proc/self/exe" ) ); QFileInfo procSelfExe( QStringLiteral( "/proc/self/exe" ) );
QFileInfo currentExecutable = procSelfExe.canonicalFilePath(); QFileInfo currentExecutable = procSelfExe.canonicalFilePath();
@ -54,56 +54,56 @@ MYXLIB_INLINE bool Paths::init( bool autodetect )
} // Paths::init } // Paths::init
MYXLIB_INLINE void Paths::setupSystemDirectories( const QString& projectDir, MYXLIB_INLINE void Paths::setupSystemDirectories( const QString& defaultProjectDirectory,
const QString& etcDir, const QString& defaultEtcDirectory,
const QString& constDataDir, const QString& defaultConstDataDirectory,
const QString& varDataDir, const QString& defaultVarDataDirectory,
const QString& logDir ) const QString& defaultLogDirectory )
{ {
QFileInfo prefixDirInfo { projectDir }; QFileInfo prefixDirInfo { defaultProjectDirectory };
if ( prefixDirInfo.isDir() && prefixDirInfo.isReadable() ) if ( prefixDirInfo.isDir() && prefixDirInfo.isReadable() )
{ {
m_projectDirectory = projectDir; m_projectDirectory = defaultProjectDirectory;
} }
else else
{ {
m_projectDirectory = QStringLiteral( "." ); m_projectDirectory = QStringLiteral( "." );
} }
QFileInfo etcDirInfo { etcDir }; QFileInfo etcDirInfo { defaultEtcDirectory };
if ( etcDirInfo.isDir() && etcDirInfo.isReadable() ) if ( etcDirInfo.isDir() && etcDirInfo.isReadable() )
{ {
m_systemConfigDirectory = etcDir; m_systemConfigDirectory = defaultEtcDirectory;
} }
else else
{ {
m_systemConfigDirectory = m_userConfigDirectory; m_systemConfigDirectory = m_userConfigDirectory;
} }
QFileInfo constDataDirInfo { constDataDir }; QFileInfo constDataDirInfo { defaultConstDataDirectory };
if ( constDataDirInfo.isDir() && constDataDirInfo.isReadable() ) if ( constDataDirInfo.isDir() && constDataDirInfo.isReadable() )
{ {
m_systemConstDataDirectory = constDataDir; m_systemConstDataDirectory = defaultConstDataDirectory;
} }
else else
{ {
m_systemConstDataDirectory = m_userConstDataDirectory; m_systemConstDataDirectory = m_userConstDataDirectory;
} }
QFileInfo varDataDirInfo { varDataDir }; QFileInfo varDataDirInfo { defaultVarDataDirectory };
if ( varDataDirInfo.isDir() && varDataDirInfo.isWritable() ) if ( varDataDirInfo.isDir() && varDataDirInfo.isWritable() )
{ {
m_systemVarDataDirectory = varDataDir; m_systemVarDataDirectory = defaultVarDataDirectory;
} }
else else
{ {
m_systemVarDataDirectory = m_userVarDataDirectory; m_systemVarDataDirectory = m_userVarDataDirectory;
} }
QFileInfo logDirInfo { logDir }; QFileInfo logDirInfo { defaultLogDirectory };
if ( logDirInfo.isDir() && logDirInfo.isWritable() ) if ( logDirInfo.isDir() && logDirInfo.isWritable() )
{ {
m_systemLogDirectory = logDir; m_systemLogDirectory = defaultLogDirectory;
} }
else else
{ {
@ -211,11 +211,11 @@ MYXLIB_INLINE void Paths::calculatePaths( HierarchyType hType )
break; break;
case HierarchyType::kHome: case HierarchyType::kHome:
setupSystemDirectories( m_homeDirectory, m_projectDirectory = m_homeDirectory;
m_userConfigDirectory, m_systemConfigDirectory = m_userConfigDirectory;
m_userConstDataDirectory, m_systemConstDataDirectory = m_userConstDataDirectory;
m_userVarDataDirectory, m_systemVarDataDirectory = m_userVarDataDirectory;
m_userLogDirectory ); m_systemLogDirectory = m_userLogDirectory;
break; break;
case HierarchyType::kDevelopment: case HierarchyType::kDevelopment:
@ -241,29 +241,30 @@ MYXLIB_INLINE void Paths::processOptHierarhy()
if ( m_autodetect ) if ( m_autodetect )
{ {
QRegularExpression regex( QStringLiteral( "^/opt/(.+?)/(.+?)/" ) ); QRegularExpression regex( "^/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_projectName = match.captured( 2 ); m_themeName = match.captured( 2 );
m_projectName = match.captured( 3 );
QRegularExpression themeRegex( QStringLiteral( "(.+?)-(.+)" ) ); QRegularExpression vr( "(.+?)\\.(.+)" );
QRegularExpressionMatch themeMatch = themeRegex.match( m_organizationName ); QRegularExpressionMatch vm = vr.match( m_themeName );
if ( themeMatch.hasMatch() ) if ( vm.hasMatch() )
{ {
m_themeName = themeMatch.captured( 2 ); m_themeName = vm.captured( 1 );
m_organizationName = themeMatch.captured( 1 ); m_version = vm.captured( 2 );
m_systemThemeDirectory = "/opt/" + m_organizationName + "-" + m_themeName;
} }
}
QRegularExpression versionRegex( QStringLiteral( "(.+?)\\.(.+)" ) ); else
QRegularExpressionMatch versionMatch = versionRegex.match( m_projectName ); {
if ( versionMatch.hasMatch() ) regex.setPattern( "^/opt/(.+?)/(.+?)/" );
match = regex.match( m_executableDirectory );
if ( match.hasMatch() )
{ {
m_projectName = versionMatch.captured( 1 ); m_organizationName = match.captured( 1 );
m_version = versionMatch.captured( 2 ); m_projectName = match.captured( 2 );
} }
} }
} }
@ -283,10 +284,10 @@ MYXLIB_INLINE bool Paths::makeDefaultSystemDirectories()
bool status = true; bool status = true;
QDir dir; QDir dir;
if ( !dir.mkpath( m_systemConstDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_systemLogDirectory ) ) { status = false; }
if ( !dir.mkpath( m_systemConfigDirectory ) ) { status = false; } if ( !dir.mkpath( m_systemConfigDirectory ) ) { status = false; }
if ( !dir.mkpath( m_systemVarDataDirectory ) ) { status = false; } if ( !dir.mkpath( m_systemVarDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_systemConstDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_systemLogDirectory ) ) { status = false; }
return( status ); return( status );
} }
@ -297,10 +298,10 @@ MYXLIB_INLINE bool Paths::makeDefaultUserDirectories()
bool status = true; bool status = true;
QDir dir; QDir dir;
if ( !dir.mkpath( m_userConstDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_userLogDirectory ) ) { status = false; }
if ( !dir.mkpath( m_userConfigDirectory ) ) { status = false; } if ( !dir.mkpath( m_userConfigDirectory ) ) { status = false; }
if ( !dir.mkpath( m_userVarDataDirectory ) ) { status = false; } if ( !dir.mkpath( m_userVarDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_userConstDataDirectory ) ) { status = false; }
if ( !dir.mkpath( m_userLogDirectory ) ) { status = false; }
return( status ); return( status );
} }

View File

@ -208,11 +208,11 @@ private:
QRegularExpression m_binDirRegex; QRegularExpression m_binDirRegex;
QRegularExpression m_unityBinDirRegex; QRegularExpression m_unityBinDirRegex;
void setupSystemDirectories( const QString& projectDir, void setupSystemDirectories( const QString& defaultProjectDirectory,
const QString& etcDir, const QString& defaultEtcDirectory,
const QString& constDataDir, const QString& defaultConstDataDirectory,
const QString& varDataDir, const QString& defaultVarDataDirectory,
const QString& logDir ); const QString& defaultLogDirectory );
void setupUserDirectories(); void setupUserDirectories();
HierarchyType getHierarchyType(); HierarchyType getHierarchyType();