|
@@ -118,6 +118,21 @@ PackedByteArray ZIPReader::read_file(String p_path, bool p_case_sensitive) {
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool ZIPReader::file_exists(String p_path, bool p_case_sensitive) {
|
|
|
|
+ ERR_FAIL_COND_V_MSG(fa.is_null(), false, "ZIPReader must be opened before use.");
|
|
|
|
+
|
|
|
|
+ int cs = p_case_sensitive ? 1 : 2;
|
|
|
|
+ if (unzLocateFile(uzf, p_path.utf8().get_data(), cs) != UNZ_OK) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (unzOpenCurrentFile(uzf) != UNZ_OK) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ unzCloseCurrentFile(uzf);
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
ZIPReader::ZIPReader() {}
|
|
ZIPReader::ZIPReader() {}
|
|
|
|
|
|
ZIPReader::~ZIPReader() {
|
|
ZIPReader::~ZIPReader() {
|
|
@@ -131,4 +146,5 @@ void ZIPReader::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("close"), &ZIPReader::close);
|
|
ClassDB::bind_method(D_METHOD("close"), &ZIPReader::close);
|
|
ClassDB::bind_method(D_METHOD("get_files"), &ZIPReader::get_files);
|
|
ClassDB::bind_method(D_METHOD("get_files"), &ZIPReader::get_files);
|
|
ClassDB::bind_method(D_METHOD("read_file", "path", "case_sensitive"), &ZIPReader::read_file, DEFVAL(Variant(true)));
|
|
ClassDB::bind_method(D_METHOD("read_file", "path", "case_sensitive"), &ZIPReader::read_file, DEFVAL(Variant(true)));
|
|
|
|
+ ClassDB::bind_method(D_METHOD("file_exists", "path", "case_sensitive"), &ZIPReader::file_exists, DEFVAL(Variant(true)));
|
|
}
|
|
}
|