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

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

libs/FileStream.h

Committer:
Bigcheese
Date:
2014-03-02
Revision:
3:f151d08d335c
Parent:
2:1df0b61d3b5a

File content as of revision 3:f151d08d335c:

#ifndef _FILESTREAM_H_
#define _FILESTREAM_H_

#include "StreamOutput.h"
#include "stdlib.h"

class FileStream : public StreamOutput {
    public:
        FileStream(const char *filename) { fd= fopen(filename, "w"); }
        virtual ~FileStream(){ close(); }
        int puts(const char *str){ return (fd == NULL) ? 0 : fwrite(str, 1, strlen(str), fd); }
        void close() { if(fd != NULL) fclose(fd); fd= NULL; }
        bool is_open() { return fd != NULL; }

    private:
        FILE *fd;
};

#endif