- fseek(fp, 0, SEEK_END);
- int64_t sz = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- char *bfr = new char[sz+1];
- int64_t len = fread(bfr, 1, sz+1, fp);
- if( len == sz ) {
- FileXML file;
- XMLBuffer data(bfr, len, 0);
- file.set_shared_input(&data);
+ char *bfr = 0; size_t sz = 0;
+ struct stat st;
+ if( !fstat(fileno(fp), &st) ) {
+ sz = st.st_size;
+ bfr = new char[sz+1];
+ if( fread(bfr, 1, sz+1, fp) != sz )
+ ret = 1;
+ else
+ bfr[sz] = 0;
+ }
+ if( !ret ) {