ocarina/include/file.h
Bryan Schumaker ecd56831f6 file: Open and close files
- Support OPEN_READ and OPEN_WRITE
- Update the design to accomidate for error checking
- Add lib/test.cpp containing basic functions that can be used for
  testing

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:52 -04:00

46 lines
651 B
C++

/*
* Copyright 2013 (c) Bryan 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,
};
enum OpenMode {
OPEN_READ,
OPEN_WRITE,
NOT_OPEN,
};
class File {
private:
std::fstream stream;
OpenMode mode;
FileLocHint hint;
std::string filepath;
unsigned int version;
void find_dir(std::string &);
bool open_read();
bool open_write();
public:
File(std::string, FileLocHint);
~File();
const char *get_filepath();
bool exists();
bool open(OpenMode);
bool close();
};
#endif /* OCARINA_FILE_H */