diff dep/animia/src/util.cc @ 152:8700806c2cc2

dep/animia: awesome new breaking changes! I'm so tired
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 02:34:59 -0500
parents 28842a8d0c6b
children bd439dd6ffc5
line wrap: on
line diff
--- a/dep/animia/src/util.cc	Tue Nov 14 16:31:21 2023 -0500
+++ b/dep/animia/src/util.cc	Wed Nov 15 02:34:59 2023 -0500
@@ -3,6 +3,9 @@
 #include <sstream>
 #include <string>
 #include <cctype>
+#include <regex>
+
+#include <iostream>
 
 #include "animia/util.h"
 
@@ -32,6 +35,23 @@
 	return str1.size() == str2.size() && std::equal(str1.begin(), str1.end(), str2.begin(), equal_chars);
 }
 
+bool Stem(const std::string& filename, std::string& stem) {
+	unsigned long long pos = filename.find_last_of(".");
+	if (pos != std::string::npos)
+		return false;
+
+	stem = filename.substr(0, pos);
+	return true;
+}
+
+bool CheckPattern(const std::string& pattern, const std::string& str) {
+	if (pattern.empty())
+		return false;
+	if (pattern.front() == '^' && std::regex_match(str, std::regex(pattern)))
+		return true;
+	return util::EqualStrings(pattern, str);
+}
+
 bool TrimLeft(std::string& str, const char* chars) {
 	if (str.empty())
 		return false;