| 13 | #include "utility/file_access_buffer.h" |
| 14 | |
| 15 | bool DirSource::try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset, const Vector<uint8_t> &p_decryption_key) { |
| 16 | if (!DirAccess::exists(p_path)) { |
| 17 | return false; |
| 18 | } |
| 19 | Ref<DirAccess> da = DirAccess::open(p_path); |
| 20 | if (da.is_null()) { |
| 21 | return false; |
| 22 | } |
| 23 | PackedStringArray pa = gdre::get_recursive_dir_list(p_path, {}, false); |
| 24 | if (is_print_verbose_enabled()) { |
| 25 | for (auto s : pa) { |
| 26 | print_verbose(s); |
| 27 | } |
| 28 | } |
| 29 | Ref<GDRESettings::PackInfo> pckinfo; |
| 30 | pckinfo.instantiate(); |
| 31 | pckinfo->init(p_path, Ref<GodotVer>(memnew(GodotVer)), 1, 0, 0, pa.size(), GDRESettings::PackInfo::DIR); |
| 32 | GDRESettings::get_singleton()->add_pack_info(pckinfo); |
| 33 | for (auto &path : pa) { |
| 34 | size_t size = 0; |
| 35 | Ref<FileAccess> fa = FileAccess::open(p_path.path_join(path), FileAccess::READ); |
| 36 | if (fa.is_valid()) { |
| 37 | size = fa->get_length(); |
| 38 | } |
| 39 | GDREPackedData::get_singleton()->add_path(p_path, path, 1, size, MD5_EMPTY, this, p_replace_files, false, false); |
| 40 | } |
| 41 | packs.push_back(p_path); |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | Ref<FileAccess> DirSource::get_file(const String &p_path, PackedData::PackedFile *p_file, const Vector<uint8_t> &p_decryption_key) { |
| 46 | if (!p_file) { |
no test coverage detected