From ab2cdfba66bf9e50f3a4a9e535357ef389e7759a Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 15 Sep 2017 11:55:01 +0200
Subject: [PATCH] Add method to check if a directory exists or try to create it
 otherwise.

References issue #7.
---
 AutoTx/AutoTx.cs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs
index f348ef4..cd4e76b 100644
--- a/AutoTx/AutoTx.cs
+++ b/AutoTx/AutoTx.cs
@@ -816,6 +816,19 @@ namespace AutoTx
             return "";
         }
 
+        /// <summary>
+        /// Helper method to check if a directory exists, trying to create it if not.
+        /// </summary>
+        /// <param name="path">The full path of the directory to check / create.</param>
+        /// <returns>True if existing or creation was successful, false otherwise.</returns>
+        private bool CheckForDirectory(string path) {
+            if (string.IsNullOrWhiteSpace(path)) {
+                writeLog("ERROR: CheckForDirectory() parameter must not be empty!");
+                return false;
+            }
+            return CreateNewDirectory(path, false) == path;
+        }
+
         #endregion
 
     }
-- 
GitLab