fix_six.cpp 1.1 KB

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