Changeset 3163


Ignore:
Timestamp:
Jan 15, 2014, 9:04:56 AM (8 years ago)
Author:
Peter
Message:

samwrite returns -1 if file is closed, so correct code to detect when this happens.

Location:
branches/0.11-stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/0.11-stable

    • Property svn:mergeinfo changed
      /trunk (added)merged: 3162
  • branches/0.11-stable/test/bam.cc

    r3055 r3163  
    192192
    193193
     194void test_write(test::Suite& suite, const BamHeader& header)
     195{
     196  OutBamFile out;
     197  BamRead read;
     198  try {
     199    // trying to write to a file not open
     200    out.write(read);
     201    suite.add(false);
     202    suite.err() << "write(BamRead): did not throw\n";
     203  }
     204  catch (utility::runtime_error& e) {
     205    suite.err() << "expected exception: " << e.what() << "\n";
     206  }
     207}
     208
     209
    194210void test1(test::Suite& suite)
    195211{
     
    239255  test_sequence(suite, bam);
    240256  test_name(suite, bam);
    241 }
    242 #endif
     257  test_write(suite, in.header());
     258}
     259#endif
  • branches/0.11-stable/yat/omic/BamFile.cc

    r3080 r3163  
    140140  void OutBamFile::write(const BamRead& read)
    141141  {
    142     if (!samwrite(sf_, read.bam_)) {
     142    if (samwrite(sf_, read.bam_)<=0) {
    143143      // FIXME if wanted perhaps we should throw an OutBamFile::error
    144144      // instead that can hold \a read
Note: See TracChangeset for help on using the changeset viewer.