Add prototype for binary directory functions
This commit is contained in:
+25
-7
@@ -1,19 +1,37 @@
|
||||
#include "paths.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <easylogging++.h>
|
||||
|
||||
namespace paths
|
||||
{
|
||||
optional<string> binaryDirectory()
|
||||
{
|
||||
const auto binaryDir
|
||||
const auto path
|
||||
= QStandardPaths::writableLocation( QStandardPaths::AppDataLocation );
|
||||
|
||||
if ( binaryDir != "" )
|
||||
if ( path == "" )
|
||||
{
|
||||
return binaryDir.toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
LOG( ERROR ) << "Could not find binary directory.";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return path.toStdString();
|
||||
}
|
||||
|
||||
optional<string> binaryDirectoryFindFile( const string fileName )
|
||||
{
|
||||
const auto path = QStandardPaths::locate(
|
||||
QStandardPaths::AppDataLocation, QString::fromStdString( fileName ) );
|
||||
|
||||
if ( path == "" )
|
||||
{
|
||||
LOG( ERROR ) << "Could not find file '" << fileName
|
||||
<< "' in binary directory.";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return path.toStdString();
|
||||
}
|
||||
|
||||
} // namespace paths
|
||||
|
||||
Reference in New Issue
Block a user