summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 9bf83cc..92560b6 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -110,3 +110,28 @@ Language languageFromExtension(const std::filesystem::path& file)
exit(1);
return {};
}
+
+namespace
+{
+bool isClean(char c)
+{
+ return c != '.' && c != '/';
+}
+}
+
+std::string cleanUp(const std::string& path)
+{
+ std::string cleaned;
+ for(const auto& c : path)
+ {
+ if(isClean(c))
+ {
+ cleaned += c;
+ }
+ else
+ {
+ cleaned += '_';
+ }
+ }
+ return cleaned;
+}