From 14587a22d7a4750bc77f41d1990cd41fe790257f Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Mon, 15 Sep 2014 14:37:09 +0200
Subject: [PATCH] ENH: Mantis-764: check output directory for
 OutputFilenameParameter

---
 .../CommandLine/otbWrapperCommandLineLauncher.cxx | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx
index ceabee8d46..4ae5f6aa59 100644
--- a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx
+++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx
@@ -628,6 +628,21 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
           }
         }
       }
+
+    // Check output paths validity
+    if (hasValue)
+      {
+      if (type == ParameterType_OutputFilename)
+        {
+        std::string filename = m_Application->GetParameterString(paramKey);
+        itksys::String path = itksys::SystemTools::GetFilenamePath(filename);
+        if (!itksys::SystemTools::FileIsDirectory(path.c_str()))
+          {
+          std::cerr <<"ERROR: Directory doesn't exist : "<< path.c_str() << std::endl;
+          return WRONGPARAMETERVALUE;
+          }
+        }
+      }
     }
 
   return OKPARAM;
-- 
GitLab