From e3ba6b5053cc4678870f37d3bd5f0df192976c8d Mon Sep 17 00:00:00 2001 From: kvtorp Date: Mon, 16 Jan 2017 12:09:20 +0000 Subject: [PATCH] Added workaround to loading zero-length files Changed the use of CL_ABAP_ZIP to use the FILES attribute rather than use the SPLICE method, as the latter does not return zero-length files --- src/zabapgit_zip.prog.abap | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/zabapgit_zip.prog.abap b/src/zabapgit_zip.prog.abap index 45667324e..497f0b474 100644 --- a/src/zabapgit_zip.prog.abap +++ b/src/zabapgit_zip.prog.abap @@ -27,12 +27,12 @@ CLASS lcl_zip DEFINITION FINAL. PRIVATE SECTION. CLASS-METHODS file_upload - RETURNING value(rv_xstr) TYPE xstring + RETURNING VALUE(rv_xstr) TYPE xstring RAISING lcx_exception. CLASS-METHODS unzip_file IMPORTING iv_xstr TYPE xstring - RETURNING value(rt_files) TYPE ty_files_tt + RETURNING VALUE(rt_files) TYPE ty_files_tt RAISING lcx_exception. CLASS-METHODS normalize_path @@ -52,11 +52,11 @@ CLASS lcl_zip DEFINITION FINAL. CLASS-METHODS encode_files IMPORTING it_files TYPE ty_files_item_tt - RETURNING value(rv_xstr) TYPE xstring + RETURNING VALUE(rv_xstr) TYPE xstring RAISING lcx_exception. CLASS-METHODS get_message - RETURNING value(rv_message) TYPE string + RETURNING VALUE(rv_message) TYPE string RAISING lcx_exception. ENDCLASS. "lcl_zip DEFINITION @@ -341,12 +341,11 @@ CLASS lcl_zip IMPLEMENTATION. METHOD unzip_file. - DATA: lo_zip TYPE REF TO cl_abap_zip, - lv_xstr TYPE xstring, - lt_splice TYPE cl_abap_zip=>t_splice_entries. + DATA: lo_zip TYPE REF TO cl_abap_zip, + lv_data TYPE xstring. - FIELD-SYMBOLS: LIKE LINE OF lt_splice, - LIKE LINE OF rt_files. + FIELD-SYMBOLS: TYPE cl_abap_zip=>t_file, + LIKE LINE OF rt_files. CREATE OBJECT lo_zip. @@ -359,14 +358,13 @@ CLASS lcl_zip IMPLEMENTATION. lcx_exception=>raise( 'error from zip' ). ENDIF. - lt_splice = cl_abap_zip=>splice( iv_xstr ). + LOOP AT lo_zip->files ASSIGNING . - LOOP AT lt_splice ASSIGNING . lo_zip->get( EXPORTING - name = -name + name = -name IMPORTING - content = lv_xstr + content = lv_data EXCEPTIONS zip_index_error = 1 zip_decompression_error = 2 @@ -379,12 +377,12 @@ CLASS lcl_zip IMPLEMENTATION. filename( EXPORTING - iv_str = -name + iv_str = -name IMPORTING ev_path = -path ev_filename = -filename ). - -data = lv_xstr. + -data = lv_data. -sha1 = lcl_hash=>sha1( iv_type = gc_type-blob iv_data = -data ).