Hey, I am trying to make a XDBF class, and I am reading a file and this is getting ridiculously annoying.
First: I open my file...
openedFile = fopen(path, "r+");
It works, and my whole constructor works correctly:
I know it works correctly, because I looked at all of the entries that it loaded and stuff.
Now, the constructor ends, and I do this to extract an entry:
f = fopen("C:\\Users\\Stevie\\Desktop\\a.png", "wb");
fseek(f, 0, SEEK_SET);
XDBF::Entry *entry = a.get_entry_by_id(0x1C);
char *buff = a.extract_entry(entry);
int size = entry->length;
QMessageBox::information(this, "", QString::number(size), QMessageBox::Ok);
fwrite(buff, sizeof(char), size, f);
Now, here are the 2 functions I call(get_entry_by_id, and extract_entry):
XDBF::Entry* XDBF::get_entry_by_id(long long identifier)
Entry* entries = get_entries();
for(unsigned int i = 0; i < get_header()->entry_count; i++)
if(entries[i].identifier == identifier)
char *XDBF::extract_entry(Entry *entry)
if(openedFile == NULL)
unsigned int offset = get_offset(entry->offset_specifier, h);
fseek(openedFile, offset, SEEK_SET);
char *data = new char[entry->length];
unsigned int poophead = (unsigned int)data;
fread(data, entry->length, sizeof(char), openedFile);
Now once I get the char* from 'extract_entry', I write it to a file... It's really dumb because it reads the data incorrectly... I don't know how it's possible, but it gets the bytes:
out of the file, while the real bytes are:
The bytes that I posted first don't even exist in the GPD... I also look at the location that it seeks to before reading the entry in the 'extract_entry' function, and it's correct...
I am new the C++, so there is probably some stupid stuff I did in the code posted. Thanks for any help.