added parser/preparser.cc
git-svn-id: svn://anubis/fart/trunk@83 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
afd0df3ce4
commit
80004438be
33
parser/preparser.cc
Normal file
33
parser/preparser.cc
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user