Extract .rar and .7z on Godot in GDscript

Godot Version

4.7.1

Question

Actually trying to extract files from an API in GDscript but some are ZIP files (not a problem) others are .rar and .7z, is there a way to extract them like with the Zip reader ?

These formats require a different library to be able to extract them as far as I know, so it’s not possible unless you write a GDExtension.

Looks like this C++ library does not only extract 7z but also AR, ARJ, BZIP2, CAB, CHM, CPIO, CramFS, DEB, DMG, EXT, FAT, GPT, GZIP, HFS, HXS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RAR5, RPM, SquashFS, TAR, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR, XZ, Z GitHub - rikyoz/bit7z: A C++ static library offering a clean and simple interface to the 7-zip shared libraries. · GitHub

Here’s Godot’s code for the zip module godot/modules/zip at master · godotengine/godot · GitHub
and here’s minizip that is included as a thirdparty library. godot/thirdparty/minizip at master · godotengine/godot · GitHub
Maybe that gives you enough inspiration for your implementation. Who knows, you might be able to compile Godot and just replace that minizip library with bi7z and change only a few lines of code.

Don’t forget to read the FAQ of bit7z’s license first: MPL 2.0 FAQ — Mozilla