From 6c488a934bde37ffcc1b60fa291340d0bf15efc7 Mon Sep 17 00:00:00 2001
From: gcontini <1121667+gcontini@users.noreply.github.com>
Date: 周日, 13 10月 2019 20:02:13 +0800
Subject: [PATCH] test Linux

---
 src/library/base/FileUtils.cpp |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/library/base/FileUtils.cpp b/src/library/base/FileUtils.cpp
index 55e4fdd..ff79406 100644
--- a/src/library/base/FileUtils.cpp
+++ b/src/library/base/FileUtils.cpp
@@ -42,4 +42,23 @@
 	throw(errno);
 }
 
+string remove_extension(const string& path) {
+	if (path == "." || path == "..") {
+		return path;
+	}
+	size_t dotpos = path.find_last_of(".");
+	//no dot
+	if (dotpos == string::npos) {
+		return path;
+	}
+	//find the last path separator
+	size_t pathsep_pos = path.find_last_of("\\/");
+	if (pathsep_pos == string::npos) {
+		return (dotpos == 0 ? path : path.substr(0, dotpos));
+	} else if(pathsep_pos >= dotpos +1) {
+		return path;
+	} 
+	return path.substr(0, dotpos);
+}
+
 }

--
Gitblit v1.9.1