Browse Source

Test zip decompression

master
Macoy Madson 6 months ago
parent
commit
10b679ec7b
  1. 1
      ReadMe.org
  2. 23
      src/Compression.cake
  3. BIN
      test/test.zip

1
ReadMe.org

@ -109,6 +109,7 @@ Here are the known compatibility results, where blank means untested/unknown:
| ImGui.cake | Yes | No[1] | Yes | |
| ImGuiSDLOpenGL.cpp | Yes | No[1] | Yes | |
| Introspection.cake | Yes | Yes | Yes | Yes |
| Licenses.cake | Yes | Yes | Yes | Yes |
| Math.cake | Yes | Yes | Yes | Yes |
| Ogre.cake | Yes | | | |
| OgreInitialize.cake | Yes | | | |

23
src/Compression.cake

@ -11,6 +11,29 @@
(c-import "<stdio.h>" "miniz.h")
(defun test--compression (&return int)
(fprintf stderr "miniz version %s\n" (mz_version))
(var zip-filename (* (const char)) "test.zip")
(var archive mz_zip_archive)
(mz_zip_zero_struct (addr archive))
(unless (mz_zip_reader_init_file (addr archive) zip-filename 0)
(fprintf stderr "error: failed to open %s\n" zip-filename)
(return 1))
(var num-files (unsigned int) (mz_zip_reader_get_num_files (addr archive)))
(fprintf stderr "Archive has %d files\n" num-files)
(var filename-buffer ([] 1024 char) (array 0))
(var output-filename-buffer ([] 2048 char) (array 0))
(each-in-range num-files i
(mz_zip_reader_get_filename (addr archive) i filename-buffer (sizeof filename-buffer))
(sprintf output-filename-buffer "%s" filename-buffer)
(unless (mz_zip_reader_extract_to_file (addr archive) i output-filename-buffer 0)
(fprintf stderr "Failed to extract %s to %s\n" filename-buffer output-filename-buffer)
(mz_zip_reader_end (addr archive))
(return 1))
(fprintf stderr "Extracted %s to %s\n" filename-buffer output-filename-buffer))
(mz_zip_reader_end (addr archive))
(return 0))))
(add-c-search-directory-module "Dependencies/miniz"

BIN
test/test.zip

Binary file not shown.
Loading…
Cancel
Save