From 8951ea30d2b295ba62c8c56df61d3e79ccb1ddfd Mon Sep 17 00:00:00 2001 From: riasc Date: Sun, 17 Nov 2024 15:56:20 -0600 Subject: [PATCH] changed gzip flag to bool --- cli/include/FileTypeDetector.hpp | 2 +- cli/src/FileTypeDetector.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/include/FileTypeDetector.hpp b/cli/include/FileTypeDetector.hpp index cbe9c18..0834a6b 100644 --- a/cli/include/FileTypeDetector.hpp +++ b/cli/include/FileTypeDetector.hpp @@ -21,7 +21,7 @@ namespace genogrove { class FileTypeDetector { public: - std::tuple> detectFileType(const std::filesystem::path& filepath); + std::tuple detectFileType(const std::filesystem::path& filepath); }; } diff --git a/cli/src/FileTypeDetector.cpp b/cli/src/FileTypeDetector.cpp index 8fab613..2b491a8 100644 --- a/cli/src/FileTypeDetector.cpp +++ b/cli/src/FileTypeDetector.cpp @@ -10,15 +10,14 @@ namespace genogrove { {".vcf", FileType::VCF} }; - std::tuple> FileTypeDetector::detectFileType(const std::filesystem::path& filepath) { + std::tuple FileTypeDetector::detectFileType(const std::filesystem::path& filepath) { std::ifstream file(filepath, std::ios::binary); if(!file) { throw std::runtime_error("Failed to open file: " + filepath.string()); } // check if the file is gzipped char buffer[2]; file.read(buffer, 2); - std::bitset<1> gzipped(0); - if(file.gcount() == 2 && buffer[0] == 0x1f && buffer[1] == 0x8b) { gzipped = std::bitset<1>(1); } + bool gzipped = (file.gcount() == 2 && buffer[0] == 0x1f && buffer[1] == 0x8b); // extract the file extension std::string extension = filepath.extension().string();