Browse code

Fixed getting the path of the filename for XSFFile.

Naram Qashat authored on 2013/03/26 06:58:50
Showing 2 changed files
... ...
@@ -45,6 +45,15 @@ template<typename T> inline std::basic_string<T> ExtractDirectoryFromPath(const
45 45
 	return lastSlash != std::basic_string<T>::npos ? fullPath.substr(0, lastSlash + 1) : std::basic_string<T>();
46 46
 }
47 47
 
48
+// This gets the filename for the path
49
+template<typename T> inline std::basic_string<T> ExtractFilenameFromPath(const std::basic_string<T> &fullPath)
50
+{
51
+	size_t lastSlash = fullPath.rfind('\\');
52
+	if (lastSlash == std::basic_string<T>::npos)
53
+		lastSlash = fullPath.rfind('/');
54
+	return lastSlash != std::basic_string<T>::npos ? fullPath.substr(lastSlash + 1) : std::basic_string<T>();
55
+}
56
+
48 57
 // Code from the following answer on Stack Overflow:
49 58
 // http://stackoverflow.com/a/15479212
50 59
 template<typename T> static inline T NextHighestPowerOf2(T value)
... ...
@@ -447,7 +447,7 @@ String XSFFile::GetFilename() const
447 447
 
448 448
 String XSFFile::GetFilenameWithoutPath() const
449 449
 {
450
-	return ExtractDirectoryFromPath(this->fileName.GetStr());
450
+	return ExtractFilenameFromPath(this->fileName.GetStr());
451 451
 }
452 452
 
453 453
 void XSFFile::SaveFile() const