2013-07-27 11:40:16 -04:00
|
|
|
/*
|
2013-08-07 21:00:09 -04:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
2013-07-27 11:40:16 -04:00
|
|
|
*/
|
|
|
|
#ifndef OCARINA_FILE_H
|
|
|
|
#define OCARINA_FILE_H
|
|
|
|
|
2013-07-28 19:57:07 -04:00
|
|
|
#include <fstream>
|
2013-07-27 11:40:16 -04:00
|
|
|
#include <string>
|
|
|
|
|
2013-07-28 19:57:07 -04:00
|
|
|
#define FILE_VERSION 0
|
|
|
|
|
2013-07-27 11:40:16 -04:00
|
|
|
enum FileLocHint {
|
|
|
|
FILE_TYPE_DATA,
|
|
|
|
FILE_TYPE_LEGACY,
|
2013-08-10 23:52:52 -04:00
|
|
|
FILE_TYPE_INVALID,
|
2013-07-27 11:40:16 -04:00
|
|
|
};
|
|
|
|
|
2013-07-28 19:57:07 -04:00
|
|
|
enum OpenMode {
|
|
|
|
OPEN_READ,
|
|
|
|
OPEN_WRITE,
|
|
|
|
NOT_OPEN,
|
|
|
|
};
|
|
|
|
|
2013-07-28 22:33:40 -04:00
|
|
|
class File : public std::fstream {
|
2013-07-27 11:40:16 -04:00
|
|
|
private:
|
2013-07-28 19:57:07 -04:00
|
|
|
OpenMode mode;
|
2013-07-27 11:40:16 -04:00
|
|
|
FileLocHint hint;
|
|
|
|
std::string filepath;
|
2013-07-28 19:57:07 -04:00
|
|
|
unsigned int version;
|
|
|
|
|
2014-03-02 14:44:24 -05:00
|
|
|
std::string find_dir();
|
2013-12-29 21:12:32 -05:00
|
|
|
void open_read();
|
|
|
|
void open_write();
|
2013-07-27 11:40:16 -04:00
|
|
|
|
|
|
|
public:
|
2013-12-29 21:12:32 -05:00
|
|
|
File(const std::string &, FileLocHint);
|
2013-07-28 19:57:07 -04:00
|
|
|
~File();
|
2013-07-27 11:40:16 -04:00
|
|
|
const char *get_filepath();
|
2013-07-28 22:33:40 -04:00
|
|
|
const unsigned int get_version();
|
2013-07-28 19:57:07 -04:00
|
|
|
bool exists();
|
2013-12-29 21:12:32 -05:00
|
|
|
void open(OpenMode);
|
|
|
|
void close();
|
2013-07-28 22:33:40 -04:00
|
|
|
std::string getline();
|
2013-07-27 11:40:16 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* OCARINA_FILE_H */
|