35 lines
599 B
C++
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;
|
|
}
|