futility/updater_archive.c
/* Callback for archive_zip_write_file on a ZIP file. */
Callback for archive_zip_write_file on a ZIP file.
Callback for archive_zip_write_file on a ZIP file .
static int archive_zip_write_file(void *handle, const char *fname,
				  uint8_t *data, uint32_t size, int64_t mtime)
{
	struct zip *zip = (struct zip *)handle;
	struct zip_source *src;
	VB2_DEBUG("Writing %s\n", fname);
	assert(zip);
	src = zip_source_buffer(zip, data, size, 0);
	if (!src) {
		ERROR("Internal error: cannot allocate buffer: %s\n", fname);
		return 1;
	}
	if (zip_file_add(zip, fname, src, ZIP_FL_OVERWRITE) < 0) {
		zip_source_free(src);
		ERROR("Internal error: failed to add: %s\n", fname);
		return 1;
	}
#if LIBZIP_VERSION_MAJOR >= 1
	zip_file_set_mtime(zip, zip_name_locate(zip, fname, 0), mtime, 0);
#endif
	return 0;
}
static int archive_zip_write_file ( void * handle , const char * fname , uint8_t * data , uint32_t size , int64_t mtime ) { struct zip * zip = ( struct zip * ) handle ; struct zip_source * src ; VB2_DEBUG ( " \n " , fname ) ; assert ( zip ) ; src = zip_source_buffer ( zip , data , size , 0 ) ; if ( ! src ) { ERROR ( " \n " , fname ) ; return 1 ; } if ( zip_file_add ( zip , fname , src , ZIP_FL_OVERWRITE ) < 0 ) { zip_source_free ( src ) ; ERROR ( " \n " , fname ) ; return 1 ; } #if LIBZIP_VERSION_MAJOR >= 1 zip_file_set_mtime ( zip , zip_name_locate ( zip , fname , 0 ) , mtime , 0 ) ; #endif return 0 ; }
Callback for archive_zip_write_file on a ZIP file.
Callback for archive_zip_write_file on a ZIP file .
/* zip_source_free is not needed if zip_file_add success. */