MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / unzGetLocalExtrafield

Function unzGetLocalExtrafield

src/Setup/unzip.cpp:3613–3649  ·  view source on GitHub ↗

Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of by

Source from the content-addressed store, hash-verified

3611// if buf!=NULL, len is the size of the buffer, the extra header is copied in buf.
3612// the return value is the number of bytes copied in buf, or (if <0) the error code
3613int unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
3614{
3615 unz_s* s;
3616 file_in_zip_read_info_s* pfile_in_zip_read_info;
3617 uInt read_now;
3618 uLong size_to_read;
3619
3620 if (file==NULL)
3621 return UNZ_PARAMERROR;
3622 s=(unz_s*)file;
3623 pfile_in_zip_read_info=s->pfile_in_zip_read;
3624
3625 if (pfile_in_zip_read_info==NULL)
3626 return UNZ_PARAMERROR;
3627
3628 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
3629 pfile_in_zip_read_info->pos_local_extrafield);
3630
3631 if (buf==NULL)
3632 return (int)size_to_read;
3633
3634 if (len>size_to_read)
3635 read_now = (uInt)size_to_read;
3636 else
3637 read_now = (uInt)len ;
3638
3639 if (read_now==0)
3640 return 0;
3641
3642 if (lufseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
3643 return UNZ_ERRNO;
3644
3645 if (lufread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
3646 return UNZ_ERRNO;
3647
3648 return (int)read_now;
3649}
3650
3651// Close the file in zip opened with unzipOpenCurrentFile
3652// Return UNZ_CRCERROR if all the file was read but the CRC is not good

Callers

nothing calls this directly

Calls 2

lufseekFunction · 0.85
lufreadFunction · 0.85

Tested by

no test coverage detected