Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. Program received signal SIGSEGV, Segmentation fault.
  2. 0x000055c84fbbc058 in std::vector<boost::filesystem::path, std::allocator<boost::filesystem::path> >::push_back(boost::filesystem::path const&) ()
  3. (gdb)
  4. Single stepping until exit from function _ZNSt6vectorIN5boost10filesystem4pathESaIS2_EE9push_backERKS2_,
  5. which has no line number information.
  6.  
  7. Program terminated with signal SIGSEGV, Segmentation fault.
  8.  
  9. #pragma once
  10. #include <boost/filesystem.hpp>
  11.  
  12. #include <cryptopp/cryptlib.h>
  13.  
  14. #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
  15. #include <cryptopp/md5.h>
  16. #include "cryptopp/hex.h"
  17. #include "cryptopp/files.h"
  18.  
  19. class Verify {
  20. private:
  21. typedef std::vector<boost::filesystem::path> vec;
  22. vec v;
  23. public:
  24. bool verify_files();
  25. bool generate_hash(boost::filesystem::path source);
  26. };
  27.  
  28. bool Verify::generate_hash(boost::filesystem::path source) {
  29. try {
  30. if (boost::filesystem::exists(source)) { //make sure path is valid
  31. if (boost::filesystem::is_regular_file(source)) { //no regular files
  32. std::cout << "Please enter base path of directory only." << std::endl;
  33. return false;
  34. }
  35. else if (boost::filesystem::is_directory(source)){ //process directory here
  36. std::cout << "Scanning " << source << std::endl;
  37.  
  38. std::copy(boost::filesystem::recursive_directory_iterator(source), boost::filesystem::recursive_directory_iterator(), std::back_inserter(this->v));
  39. std::sort(v.begin(), v.end());
  40.  
  41. for (vec::const_iterator it (v.begin()); it != v.end(); ++it){
  42. std::string result;
  43. if (boost::filesystem::is_regular_file(*it)) {
  44. Weak::MD5 hash;
  45. FileSource((*it).string().c_str(), true, new HashFilter(hash, new HexEncoder(new StringSink(result), false)));
  46. }
  47. std::cout << "Hashing: " << *it << " - " << result << std::endl;
  48. }
  49. }
  50. }
  51. } catch (const boost::filesystem::filesystem_error& e){
  52. std::cout << e.what() << std::endl;
  53. return false;
  54. }
  55. return true;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement