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