#include #include #include #include #include "TFile.h" #include "TError.h" #include "JLang/JUUID.hh" #include "Jeep/JComment.hh" #include "JIO/JFileStreamIO.hh" #include "JDetector/JDetectorToolkit.hh" #include "JSupport/JFilenameSupportkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to print UUID. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; string inputFile; int debug; try { JParser<> zap("Auxiliary program to print UUID."); zap['f'] = make_field(inputFile) = ""; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } if (inputFile != "") { if (getFilenameExtension(inputFile) == ROOT_FILE_FORMAT) { gErrorIgnoreLevel = kError; TFile* file = TFile::Open(inputFile.c_str(), "EXISTS"); if (file != NULL) { file->GetUUID().Print(); file->Close(); } else return 1; } else if (getFilenameExtension(inputFile) == ASCII_FILE_FORMAT || getFilenameExtension(inputFile) == KM3NET_DETECTOR_FILE_FORMAT) { ifstream in(inputFile.c_str()); JComment comment; if (in >> comment && comment.hasUUID()) cout << comment.getUUID() << endl; else return 1; in.close(); } else if (getFilenameExtension(inputFile) == BINARY_DETECTOR_FILE_FORMAT[0] || getFilenameExtension(inputFile) == BINARY_DETECTOR_FILE_FORMAT[1]) { JFileStreamReader in(inputFile.c_str()); JComment comment; char c; for (string buffer; in >> c && c == JComment::START_COMMENT; ) { in >> buffer; comment.add(buffer); } if (comment.hasUUID()) cout << comment.getUUID() << endl; else return 1; in.close(); } } else { cout << JUUID::rndm() << endl; } return 0; }