ocarina/include/file.h
Anna Schumaker b251f27bb5 file: Don't use throw / catch to report errors
Needing to use throw / catch was getting in the way.  Instead, check for
a boolean return value.

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

47 lines
712 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_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;
std::string find_dir();
bool open_read();
bool open_write();
public:
File(const std::string &, FileLocHint);
~File();
const char *get_filepath();
const unsigned int get_version();
bool exists();
bool open(OpenMode);
void close();
std::string getline();
};
#endif /* OCARINA_FILE_H */