Использование функций Qt для временного и домашнего каталогов

This commit is contained in:
Andrei Astafev 2020-04-13 09:31:51 +03:00
parent 7c2e583cb7
commit 940d1361df

View File

@ -140,17 +140,13 @@ Paths::HierarchyType Paths::getHierarchyType()
bool Paths::init( const QString& projectDir, const QString& configFileExtension ) bool Paths::init( const QString& projectDir, const QString& configFileExtension )
{ {
m_projectName = projectDir.isEmpty() ? m_currentExecutable.m_canonicalFilePath.fileName() m_projectName = projectDir.isEmpty() ? m_currentExecutable.m_canonicalFilePath.fileName()
: projectDir; : projectDir;
m_configFileExtension = configFileExtension.isEmpty() ? QStringLiteral( "conf" ) m_configFileExtension = configFileExtension.isEmpty() ? QStringLiteral( "conf" )
: configFileExtension; : configFileExtension;
m_configFileName = m_projectName + "." + m_configFileExtension; m_configFileName = m_projectName + "." + m_configFileExtension;
m_homeDirectory = QString::fromLocal8Bit( qgetenv( "HOME" ) ); m_homeDirectory = QDir::homePath();
m_tempDirectory = QString::fromLocal8Bit( qgetenv( "TMPDIR" ) ); m_tempDirectory = QDir::tempPath();
if ( !m_tempDirectory.exists() || ( m_tempDirectory.path() == QStringLiteral( "." ) ) )
{
m_tempDirectory = QStringLiteral( _PATH_TMP );
}
auto configHome = QString::fromLocal8Bit( qgetenv( "XDG_CONFIG_HOME" ) ); auto configHome = QString::fromLocal8Bit( qgetenv( "XDG_CONFIG_HOME" ) );
if ( configHome.isEmpty() ) if ( configHome.isEmpty() )