1#ifndef PSEUDO_DETECT_FORMAT_HPP
2#define PSEUDO_DETECT_FORMAT_HPP
25#include <rapidxml.hpp>
37 struct stat file_stat;
38 if (stat(filename.c_str(), &file_stat) == -1)
40 if (S_ISDIR(file_stat.st_mode))
44 std::ifstream
file(filename.c_str());
50 std::string extension = filename.substr(filename.find_last_of(
".") + 1);
51 std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
53 if (extension ==
"psp8" || extension ==
"drh")
55 if (extension ==
"psf")
57 if (extension ==
"cpi")
59 if (extension ==
"fhi")
61 if (extension ==
"hgh")
65 std::vector<char> buffer((std::istreambuf_iterator<char>(
file)),
66 std::istreambuf_iterator<char>());
67 buffer.push_back(
'\0');
69 rapidxml::xml_document<> doc;
71 doc.parse<0>(&buffer[0]);
73 if (doc.first_node(
"fpmd:species"))
75 if (doc.first_node(
"qbox:species"))
77 if (doc.first_node(
"PP_INFO"))
79 if (doc.first_node(
"UPF"))
81 if (doc.first_node(
"psml"))
83 }
catch (rapidxml::parse_error xml_error) {
!The assertions are ignored if the code is compiled in not debug when !prints out the assertion the file
Definition: global.h:58
!The assertions are ignored if the code is compiled in not debug when !prints out the assertion string
Definition: global.h:58
Definition: anygrid.hpp:27
format
Definition: base.hpp:49