[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hello,
I'm currently working on a patch that will allow the packfile functions
to work on a normal memory chunk by calling:
PACKFILE* pack_open_mem(void *data, int size);
(the size param is of type int, since the corresponding packfile member
is an int as well - not sure if we should change both to size_t)
The actual handling works fine, but in order to make it useful I'd have
to change most loading functions slightly.
Right now, most loaders do something like this:
FOO *load_foo(const chat* filename) {
f = pack_fopen(filename, F_READ);
if (!f)
return NULL;
/* ... */
}
Which would be needed to be changed into:
FOO* load_foo(const char *filename) {
f = pack_fopen(filename, F_READ);
if (f)
return pack_load_foo(f);
return NULL;
}
And the pack_load_foo() functions would need to be exposed.
This allows you to do two things:
a) You can create BITMAPs, SAMPLEs, etc. from memory
b) You can load these types also from the middle of a larger, concated file.
PACKFILE *f = pack_fopen("foo.dat", "rb");
pack_fseek(f, 1024);
bmp = pack_load_bitmap(f, NULL);
I think I can finish the changes during the weekend. What do you guys think?
Regards,
Lenny