4 #include "StreamOutput.h"
7 class FileStream
: public StreamOutput
{
9 FileStream(const char *filename
) { fd
= fopen(filename
, "w"); }
10 virtual ~FileStream(){ close(); }
11 int puts(const char *str
){ return (fd
== NULL
) ? 0 : fwrite(str
, 1, strlen(str
), fd
); }
12 void close() { if(fd
!= NULL
) fclose(fd
); fd
= NULL
; }
13 bool is_open() { return fd
!= NULL
; }