mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
Return zero if settings file cannot be opened
This commit is contained in:
parent
c133e230d7
commit
ddd0dcc301
@ -24,6 +24,7 @@
|
||||
#include "Interface/File.h"
|
||||
|
||||
CFileSettingsReader::CFileSettingsReader(std::string pFile)
|
||||
: has_error(false)
|
||||
{
|
||||
read(pFile);
|
||||
}
|
||||
@ -54,11 +55,17 @@ std::vector<std::string> CFileSettingsReader::getKeys()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CFileSettingsReader::hasError()
|
||||
{
|
||||
return has_error;
|
||||
}
|
||||
|
||||
void CFileSettingsReader::read(const std::string& pFile )
|
||||
{
|
||||
std::auto_ptr<IFile> file(Server->openFile(pFile));
|
||||
if (file.get() == NULL)
|
||||
{
|
||||
has_error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -13,10 +13,14 @@ public:
|
||||
|
||||
virtual std::vector<std::string> getKeys();
|
||||
|
||||
bool hasError();
|
||||
|
||||
private:
|
||||
|
||||
void read(const std::string& pFile);
|
||||
|
||||
std::map<std::string, std::string> mSettingsMap;
|
||||
|
||||
bool has_error;
|
||||
};
|
||||
|
||||
|
||||
@ -1393,7 +1393,13 @@ IThreadPool *CServer::getThreadPool(void)
|
||||
|
||||
ISettingsReader* CServer::createFileSettingsReader(const std::string& pFile)
|
||||
{
|
||||
return new CFileSettingsReader(pFile);
|
||||
CFileSettingsReader* ret = new CFileSettingsReader(pFile);
|
||||
if (ret->hasError())
|
||||
{
|
||||
delete ret;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ISettingsReader* CServer::createDBSettingsReader(THREAD_ID tid, DATABASE_ID pIdentifier, const std::string &pTable, const std::string &pSQL)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user