Skip to content

Commit

Permalink
changed gzip flag to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
riasc committed Nov 17, 2024
1 parent 5711c66 commit 8951ea3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/include/FileTypeDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace genogrove {

class FileTypeDetector {
public:
std::tuple<FileType, std::bitset<1>> detectFileType(const std::filesystem::path& filepath);
std::tuple<FileType, bool> detectFileType(const std::filesystem::path& filepath);
};
}

Expand Down
5 changes: 2 additions & 3 deletions cli/src/FileTypeDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ namespace genogrove {
{".vcf", FileType::VCF}
};

std::tuple<FileType, std::bitset<1>> FileTypeDetector::detectFileType(const std::filesystem::path& filepath) {
std::tuple<FileType, bool> 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();
Expand Down

0 comments on commit 8951ea3

Please sign in to comment.