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