RIIA wrapper for FILE*. No copy semantics yet.
class FilePtr {
public:
FilePtr() { fp = nullptr; }
FilePtr(FILE *fp_) { fp = fp_; }
FilePtr & operator = (FILE *fp_) { assert(fp == nullptr); fp = fp_; return *this; }
~FilePtr() { if (fp != nullptr) fclose(fp); }
operator FILE * () { return fp; }
private:
FILE *fp;
};