Advertisement
Loesome

Untitled

May 12th, 2014
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <sstream>
  5. #include <fstream>
  6. #include <cerrno>
  7. using namespace std;
  8.  
  9. class FilePro{
  10. private:
  11.     ifstream fileProce;
  12.     string name;
  13.     long size;
  14. public:
  15.     FilePro(string name){
  16.         this->name = name;
  17.     }
  18.  
  19.     string toString(){
  20.  
  21.         std::ifstream in(name, ios::in | ios::binary);
  22.           if (in)
  23.           {
  24.             string str;
  25.             in.seekg(0, ios::end);
  26.             str.resize(in.tellg());
  27.             in.seekg(0, ios::beg);
  28.             in.read(&str[0], str.size());
  29.             in.close();
  30.             return(str);
  31.           }
  32.           throw(errno);
  33.  
  34.  
  35.     }
  36.     long sizeFile(){
  37.         return size;
  38.     }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement