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)
00036 {
00037 file = str;
00038 }
00039
00040 string getFile()
00041 {
00042 return file;
00043 }
00044 };
00045
00046 class File
00047 {
00048 public:
00049 std::ifstream* file;
00050
00051
00052
00053 File(string const filename)
00054 {
00055 std::fstream foo;
00056
00057 foo.open(filename.c_str());
00058
00059 if (foo.is_open() == true)
00060 foo.close();
00061 else
00062 throw FileNotFound(filename);
00063
00064 file = new std::ifstream(filename.c_str(), std::ifstream::in);
00065 }
00066
00067 virtual ~File()
00068 {
00069 close();
00070 }
00071
00072 int get()
00073 {
00074 return file->get();
00075 }
00076
00077 bool eof()
00078 {
00079 return file->eof();
00080 }
00081
00082 void close()
00083 {
00084 file->close();
00085 }
00086 };
00087
00088 #endif