mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 13:53:02 +05:30
Moved file operation out of unpackpld
This commit is contained in:
parent
54ef5e84db
commit
6cf243138e
21
test/main.c
21
test/main.c
@ -73,25 +73,26 @@ char *loadfile(const char *fname, unsigned int *s) {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unpackpld (const char *filename) {
|
bool unpackpld (const char *filedata,
|
||||||
|
unsigned int filesize,
|
||||||
|
const char *filename) {
|
||||||
bool status = false;
|
bool status = false;
|
||||||
unsigned int fsize = 0;
|
printf("fsize is %i\n", filesize);
|
||||||
char *filedata = loadfile(filename, &fsize);
|
if (filedata != NULL && filesize != 0) {
|
||||||
printf("fsize is %i\n", fsize);
|
|
||||||
if (filedata != NULL && fsize != 0) {
|
|
||||||
struct PldHeader *pldh = getpldh(filedata);
|
struct PldHeader *pldh = getpldh(filedata);
|
||||||
splitpld(filedata, pldh, filename, fsize);
|
splitpld(filedata, pldh, filename, filesize);
|
||||||
free(pldh -> offsets);
|
destroypldh(pldh);
|
||||||
free(pldh);
|
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
free(filedata);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
char *f = argv[1];
|
char *f = argv[1];
|
||||||
unpackpld(f);
|
unsigned int bufsize = 0;
|
||||||
|
char *buffer = loadfile(f, &bufsize);
|
||||||
|
unpackpld(buffer, bufsize, f);
|
||||||
|
free(buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user