00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FILE_H_
00022 #define FILE_H_
00023
00024 #include<fstream>
00025 #include<string>
00026
00027 using namespace std;
00028 #include<iostream>
00029
00030 class FileNotFound
00031 {
00032 private:
00033 string file;
00034 public:
00035 FileNotFound(string str){file = str;};
00036 };
00037
00038 class File
00039 {
00040 public:
00041 std::ifstream* file;
00042
00043
00044 File(string filename)
00045 {
00046 std::fstream foo;
00047
00048 foo.open(filename.c_str());
00049
00050 if(foo.is_open() == true)
00051 foo.close();
00052 else
00053 {
00054 cerr << "File Doesn't Exist: "<<filename << endl;
00055 throw FileNotFound(filename);
00056 }
00057
00058 file = new std::ifstream(filename.c_str(), std::ifstream::in);
00059
00060 }
00061
00062 virtual ~File() { close();}
00063
00064 int get(){ return file->get();}
00065
00066 bool eof(){ return file->eof();}
00067
00068 void close(){ file->close();}
00069 };
00070
00071 #endif