Skip to content

Commit

Permalink
Setup BWT output streams to throw an exception if error occurs during…
Browse files Browse the repository at this point in the history
… writing
  • Loading branch information
ch4rr0 committed Apr 26, 2024
1 parent 89c86d7 commit b22247b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bt2_idx.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,17 @@ class Ebwt {
_in2Str = file + ".2." + gEbwt_ext + ".tmp";
packed_ = packed;
// Open output files
ofstream fout1(_in1Str.c_str(), ios::binary);
ofstream fout1(_in1Str.c_str(), ios::binary);
fout1.exceptions(ofstream::failbit | ofstream::badbit | ofstream::eofbit);
if(!fout1.good()) {
cerr << "Could not open index file for writing: \"" << _in1Str.c_str() << "\"" << endl
<< "Please make sure the directory exists and that permissions allow writing by" << endl
<< "Bowtie." << endl;
throw 1;
}
ofstream fout2(_in2Str.c_str(), ios::binary);
}

ofstream fout2(_in2Str.c_str(), ios::binary);
fout2.exceptions(ofstream::failbit | ofstream::badbit | ofstream::eofbit);
if(!fout2.good()) {
cerr << "Could not open index file for writing: \"" << _in2Str.c_str() << "\"" << endl
<< "Please make sure the directory exists and that permissions allow writing by" << endl
Expand Down

0 comments on commit b22247b

Please sign in to comment.