From bda9fc68833f9b907162b82e93e16aefa006bdc0 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 29 Aug 2021 22:07:45 -0600 Subject: [PATCH] fixed typecasts and changed Rsrc_load_file to use zip sources --- src/resources.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/resources.c b/src/resources.c index d49e32f..a29267c 100644 --- a/src/resources.c +++ b/src/resources.c @@ -87,11 +87,12 @@ HRESULT Rsrc_load_file(PCSTR filename, PHRESFILE newhandle) { HRESULT hr = S_OK; PRESFILE pfile = NULL; + zip_source_t *source; zip_error_t errinfo; if (!newhandle) return E_POINTER; - *newhandle = NULL; + *newhandle = (HRESFILE)NULL; pfile = (PRESFILE)malloc(sizeof(RESFILE)); if (!pfile) @@ -99,7 +100,13 @@ HRESULT Rsrc_load_file(PCSTR filename, PHRESFILE newhandle) memset(pfile, 0, sizeof(RESFILE)); zip_error_init(&errinfo); - pfile->resource = zip_open(filename, ZIP_RDONLY, &errinfo); + source = zip_source_file_create(filename, 0, 0, &errinfo); + if (source) + { + pfile->resource = zip_open_from_source(source, ZIP_RDONLY, &errinfo); + if (!(pfile->resource)) + zip_source_free(source); + } if (!(pfile->resource)) hr = ziperror_to_hresult(&errinfo); zip_error_fini(&errinfo); @@ -167,7 +174,7 @@ HRESULT Rsrc_find_resource(HRESFILE hfile, PCSTR name, PCSTR type, PHRSRC presou return E_INVALIDARG; if (!presource) return E_POINTER; - *presource = NULL; + *presource = (HRSRC)NULL; index = zip_name_locate(theresource, name, ZIP_FL_NOCASE); if (index < 0)