• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <fstream>
2 #include <ios>
3 #include <iostream>
4 #include <boost/integer_traits.hpp>
5 #include <boost/archive/binary_iarchive.hpp>
6 
usage(const char * program_name)7 void usage(const char * program_name){
8     std::cout << "usage:";
9     std::cout << program_name << " filename" << std::endl;
10 }
11 
main(int argc,char * argv[])12 int main(int argc, char *argv[]){
13     if(argc != 2){
14         std::cout << "invalid number of arguments" << std::endl;
15         usage(argv[0]);
16         return 1;
17     }
18     std::filebuf fb;
19     fb.open(
20         argv[1],
21         std::ios_base::binary | std::ios_base::in | std::ios_base::out
22     );
23     if(!fb.is_open()){
24         std::cout << argv[1] <<  " failed to open" << std::endl;
25         return 1;
26     }
27     boost::archive::binary_iarchive ia(fb);
28     boost::archive::library_version_type lvt = ia.get_library_version();
29     if(boost::archive::library_version_type(6) != lvt){
30         std::cout << "library version not equal to six" << std::endl;
31         return 1;
32     }
33     lvt = boost::archive::library_version_type(7);
34     fb.pubseekpos(26, std::ios_base::out);
35     fb.sputn(reinterpret_cast<const char *>(& lvt), sizeof(lvt));
36     fb.close();
37 }
38