From ac4a12445036d30d062f565c2caa74479cf676cc Mon Sep 17 00:00:00 2001 From: Vasily Date: Sun, 17 Mar 2019 12:10:58 +0100 Subject: [PATCH] Add prototype for binary directory functions --- src/utils/paths.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) 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