Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool is_gzipped(std::string filename) {
- std::ifstream in_file;
- char byte1, byte2;
- in_file.open(filename, ios::binary|ios::ate);
- if (in_file.is_open()) {
- in_file.seekg(0, ios::beg);
- std::string bytes;
- in_file.read(&byte1, 1);
- in_file.read(&byte2, 1);
- in_file.close();
- } else {
- throw std::exception();
- }
- return (reinterpret_cast<unsigned char &>(byte1) == 0x1f) &&
- (reinterpret_cast<unsigned char &>(byte2) == 0x8b);
- }
Add Comment
Please, Sign In to add comment