Skip to content

UdonZip is a ZIP parser written in Udon for VRChat.

License

Notifications You must be signed in to change notification settings

Foorack/UdonZip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UdonZip

Discord - Feel free to join if you have any bugs or questions!

UdonZip is a ZIP parser written in Udon for VRChat. The purpose of this project is for it to be used as an API in other bigger projects. This work is something the average VRChatter never will notice, but something the author hopes might be beneficial and make the life easier for world/game creators in VRChat.

An example use of this library is allowing the player to paste the entire contents of an zip file (e.g. game save file) into an Input field in VRC, and allowing the world to then parse the submitted data. For this purpose a full XML library has already been implemented, which you can find here, called UdonXML.

πŸ› οΈ Setup

Requirements

Installation

  1. Go to Releases and download the latest release. The file should end with unitypackage. If you can't find it, ask for help on Discord.
  2. Import the package into Unity with Assets > Import Package > Custom Package. This will import the files to Resources > Foorack > UdonZip.
  3. Create an Empty GameObject in your Scene, name it UdonZip and assign it the UdonZip UdonBehaviour.

Getting started

  1. Declare a public UdonZip udonZip; variable in your program.
  2. Assign it the value of the UdonZip GameObject in your scene.
  3. Extract your Zip data file with Extract udonZip.Extract(inputData);. It will return an object.
  4. The object returned represents the archive of the Zip, use it when executing other API functions such as GetFile or GetFileData.

Example demo

using UnityEngine;
using UdonSharp;

public class UdonZipTest : UdonSharpBehaviour
{
    public UdonZip udonZip;

    private string EXAMPLE_DATA_1 =
        "UEsDBBQAAAAAAPVljFD4cLMKBQAAAAUAAAAIAAAAdGVzdC50eHRIZWxsdVBLAQIUABQAAAAAAPVljFD4cLMKBQAAAAUAAAAIAAAAAAAAAAEAIAAAAAAAAAB0ZXN0LnR4dFBLBQYAAAAAAQABADYAAAArAAAAAAA";

    private string EXAMPLE_DATA_2 =
        "UEsDBAoAAAAAAIdO4kAAAAAAAAAAAAAAAAAJAAAAZG9jUHJvcHMvUEsDBBQAAAAIAIdO4kDPOEGeWwEAAHACAAAQAAAAZ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AB3b3JkL2ZvbnRUYWJsZS54bWxQSwECFAAUAAAACACHTuJArrb1i9YDAABeCQAAEQAAAAAAAAABACAAAADoDQAAd29yZC9zZXR0aW5ncy54bWxQSwECFAAUAAAACACHTuJA6HWbYkkJAAD0ZAAADwAAAAAAAAABACAAAAByBAAAd29yZC9zdHlsZXMueG1sUEsBAhQACgAAAAAAh07iQAAAAAAAAAAAAAAAAAsAAAAAAAAAAAAQAAAA7REAAHdvcmQvdGhlbWUvUEsBAhQAFAAAAAgAh07iQNGu78T4BQAAJBkAABUAAAAAAAAAAQAgAAAAFhIAAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLBQYAAAAAFQAVABkFAABLJQAAAAA";
    
    public void Start()
    {
        var data = EXAMPLE_DATA_2;
        // When you select "MIME Tools > Base64 Encode" it does it without padding
        // Append padding '=' if necessary until length is divisible by 4.
        while (data.Length % 4 != 0)
        {
            data += "=";
        }
        Debug.Log("data-length: " + data.Length);
        
        // Extract the ZIP file and give an archive representation object
        var archive = udonZip.Extract(Convert.FromBase64String(data));
        // Fetches the "File" representation object, containing data such as "last modified", CRC and extra fields. 
        var file = udonZip.GetFile(archive, "word/document.xml");
        // Fetches the actual file data, the raw bytes decompressed.
        //   The first time you access a file it will decompress it if necessary.
        //   The second time and on it will always return the already compressed data, making it significantly faster.
        var fileData = udonZip.GetFileData(file);
        // Efficiently converts the byte array to a string by casting each byte to char.
        char[] rawXmlData = new char[fileData.Length];
        for (var i = 0; i != fileData.Length; i++)
        {
            rawXmlData[i] = (char) fileData[i];
        }

        Debug.Log("data:" + new String(rawXmlData));
    }
}

console output

πŸ“„ Documentation

Extracting data

🟣 object Extract(byte[] data)

Loads a Zip file into memory by extracting the provided input.

Returns null in case of parse failure. (no? this is lie)

Reading data

πŸ”΅ string[] GetFileNames(object archive)

Returns a string array of all file names. File names always include the full path.

πŸ”΅ object GetFile(object archive, string filePath)

Returns a file object representing the file with given filePath.

πŸ”΅ byte[] GetFileData(object file)

Returns a byte array containing the raw uncompressed data of the file.

The first time you access a file it will decompress it if necessary. The second time and on it will always return the already compressed data, making it significantly faster.

πŸš› Roadmap

  • Allowing to write and package Zip files, allowing the creation of Zip files.
  • Implementing CRC32 checksum verficiation of decompression.
  • Better error handling. Right now it is sketchy if given invalid/corrupt input data.

About

UdonZip is a ZIP parser written in Udon for VRChat.

Resources

License

Stars

Watchers

Forks

Packages

No packages published