From ed2c01405f5a5b913c4fd64397394559051e041a Mon Sep 17 00:00:00 2001 From: James Burkle Date: Thu, 23 Jun 2011 23:43:26 -0400 Subject: [PATCH] Edited init.cpp to include a check that -datadir exists --- src/init.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index a0c90e0a7a..ebe176a5e4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -141,10 +141,19 @@ bool AppInit2(int argc, char* argv[]) if (mapArgs.count("-datadir")) { - filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]); - strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir)); + if (filesystem::is_directory(filesystem::system_complete(mapArgs["-datadir"]))) + { + filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]); + strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir)); + } + else + { + fprintf(stderr, "Error: Specified directory does not exist\n"); + Shutdown(NULL); + } } + ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir if (mapArgs.count("-?") || mapArgs.count("--help"))