Guest User

Untitled

a guest
Mar 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. bool is_gzipped(std::string filename) {
  2. std::ifstream in_file;
  3. char byte1, byte2;
  4.  
  5. in_file.open(filename, ios::binary|ios::ate);
  6. if (in_file.is_open()) {
  7. in_file.seekg(0, ios::beg);
  8. std::string bytes;
  9. in_file.read(&byte1, 1);
  10. in_file.read(&byte2, 1);
  11. in_file.close();
  12. } else {
  13. throw std::exception();
  14. }
  15.  
  16. return (reinterpret_cast<unsigned char &>(byte1) == 0x1f) &&
  17. (reinterpret_cast<unsigned char &>(byte2) == 0x8b);
  18. }
Add Comment
Please, Sign In to add comment