fart/parser/preparser.cc
Josh Holtrop 69c5fdd1e6 updated parser to compile again, still have non-virtual destructor compiler warnings
git-svn-id: svn://anubis/fart/trunk@109 7f9b0f55-74a9-4bce-be96-3c2cd072584d
2009-02-16 20:51:59 +00:00

35 lines
599 B
C++

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
using namespace std;
int preprocess(const char * fileName)
{
struct stat st;
if (stat(fileName, &st))
{
cerr << "Error accessing " << fileName << endl;
return -1;
}
ifstream ifs(fileName);
if ( ! ifs.is_open() )
{
cerr << "Error opening " << fileName << endl;
return -2;
}
char * buff = new char[st.st_size];
while ( ! ifs.eof() )
{
ifs.getline(buff, st.st_size);
}
delete[] buff;
return 0;
}