Merge branch 'feature/e-endstop' into merge-abc-with-homing
[clinton/Smoothieware.git] / src / libs / FileStream.h
1 #ifndef _FILESTREAM_H_
2 #define _FILESTREAM_H_
3
4 #include "StreamOutput.h"
5 #include <stdlib.h>
6 #include <stdio.h>
7
8 class FileStream : public StreamOutput {
9 public:
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; }
15
16 private:
17 FILE *fd;
18 };
19
20 #endif