From 52fc71530116c57ad82f4892aceb1b1358da5752 Mon Sep 17 00:00:00 2001
From: Dmitrij Naumov <dmitrij@naumov.de>
Date: Tue, 30 Oct 2012 23:26:28 +0100
Subject: [PATCH] Correct extractPath.

---
 BaseLib/FileTools.cpp | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp
index 2146cfb8e75..dbece13df5f 100644
--- a/BaseLib/FileTools.cpp
+++ b/BaseLib/FileTools.cpp
@@ -108,14 +108,8 @@ std::string copyPathToFileName(const std::string &file_name, const std::string &
 
 std::string extractPath(std::string const& pathname)
 {
-	// extract path for reading external files
-	size_t pos(pathname.rfind("/")); // linux, mac delimiter
-	if (pos == std::string::npos) {
-		pos = pathname.rfind("\\"); // windows delimiter
-		if (pos == std::string::npos)
-			pos = 0;
-	}
-	return pathname.substr(0, pos==0 ? pos : pos + 1);
+	const size_t pos = findLastPathSeparator(pathname);
+	return pathname.substr(0, pos + 1);
 }
 
 } // end namespace BaseLib
-- 
GitLab