1 | |
2 | |
3 | |
4 | |
5 | #include "hddm_merge_files.h" |
6 | |
7 | #include <HDDM/hddm_s.hpp> |
8 | |
9 | |
10 | |
11 | |
12 | void Process_s(unsigned int &NEvents, unsigned int &NEvents_read) |
13 | { |
14 | |
15 | std::cout << " output file: " << OUTFILENAME << std::endl; |
16 | std::ofstream ofs(OUTFILENAME); |
17 | if (! ofs.is_open()) { |
| |
18 | std::cout << " Error opening output file \"" << OUTFILENAME |
19 | << "\"!" << std::endl; |
20 | exit(-1); |
21 | } |
22 | hddm_s::ostream *fout = new hddm_s::ostream(ofs); |
| |
23 | if (HDDM_USE_COMPRESSION) { |
| 3 | | Assuming 'HDDM_USE_COMPRESSION' is 0 | |
|
| |
24 | std::cout << " Enabling bz2 compression of output HDDM file stream" |
25 | << std::endl; |
26 | fout->setCompression(hddm_s::k_bz2_compression); |
27 | } |
28 | else { |
29 | std::cout << " HDDM compression disabled" << std::endl; |
30 | } |
31 | if (HDDM_USE_INTEGRITY_CHECKS) { |
| 5 | | Assuming 'HDDM_USE_INTEGRITY_CHECKS' is 0 | |
|
| |
32 | std::cout << " Enabling CRC data integrity check in output HDDM" |
33 | " file stream" << std::endl; |
34 | fout->setIntegrityChecks(hddm_s::k_crc32_integrity); |
35 | } |
36 | else { |
37 | std::cout << " HDDM integrity checks disabled" << std::endl; |
38 | } |
39 | |
40 | |
41 | time_t last_time = time(NULL__null); |
42 | for (unsigned int i=0; i<INFILENAMES.size(); i++) { |
| 7 | | Loop condition is false. Execution continues on line 81 | |
|
43 | std::cout << " input file: " << INFILENAMES[i] << std::endl; |
44 | std::ifstream ifs(INFILENAMES[i]); |
45 | if (! ifs.is_open()) { |
46 | std::cout << " Error opening input file \"" << INFILENAMES[i] |
47 | << "\"!" << std::endl; |
48 | exit(-1); |
49 | } |
50 | hddm_s::istream *fin = new hddm_s::istream(ifs); |
51 | |
52 | |
53 | while (ifs.good()) { |
54 | hddm_s::HDDM record; |
55 | *fin >> record; |
56 | NEvents_read++; |
57 | |
58 | |
59 | *fout << record; |
60 | NEvents++; |
61 | |
62 | |
63 | time_t now = time(NULL__null); |
64 | if (now != last_time) { |
65 | std::cout << " " << NEvents_read << " events read (" |
66 | << NEvents << " event written) \r"; |
67 | std::cout.flush(); |
68 | last_time = now; |
69 | } |
70 | |
71 | if (QUIT) |
72 | break; |
73 | } |
74 | |
75 | |
76 | ifs.close(); |
77 | delete fin; |
78 | } |
79 | |
80 | |
81 | ofs.close(); |
| 8 | | Potential leak of memory pointed to by 'fout' |
|
82 | } |