diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp
index f8f541a048b37ff6aec39ea9e340d2a6068a5996..afb53b5fc9d1205f652206c080f11ba175ce1cb2 100644
--- a/BaseLib/FileTools.cpp
+++ b/BaseLib/FileTools.cpp
@@ -86,6 +86,21 @@ bool hasFileExtension(std::string const& extension, std::string const& filename)
     return boost::iequals(extension, getFileExtension(filename));
 }
 
+std::string copyPathToFileName(const std::string &file_name,
+                               const std::string &source)
+{
+    auto filePath = fs::path(file_name);
+    if(filePath.has_parent_path())
+    {
+        return filePath.string();
+    }
+    else
+    {
+        return fs::path(source) /= filePath;
+    }
+
+}
+
 std::string extractPath(std::string const& pathname)
 {
     return fs::path(pathname).parent_path();
diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h
index 01168d254bc4173474b6e1fdce4e080bdffb5104..daf67284e3971cbb4ccefe0e40470ca1223da07e 100644
--- a/BaseLib/FileTools.h
+++ b/BaseLib/FileTools.h
@@ -136,6 +136,13 @@ std::string getFileExtension(std::string const& path);
 bool hasFileExtension(std::string const& extension,
                       std::string const& filename);
 
+/**
+ * Checks if file_name already contains a qualified path and if not copies the
+ * path from source.
+ */
+std::string copyPathToFileName(const std::string &file_name,
+                               const std::string &source);
+
 /** Returns a string with file extension as found by getFileExtension()
  * dropped.
  */
diff --git a/Tests/BaseLib/TestFilePathStringManipulation.cpp b/Tests/BaseLib/TestFilePathStringManipulation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d1014f57d9c04aa2f6cf3cd8feb95bce9b3f4fe2
--- /dev/null
+++ b/Tests/BaseLib/TestFilePathStringManipulation.cpp
@@ -0,0 +1,46 @@
+/**
+ * \file
+ * \author
+ * \date
+ * \brief
+ *
+ * \copyright
+ * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ */
+
+#include "gtest/gtest.h"
+
+#include "BaseLib/FileTools.h"
+
+#ifdef WIN32
+TEST(BaseLib, CopyPathToFileNameWin)
+{
+    ASSERT_EQ("extend\\file", BaseLib::copyPathToFileName("file", "extend"));
+    ASSERT_EQ("path\\file",
+              BaseLib::copyPathToFileName("path\\file", "extend"));
+    ASSERT_EQ("extend\\file", BaseLib::copyPathToFileName("file", "extend\\"));
+    ASSERT_EQ("path\\file",
+              BaseLib::copyPathToFileName("path\\file", "extend\\"));
+    ASSERT_EQ("extend\\smth\\file",
+              BaseLib::copyPathToFileName("file", "extend\\smth"));
+    ASSERT_EQ("path\\file",
+              BaseLib::copyPathToFileName("path\\file", "extend\\smth"));
+}
+#else
+TEST(BaseLib, CopyPathToFileNameUnix)
+{
+    ASSERT_EQ("extend/file", BaseLib::copyPathToFileName("file", "extend"));
+    ASSERT_EQ("path/file",
+              BaseLib::copyPathToFileName("path/file", "extend"));
+    ASSERT_EQ("extend/file", BaseLib::copyPathToFileName("file", "extend/"));
+    ASSERT_EQ("path/file", BaseLib::copyPathToFileName("path/file", "extend/"));
+
+    ASSERT_EQ("extend/smth/file",
+              BaseLib::copyPathToFileName("file", "extend/smth"));
+    ASSERT_EQ("path/file",
+              BaseLib::copyPathToFileName("path/file", "extend/smth"));
+}
+#endif