zgrf 1.0.5

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;
        import std.typecons : No;

        mkdirRecurse(path.toUTF8);

        // Unencrypt and decompress file data. We also disable cache.
        const data = file.getFileData(No.useCache);

        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:
1.0.5 2021-Aug-28
1.0.4 2021-Jul-03
1.0.3 2021-Jul-03
1.0.2 2021-Jul-02
1.0.1 2021-Jul-02
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 6 downloads total

Score:
0.2
Short URL:
zgrf.dub.pm