Commit | Line | Data |
---|---|---|
f2f0dfed JM |
1 | #ifndef _FILESTREAM_H_ |
2 | #define _FILESTREAM_H_ | |
3 | ||
4 | #include "StreamOutput.h" | |
f44d5fa7 JM |
5 | #include <stdlib.h> |
6 | #include <stdio.h> | |
f2f0dfed JM |
7 | |
8 | class FileStream : public StreamOutput { | |
9 | public: | |
618c9b0f | 10 | FileStream(const char *filename) { fd= fopen(filename, "w"); } |
f2f0dfed JM |
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; } | |
618c9b0f | 14 | bool is_open() { return fd != NULL; } |
f2f0dfed JM |
15 | |
16 | private: | |
17 | FILE *fd; | |
18 | }; | |
19 | ||
20 | #endif |