Skip to content

Commit

Permalink
fix: write output file streams as binary
Browse files Browse the repository at this point in the history
  • Loading branch information
abheekda1 committed Jan 10, 2024
1 parent f550eca commit 5236898
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
#include <utility>
Expand All @@ -24,7 +25,7 @@ bool convert(const std::string &indata, const std::string &outpath) {
return false;
}

std::ofstream fout(outpath);
std::ofstream fout(outpath, std::ios::binary);
fout << outdata;
return true;
}
Expand Down Expand Up @@ -211,7 +212,7 @@ int main(int argc, char *argv[]) {
<< outpath.string() + file_extension << "..."
<< std::endl;
if (noconvert) {
std::ofstream of(outpath.string() + file_extension);
std::ofstream of(outpath.string() + file_extension, std::ios::binary);
of << wem;
of.close();
idx++;
Expand Down Expand Up @@ -291,7 +292,7 @@ int main(int argc, char *argv[]) {
fs::path outpath = outdir / filename;
std::string file_extension = noconvert ? ".wem" : ".ogg";
if (noconvert) {
std::ofstream of(outpath.string() + file_extension);
std::ofstream of(outpath.string() + file_extension, std::ios::binary);
of << wem;
of.close();
idx++;
Expand All @@ -317,7 +318,7 @@ int main(int argc, char *argv[]) {
<< file_count << "] " << rang::fg::reset
<< "Extracting " << file->name() << "..."
<< rang::fg::reset << std::endl;
std::ofstream fout(file->name());
std::ofstream fout(file->name(), std::ios::binary);
fout << file->data();
continue;
}
Expand Down

0 comments on commit 5236898

Please sign in to comment.