From 5aa65ee709825ace887340ad1c25b168df956bdd Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Thu, 28 Nov 2013 09:55:20 +0100 Subject: [PATCH] Add check for path existence in conversion API --- lib/converter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/converter.cpp b/lib/converter.cpp index 1dc7362b..114b50ae 100644 --- a/lib/converter.cpp +++ b/lib/converter.cpp @@ -98,6 +98,14 @@ namespace Converter { statusHistory[name] = "No output file supplied"; return; } + struct stat statBuf; + std::string outPath = parameters["output"].asString(); + outPath = outPath.substr(0, outPath.rfind('/')); + int statRes = stat(outPath.c_str(), & statBuf); + if (statRes == -1 || !S_ISDIR(statBuf.st_mode)){ + statusHistory[name] = "Output path is either non-existent, or not a path."; + return; + } if ( !parameters.isMember("encoder")){ statusHistory[name] = "No encoder specified"; return; @@ -261,6 +269,7 @@ namespace Converter { if (allConversions.size()){ for (std::map::iterator cIt = allConversions.begin(); cIt != allConversions.end(); cIt++){ result[cIt->first] = cIt->second["status"]; + result[cIt->first]["details"] = cIt->second; } } if (statusHistory.size()){