From c021fad8129647c52bf4486104088afec68f5385 Mon Sep 17 00:00:00 2001 From: doe300 Date: Sat, 11 Feb 2023 12:00:48 +0100 Subject: [PATCH] Added detection of XML-derived file types by peeking the file contents --- src/source.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/source.cpp b/src/source.cpp index 901b4f9..1a10ff9 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,14 @@ Glib::RefPtr Source::guess_language(const boost::filesystem::path } } } + else { + std::ifstream input(file_path.string(), std::ios::binary); + std::string tag(5, '\0'); + if(input && input.read(&tag[0], static_cast(tag.size()))) { + if(tag == "get_language("xml"); + } + } } else if(language->get_id() == "cuda") { if(file_path.extension() == ".cuh")