ocarina/include/file.h
Anna Schumaker ab8c15ecb7 file: Implement minor design changes
I had been returning success / failed boolean values for various
operations.  I think it's better to throw an exception in these
"exceptional" circumstances since error values can give more information
about why a function failed.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:57 -04:00

48 lines
737 B
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_FILE_H
#define OCARINA_FILE_H
#include <fstream>
#include <string>
#define FILE_VERSION 0
enum FileLocHint {
FILE_TYPE_CONFIG,
FILE_TYPE_DATA,
FILE_TYPE_LEGACY,
FILE_TYPE_INVALID,
};
enum OpenMode {
OPEN_READ,
OPEN_WRITE,
NOT_OPEN,
};
class File : public std::fstream {
private:
OpenMode mode;
FileLocHint hint;
std::string filepath;
unsigned int version;
void find_dir(std::string &);
void open_read();
void open_write();
public:
File(const std::string &, FileLocHint);
~File();
const char *get_filepath();
const unsigned int get_version();
bool exists();
void open(OpenMode);
void close();
std::string getline();
};
#endif /* OCARINA_FILE_H */