cgatools::util::OutputStream Class Reference

a std::ostream with good error messages, and which does fsync on close on UNIX. More...

#include <Streams.hpp>

List of all members.

Public Member Functions

 OutputStream (const char *fn)
 OutputStream (const std::string &fn)
void open (const std::string &fn)
void open (const char *fn)
void close ()

Static Public Member Functions

static boost::shared_ptr
< std::ostream > 
openCompressedOutputStreamByExtension (const std::string &fn)
 Returns a pointer to an OutputStream or CompressedOutputStream, depending on the file extension.

Detailed Description

a std::ostream with good error messages, and which does fsync on close on UNIX.

Note that calling flush() of this class will not cause fsync(2) call, since FileSinkDevice is not marked as flushable. This is so that we don't fsync on every f << std::endl. If you really need to sync to disk without closing the stream, you can do:

 OutputStream f("foo");
 f.flush();
 (*f).fsync();

This will use operator*() to get access to the underlying device. This class will fsync automatically when closing itself.


Member Function Documentation

static boost::shared_ptr<std::ostream> cgatools::util::OutputStream::openCompressedOutputStreamByExtension ( const std::string &  fn  )  [static]

Returns a pointer to an OutputStream or CompressedOutputStream, depending on the file extension.

File extensions supported:

  • .gz -> gzip format
  • .bz2 -> bzip2 format
  • other -> straight InputStream

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated by  doxygen 1.6.2