zgrf 1.0.1

Library to interact with Gravity's GRF files.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:


This package provides sub packages which can be used individually:

zgrf:compression - zgrf compression algorithms

zgrf:crypto - zgrf crypto algorithms

zgrf

Library to interact with Gravity's resource and patch file (GRF/GPF).

Documentation

The documentation can be found here: https://zgrf.dpldocs.info

Building

Requirements

  • DMD, LDC or GDC

Additionally in order to compile the LZMA library a c compiler is required. For linux that would be

  • gcc

and for Windows

  • msvc

To obtain msvc on Windows you will need the Build Tools for Visual Studio.

Compiling

Linux

If everything is present simply run dub build

Windows

From within the Developer Console that will be available after installing the Build Tools run dub build

Example

Extract all files in a grf/gpf

import zgrf;

int main(string[] args)
{
    GRF grf = GRF("data.grf");

    scope(exit)
        grf.close();

    // At this point nothing is yet loaded
    // Let's parse the GRF and load the header + filetable
    grf.parse();

    // We now have access to the header and filetable
    import std.stdio : writefln;
    writefln("GRF Version: 0x%0X", grf.header.grfVersion);

    // Let's extract all files
    ulong fileindex = 0;
    ulong filecount = grf.files.length;
    foreach (ref GRFFile file; grf.files)
    {
        import std.path : dirName;

        // Filenames are stored with Windows paths
        version(Posix)
        {
            import std.array : replace;
            wstring fullpath = file.name.replace("\\"w, "/"w);
            wstring path = dirName(fullpath);
        }
        else
        {
            // Windows, no need to change anything
            wstring fullpath = file.name;
            wstring path = dirName(file.name);
        }

        // Print some progress
        writefln("Extracting (%d/%d): %s", fileindex + 1, filecount, fullpath);

        import std.file : mkdirRecurse;
        import std.utf : toUTF8;

        mkdirRecurse(path.toUTF8);

        // Unencrypt und decompress file data
        const data = file.getFileData();

        import std.stdio : File;

        auto fout = File(fullpath, "w+");
        fout.rawWrite(data);
        fout.close();

        fileindex++;
    }
}
Authors:
  • zhad3
Sub packages:
zgrf:compression, zgrf:crypto
Dependencies:
zencoding:windows949, zgrf:compression, zgrf:crypto
Versions:
2.1.1 2024-Mar-10
2.1.0 2024-Mar-08
2.0.1 2023-Jan-26
2.0.0 2022-Sep-17
1.1.0 2021-Oct-23
Show all 12 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 3 downloads this month

  • 103 downloads total

Score:
1.1
Short URL:
zgrf.dub.pm