39 std::ostringstream outStr;
40 std::ostringstream fileName;
41 fileName << fname << std::endl;
42 std::string soutString;
44 std::ifstream inFile( fname);
47 throw ErrorClass(
" Could not open the given file: " + fileName.str());
50 while( inFile.get( ch ) )
57 throw ErrorClass(
" There was a problem reading the file: " + fileName.str() );
59 soutString = outStr.str();
74 std::ostringstream fileName;
75 fileName << fname << std::endl;
85 throw ErrorClass(
" Could not read the given file: " + fileName.str() );
88 pbuf = inFile.rdbuf();
92 pbuf ->pubseekpos(0, std::ios::in);
94 xml =
new char[bufsize + 1];
97 while( inFile.get( ch ) )
105 throw ErrorClass(
" There was a problem reading the file: " + fileName.str());
118 std::ostringstream fileName;
119 fileName << fname << std::endl;
123 ft = fopen ( fname,
"w") ;
126 throw ErrorClass(
" There was a problem opening the file: " + fileName.str());
129 cstr =
new char [sname.size() + 1];
130 strcpy (cstr, sname.c_str());
132 for(i = 0; i < sname.size() + 1; i++)
134 if(cstr[ i] !=
'\0') fputc ( cstr[ i], ft ) ;
150 std::ostringstream fileName;
151 fileName << fname << std::endl;
155 ft = fopen ( fname.c_str(),
"w") ;
158 throw ErrorClass(
" There was a problem opening the file: " + fileName.str());
161 cstr =
new char [sname.size() + 1];
162 strcpy (cstr, sname.c_str());
164 for(i = 0; i < sname.size() + 1; i++)
166 if(cstr[ i] !=
'\0') fputc ( cstr[ i], ft ) ;
183 std::fstream outFile;
184 outFile.open( fname);
185 if(!outFile.is_open())
bool writeFileFromString(char *fname, std::string thestring)
write a file from an input string.
const OSSmartPtr< OSOutput > osoutput
std::string errormsg
errormsg is the error that is causing the exception to be thrown
char * getFileAsChar(const char *fname)
read a file and return contents as a char pointer.
bool writeFileFromChar(char *fname, char *ch)
write a file from an input char pointer.
~FileUtil()
the class destructor
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
FileUtil()
the class constructor
used for throwing exceptions.