Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FileStream.h Source File

FileStream.h

00001 #ifndef _FILESTREAM_H_
00002 #define _FILESTREAM_H_
00003 
00004 #include "StreamOutput.h"
00005 #include "stdlib.h"
00006 
00007 class FileStream : public StreamOutput {
00008     public:
00009         FileStream(const char *filename) { fd= fopen(filename, "w"); }
00010         virtual ~FileStream(){ close(); }
00011         int puts(const char *str){ return (fd == NULL) ? 0 : fwrite(str, 1, strlen(str), fd); }
00012         void close() { if(fd != NULL) fclose(fd); fd= NULL; }
00013         bool is_open() { return fd != NULL; }
00014 
00015     private:
00016         FILE *fd;
00017 };
00018 
00019 #endif