Check whether config file exists before trying to create object

fixes #10602
This commit is contained in:
Gunnar Beutner 2015-11-11 10:25:18 +01:00
parent e3c75faabc
commit b2364884d8
1 changed files with 3 additions and 0 deletions

View File

@ -111,6 +111,9 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
String path = GetObjectConfigPath(type, fullName);
Utility::MkDirP(Utility::DirName(path), 0700);
if (Utility::PathExists(path))
BOOST_THROW_EXCEPTION(ScriptError("Configuration file '" + path + "' already exists."));
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
fp << config;
fp.close();