zthor 2.1.0

Library to interact with the THOR file format used as patch files for the game Ragnarok Online


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:

zthor

Library to interact with Aeomin's THOR patchers file format.

Documentation

The documentation can be found here: https://zthor.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 zthor;

THOR thor = THOR("patch.thor");

scope(exit)
    thor.close();

thor.parse(["data\\wav\\*"]);

import std.stdio : writefln;

// Let's extract all files
ulong fileindex = 0;
ulong filecount = thor.files.length;
foreach (ref THORFile file; thor.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("output/" ~ path.toUTF8);

    // Decompress file data
    const data = file.getFileData();

    import std.stdio : File;

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

    fileindex++;
}
}
Authors:
  • zhad3
Dependencies:
zencoding:windows949, zgrf:compression, zgrf:crypto
Versions:
2.1.0 2024-Mar-10
2.0.1 2022-Sep-17
2.0.0 2022-Sep-17
1.0.1 2021-Dec-01
1.0.0 2021-Nov-28
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 3 downloads this week

  • 5 downloads this month

  • 82 downloads total

Score:
0.9
Short URL:
zthor.dub.pm