fart/parser/preparser.cc
Josh Holtrop 80004438be added parser/preparser.cc
git-svn-id: svn://anubis/fart/trunk@83 7f9b0f55-74a9-4bce-be96-3c2cd072584d
2009-02-05 03:13:28 +00:00

34 lines
580 B
C++

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iostream>
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;
}