12 if (fullString.length() >= ending.length()) {
13 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
26 fread(&magic, 4, 1,
f);
27 fseek(
f, -4, SEEK_END);
28 fread(&size, 4, 1,
f);
40 const char* error_string;
41 error_string = gzerror(
file, &
err);
56 TMVA::IMethod* ptr =
nullptr;
64 std::cout <<
"Weight file is pure xml." << std::endl;
69 std::cout <<
"Unzipping file." << std::endl;
75 char tmpFilename[] =
"/tmp/tmva.XXXXXX";
76 int fdToUselessFile = mkstemp(tmpFilename);
78 weight_file_name +=
".xml";
79 FILE* theActualFile = fopen(weight_file_name.c_str(),
"w");
80 if (theActualFile !=
nullptr) {
82 fputs(
c, theActualFile);
83 fputs(
"\n", theActualFile);
84 fclose(theActualFile);
85 close(fdToUselessFile);
87 throw cms::Exception(
"CannotWriteFile") <<
"Error while writing file = " << weight_file_name <<
" !!\n";
94 remove(weight_file_name.c_str());
100 std::cout <<
"Reader booked" << std::endl;
105 <<
", it should be .xml, .gz, or .gzip" << std::endl;
bool hasEnding(std::string const &fullString, std::string const &ending)
void free(void *ptr) noexcept
char * readGzipFile(const std::string &weightFile)
void * malloc(size_t size) noexcept
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)