Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- class File {
- public:
- enum { exist, notexist, notvalid };
- void open(const std::string& type, int binary, const std::string& name) {
- if (name.find_last_of(type) == std::string::npos) _status = notvalid;
- else {
- if (binary) file.open(name.c_str(),
- std::fstream::in | std::fstream::out | std::fstream::binary);
- else file.open(name.c_str(),
- std::fstream::in | std::fstream::out);
- if (!file.is_open()) _status = notexist;
- else _status = exist;
- }
- }
- void close() { file.close(); }
- int status() { return _status; }
- protected:
- std::fstream file;
- int _status;
- };
- class VMF: public File {
- public:
- VMF(const std::string& name) { open(".vmf", 0, name); }
- };
- int main() {
- VMF vmf("test.cpp");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment