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
|
|
|
|
|
|
|
enum OpenMode {
|
|
|
|
OPEN_READ,
|
|
|
|
OPEN_WRITE,
|
|
|
|
NOT_OPEN,
|
|
|
|
};
|
|
|
|
|
2014-05-26 12:10:36 -04:00
|
|
|
|
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;
|
2014-04-26 13:31:22 -04:00
|
|
|
std::string filename;
|
2013-07-28 19:57:07 -04:00
|
|
|
unsigned int version;
|
2014-05-26 12:10:36 -04:00
|
|
|
unsigned int prev_version;
|
2013-07-28 19:57:07 -04:00
|
|
|
|
2014-05-18 10:15:51 -04:00
|
|
|
const std::string find_dir();
|
2014-03-09 10:34:06 -04:00
|
|
|
bool open_read();
|
|
|
|
bool open_write();
|
2013-07-27 11:40:16 -04:00
|
|
|
|
|
|
|
public:
|
2014-05-26 12:10:36 -04:00
|
|
|
|
|
|
|
File(const std::string &, unsigned int);
|
2013-07-28 19:57:07 -04:00
|
|
|
~File();
|
2014-05-18 10:15:51 -04:00
|
|
|
const std::string 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();
|
2014-03-09 10:34:06 -04:00
|
|
|
bool open(OpenMode);
|
2013-12-29 21:12:32 -05:00
|
|
|
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 */
|