summaryrefslogtreecommitdiff
path: root/core/io/file_access_zip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/file_access_zip.cpp')
-rw-r--r--core/io/file_access_zip.cpp35
1 files changed, 0 insertions, 35 deletions
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index 9d068fe809..5dde5aa6ce 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -40,7 +40,6 @@ ZipArchive *ZipArchive::instance = nullptr;
extern "C" {
static void *godot_open(void *data, const char *p_fname, int mode) {
-
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
return nullptr;
}
@@ -52,30 +51,25 @@ static void *godot_open(void *data, const char *p_fname, int mode) {
}
static uLong godot_read(void *data, void *fdata, void *buf, uLong size) {
-
FileAccess *f = (FileAccess *)data;
f->get_buffer((uint8_t *)buf, size);
return size;
}
static uLong godot_write(voidpf opaque, voidpf stream, const void *buf, uLong size) {
-
return 0;
}
static long godot_tell(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
return f->get_position();
}
static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
-
FileAccess *f = (FileAccess *)opaque;
int pos = offset;
switch (origin) {
-
case ZLIB_FILEFUNC_SEEK_CUR:
pos = f->get_position() + offset;
break;
@@ -91,32 +85,27 @@ static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
}
static int godot_close(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
f->close();
return 0;
}
static int godot_testerror(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
return f->get_error() != OK ? 1 : 0;
}
static voidpf godot_alloc(voidpf opaque, uInt items, uInt size) {
-
return memalloc(items * size);
}
static void godot_free(voidpf opaque, voidpf address) {
-
memfree(address);
}
} // extern "C"
void ZipArchive::close_handle(unzFile p_file) const {
-
ERR_FAIL_COND_MSG(!p_file, "Cannot close a file if none is open.");
FileAccess *f = (FileAccess *)unzGetOpaque(p_file);
unzCloseCurrentFile(p_file);
@@ -125,7 +114,6 @@ void ZipArchive::close_handle(unzFile p_file) const {
}
unzFile ZipArchive::get_file_handle(String p_file) const {
-
ERR_FAIL_COND_V_MSG(!file_exists(p_file), nullptr, "File '" + p_file + " doesn't exist.");
File file = files[p_file];
@@ -152,7 +140,6 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
ERR_FAIL_COND_V(!pkg, nullptr);
int unz_err = unzGoToFilePos(pkg, &file.file_pos);
if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) {
-
unzClose(pkg);
ERR_FAIL_V(nullptr);
}
@@ -161,7 +148,6 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
}
bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
-
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
if (p_path.get_extension().nocasecmp_to("zip") != 0 && p_path.get_extension().nocasecmp_to("pcz") != 0)
return false;
@@ -195,7 +181,6 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
int pkg_num = packages.size() - 1;
for (uint64_t i = 0; i < gi.number_entry; i++) {
-
char filename_inzip[256];
unz_file_info64 file_info;
@@ -222,17 +207,14 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
}
bool ZipArchive::file_exists(String p_name) const {
-
return files.has(p_name);
}
FileAccess *ZipArchive::get_file(const String &p_path, PackedData::PackedFile *p_file) {
-
return memnew(FileAccessZip(p_path, *p_file));
}
ZipArchive *ZipArchive::get_singleton() {
-
if (instance == nullptr) {
instance = memnew(ZipArchive);
}
@@ -245,9 +227,7 @@ ZipArchive::ZipArchive() {
}
ZipArchive::~ZipArchive() {
-
for (int i = 0; i < packages.size(); i++) {
-
FileAccess *f = (FileAccess *)unzGetOpaque(packages[i].zfile);
unzClose(packages[i].zfile);
memdelete(f);
@@ -257,7 +237,6 @@ ZipArchive::~ZipArchive() {
}
Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
-
close();
ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, FAILED);
@@ -273,7 +252,6 @@ Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessZip::close() {
-
if (!zfile)
return;
@@ -284,50 +262,42 @@ void FileAccessZip::close() {
}
bool FileAccessZip::is_open() const {
-
return zfile != nullptr;
}
void FileAccessZip::seek(size_t p_position) {
-
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, p_position);
}
void FileAccessZip::seek_end(int64_t p_position) {
-
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, get_len() + p_position);
}
size_t FileAccessZip::get_position() const {
-
ERR_FAIL_COND_V(!zfile, 0);
return unztell(zfile);
}
size_t FileAccessZip::get_len() const {
-
ERR_FAIL_COND_V(!zfile, 0);
return file_info.uncompressed_size;
}
bool FileAccessZip::eof_reached() const {
-
ERR_FAIL_COND_V(!zfile, true);
return at_eof;
}
uint8_t FileAccessZip::get_8() const {
-
uint8_t ret = 0;
get_buffer(&ret, 1);
return ret;
}
int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V(!zfile, -1);
at_eof = unzeof(zfile);
if (at_eof)
@@ -340,9 +310,7 @@ int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessZip::get_error() const {
-
if (!zfile) {
-
return ERR_UNCONFIGURED;
}
if (eof_reached()) {
@@ -353,17 +321,14 @@ Error FileAccessZip::get_error() const {
}
void FileAccessZip::flush() {
-
ERR_FAIL();
}
void FileAccessZip::store_8(uint8_t p_dest) {
-
ERR_FAIL();
}
bool FileAccessZip::file_exists(const String &p_name) {
-
return false;
}