Change binary dir to be binary dir for all OS
Linux did not see AppDataLocation as the binary directory, but as an arbitrary dir in the home folder.
This commit is contained in:
+16
-24
@@ -1,5 +1,6 @@
|
|||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <easylogging++.h>
|
#include <easylogging++.h>
|
||||||
@@ -8,8 +9,8 @@ namespace paths
|
|||||||
{
|
{
|
||||||
optional<string> binaryDirectory()
|
optional<string> binaryDirectory()
|
||||||
{
|
{
|
||||||
const auto path
|
const auto path = QCoreApplication::applicationDirPath();
|
||||||
= QStandardPaths::writableLocation( QStandardPaths::AppDataLocation );
|
|
||||||
if ( path == "" )
|
if ( path == "" )
|
||||||
{
|
{
|
||||||
LOG( ERROR ) << "Could not find binary directory.";
|
LOG( ERROR ) << "Could not find binary directory.";
|
||||||
@@ -21,34 +22,25 @@ optional<string> binaryDirectory()
|
|||||||
|
|
||||||
optional<string> binaryDirectoryFindFile( const string fileName )
|
optional<string> binaryDirectoryFindFile( const string fileName )
|
||||||
{
|
{
|
||||||
const auto path
|
const auto path = binaryDirectory();
|
||||||
= QStandardPaths::locate( QStandardPaths::AppDataLocation,
|
|
||||||
QString::fromStdString( fileName ),
|
if ( !path )
|
||||||
QStandardPaths::LocateFile );
|
{
|
||||||
if ( path == "" )
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto filePath = QString::fromStdString( *path ) + "/"
|
||||||
|
+ QString::fromStdString( fileName );
|
||||||
|
QFileInfo file( filePath );
|
||||||
|
|
||||||
|
if ( !file.exists() )
|
||||||
{
|
{
|
||||||
LOG( ERROR ) << "Could not find file '" << fileName.c_str()
|
LOG( ERROR ) << "Could not find file '" << fileName.c_str()
|
||||||
<< "' in binary directory.";
|
<< "' in binary directory.";
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.toStdString();
|
return filePath.toStdString();
|
||||||
}
|
|
||||||
|
|
||||||
optional<string> binaryDirectoryFindDirectory( const string directoryName )
|
|
||||||
{
|
|
||||||
const auto path
|
|
||||||
= QStandardPaths::locate( QStandardPaths::AppDataLocation,
|
|
||||||
QString::fromStdString( directoryName ),
|
|
||||||
QStandardPaths::LocateDirectory );
|
|
||||||
if ( path == "" )
|
|
||||||
{
|
|
||||||
LOG( ERROR ) << "Could not find directory '" << directoryName.c_str()
|
|
||||||
<< "' in binary directory.";
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return path.toStdString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<string> settingsDirectory()
|
optional<string> settingsDirectory()
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using std::string;
|
|||||||
|
|
||||||
optional<string> binaryDirectory();
|
optional<string> binaryDirectory();
|
||||||
optional<string> binaryDirectoryFindFile( string fileName );
|
optional<string> binaryDirectoryFindFile( string fileName );
|
||||||
optional<string> binaryDirectoryFindDirectory( string directoryName );
|
|
||||||
|
|
||||||
optional<string> settingsDirectory();
|
optional<string> settingsDirectory();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user