| 64 | } |
| 65 | |
| 66 | PackedStringArray ZIPReader::get_files() { |
| 67 | ERR_FAIL_COND_V_MSG(fa.is_null(), PackedStringArray(), "ZIPReader must be opened before use."); |
| 68 | |
| 69 | unz_global_info gi; |
| 70 | int err = unzGetGlobalInfo(uzf, &gi); |
| 71 | ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray()); |
| 72 | if (gi.number_entry == 0) { |
| 73 | return PackedStringArray(); |
| 74 | } |
| 75 | |
| 76 | err = unzGoToFirstFile(uzf); |
| 77 | ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray()); |
| 78 | |
| 79 | List<String> s; |
| 80 | do { |
| 81 | unz_file_info64 file_info; |
| 82 | String filepath; |
| 83 | |
| 84 | err = godot_unzip_get_current_file_info(uzf, file_info, filepath); |
| 85 | if (err == UNZ_OK) { |
| 86 | s.push_back(filepath); |
| 87 | } |
| 88 | } while (unzGoToNextFile(uzf) == UNZ_OK); |
| 89 | |
| 90 | PackedStringArray arr; |
| 91 | arr.resize(s.size()); |
| 92 | int idx = 0; |
| 93 | for (const List<String>::Element *E = s.front(); E; E = E->next()) { |
| 94 | arr.set(idx++, E->get()); |
| 95 | } |
| 96 | return arr; |
| 97 | } |
| 98 | |
| 99 | PackedByteArray ZIPReader::read_file(const String &p_path, bool p_case_sensitive) { |
| 100 | ERR_FAIL_COND_V_MSG(fa.is_null(), PackedByteArray(), "ZIPReader must be opened before use."); |
no test coverage detected