Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x 4x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 2x 2x 2x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_path DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. CLASS-METHODS split_file_location IMPORTING iv_fullpath TYPE string EXPORTING ev_path TYPE string ev_filename TYPE string. CLASS-METHODS is_root IMPORTING iv_path TYPE string RETURNING VALUE(rv_yes) TYPE abap_bool. CLASS-METHODS is_subdir IMPORTING iv_path TYPE string iv_parent TYPE string RETURNING VALUE(rv_yes) TYPE abap_bool. CLASS-METHODS change_dir IMPORTING iv_cur_dir TYPE string iv_cd TYPE string RETURNING VALUE(rv_path) TYPE string. CLASS-METHODS get_filename_from_syspath IMPORTING iv_path TYPE string RETURNING VALUE(rv_filename) TYPE string. ENDCLASS. CLASS ZCL_ABAPGIT_PATH IMPLEMENTATION. METHOD change_dir. DATA: lv_last TYPE i, lv_temp TYPE string. lv_last = strlen( iv_cur_dir ) - 1. IF iv_cd = '' OR iv_cd = '.'. " No change rv_path = iv_cur_dir. ELSEIF iv_cd+0(1) = '/'. " Absolute path rv_path = iv_cd. ELSEIF iv_cd = '..'. " CD back IF iv_cur_dir = '/' OR iv_cur_dir = ''. " Back from root = root rv_path = iv_cur_dir. ELSE. lv_temp = reverse( iv_cur_dir ). IF lv_temp+0(1) = '/'. SHIFT lv_temp BY 1 PLACES LEFT. ENDIF. SHIFT lv_temp UP TO '/' LEFT. rv_path = reverse( lv_temp ). ENDIF. ELSEIF iv_cur_dir+lv_last(1) = '/'. " Append cd to cur_dir separated by / rv_path = iv_cur_dir && iv_cd. ELSE. rv_path = iv_cur_dir && '/' && iv_cd. ENDIF. " TODO: improve logic and cases ENDMETHOD. METHOD get_filename_from_syspath. DATA: lv_split TYPE c LENGTH 1, lv_index TYPE i, lt_split TYPE TABLE OF string. " filename | c:\filename | /dir/filename | \\server\filename IF iv_path CA '/'. lv_split = '/'. ELSE. lv_split = '\'. ENDIF. SPLIT iv_path AT lv_split INTO TABLE lt_split. lv_index = lines( lt_split ). READ TABLE lt_split INDEX lv_index INTO rv_filename. ENDMETHOD. METHOD is_root. rv_yes = boolc( iv_path = '/' ). ENDMETHOD. METHOD is_subdir. DATA lv_len TYPE i. DATA lv_last TYPE i. lv_len = strlen( iv_parent ). lv_last = lv_len - 1. rv_yes = boolc( strlen( iv_path ) > lv_len AND iv_path+0(lv_len) = iv_parent AND ( iv_parent+lv_last(1) = '/' OR iv_path+lv_len(1) = '/' ) ). ENDMETHOD. METHOD split_file_location. DATA: lv_cnt TYPE i, lv_len TYPE i. FIND FIRST OCCURRENCE OF REGEX '^/(.*/)?' IN iv_fullpath MATCH COUNT lv_cnt MATCH LENGTH lv_len. IF lv_cnt > 0. ev_path = iv_fullpath+0(lv_len). ev_filename = iv_fullpath+lv_len. ELSE. CLEAR ev_path. ev_filename = iv_fullpath. ENDIF. ev_filename = cl_http_utility=>unescape_url( escaped = ev_filename ). ENDMETHOD. ENDCLASS. |