Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/logging/lib/load-log.cxx
ViewVC logotype

Diff of /branches/vis15/src/logging/lib/load-log.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4854, Sun Dec 25 14:10:09 2016 UTC revision 4855, Mon Dec 26 12:48:39 2016 UTC
# Line 51  Line 51 
51              perror ("stat");              perror ("stat");
52              exit (1);              exit (1);
53          }          }
54          numBufs = (st.st_size - sizeof(diderot::log::file_hdr)) / sizeof(diderot::log::event);          numBufs = (st.st_size - sizeof(diderot::log::file_hdr)) / sizeof(diderot::log::buffer);
55          if (st.st_size != sizeof(diderot::log::file_hdr) + numBufs * sizeof(diderot::log::event)) {          if (st.st_size != sizeof(diderot::log::file_hdr) + numBufs * sizeof(diderot::log::buffer)) {
56              std::cerr << "Warning: log file size is not a whole number of buffers\n";              std::cerr << "Warning: log file size is not a whole number of buffers\n";
57          }          }
58      }      }
59    
60    // open the file    // open the file
61      std::ifstream ins(name, std::ifstream::in | std::ifstream::binary);      std::ifstream ins(name, std::ifstream::in | std::ifstream::binary);
62      if (! ins.good()) {      if (ins.fail()) {
63          std::cerr << "Error: unable to open \"" << name << "\"\n";          std::cerr << "Error: unable to open \"" << name << "\"\n";
64          exit (1);          exit (1);
65      }      }
# Line 67  Line 67 
67    // read the header    // read the header
68      diderot::log::file_hdr hdr;      diderot::log::file_hdr hdr;
69      ins.read (reinterpret_cast<char *>(&hdr), sizeof(hdr));      ins.read (reinterpret_cast<char *>(&hdr), sizeof(hdr));
70      if (! ins.good()) {      if (ins.fail()) {
71          std::cerr << "Error attempting to read header from \"" << name << "\"\n";          std::cerr << "Error attempting to read header from \"" << name << "\"\n";
72          exit (1);          exit (1);
73      }      }
# Line 112  Line 112 
112    // read in the events    // read in the events
113      diderot::log::buffer buf;      diderot::log::buffer buf;
114      uint64_t numEvents = 0;      uint64_t numEvents = 0;
115    std::cout << numBufs << " buffers\n";
116      for (int i = 0;  i < numBufs;  i++) {      for (int i = 0;  i < numBufs;  i++) {
117          ins.read (reinterpret_cast<char *>(&buf), sizeof(buf));          ins.read (reinterpret_cast<char *>(&buf), sizeof(buf));
118          if (! ins.good()) {  std::cout << "  read buffer " << i << "\n";
119            if (ins.fail()) {
120              std::cerr << "Error attempting to read buffer from \"" << name << "\"\n";              std::cerr << "Error attempting to read buffer from \"" << name << "\"\n";
121              exit (1);              exit (1);
122          }          }

Legend:
Removed from v.4854  
changed lines
  Added in v.4855

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0