1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "File.h"
- #include <iostream>
- #include <fstream>
- #include <sstream>
- File::File(string path)
- {
- this->path = path;
- }
- File::File(const File& orig)
- {
- }
- File::~File()
- {
- }
- bool File::exists()
- {
- ifstream fileStream(path);
- return fileStream.good();
- }
- string File::read()
- {
- ifstream fileStream(path);
- if(!fileStream.good())
- {
- return "";
- }
- stringstream stream;
- string s;
- while(!fileStream.eof())
- {
- getline(fileStream, s);
- stream << s;
- stream << '\n';
- }
- return stream.str();
- }
|