fixed typecasts and changed Rsrc_load_file to use zip sources
This commit is contained in:
		
							parent
							
								
									333e40827e
								
							
						
					
					
						commit
						bda9fc6883
					
				@ -87,11 +87,12 @@ HRESULT Rsrc_load_file(PCSTR filename, PHRESFILE newhandle)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  HRESULT hr = S_OK;
 | 
					  HRESULT hr = S_OK;
 | 
				
			||||||
  PRESFILE pfile = NULL;
 | 
					  PRESFILE pfile = NULL;
 | 
				
			||||||
 | 
					  zip_source_t *source;
 | 
				
			||||||
  zip_error_t errinfo;
 | 
					  zip_error_t errinfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!newhandle)
 | 
					  if (!newhandle)
 | 
				
			||||||
    return E_POINTER;
 | 
					    return E_POINTER;
 | 
				
			||||||
  *newhandle = NULL;
 | 
					  *newhandle = (HRESFILE)NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pfile = (PRESFILE)malloc(sizeof(RESFILE));
 | 
					  pfile = (PRESFILE)malloc(sizeof(RESFILE));
 | 
				
			||||||
  if (!pfile)
 | 
					  if (!pfile)
 | 
				
			||||||
@ -99,7 +100,13 @@ HRESULT Rsrc_load_file(PCSTR filename, PHRESFILE newhandle)
 | 
				
			|||||||
  memset(pfile, 0, sizeof(RESFILE));
 | 
					  memset(pfile, 0, sizeof(RESFILE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  zip_error_init(&errinfo);
 | 
					  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))
 | 
					  if (!(pfile->resource))
 | 
				
			||||||
    hr = ziperror_to_hresult(&errinfo);
 | 
					    hr = ziperror_to_hresult(&errinfo);
 | 
				
			||||||
  zip_error_fini(&errinfo);
 | 
					  zip_error_fini(&errinfo);
 | 
				
			||||||
@ -167,7 +174,7 @@ HRESULT Rsrc_find_resource(HRESFILE hfile, PCSTR name, PCSTR type, PHRSRC presou
 | 
				
			|||||||
    return E_INVALIDARG;
 | 
					    return E_INVALIDARG;
 | 
				
			||||||
  if (!presource)
 | 
					  if (!presource)
 | 
				
			||||||
    return E_POINTER;
 | 
					    return E_POINTER;
 | 
				
			||||||
  *presource = NULL;
 | 
					  *presource = (HRSRC)NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  index = zip_name_locate(theresource, name, ZIP_FL_NOCASE);
 | 
					  index = zip_name_locate(theresource, name, ZIP_FL_NOCASE);
 | 
				
			||||||
  if (index < 0)
 | 
					  if (index < 0)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user