diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index fd958b2..0275c31 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -1,19 +1,37 @@ #include "paths.h" #include +#include +#include + namespace paths { optional 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 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