CarlosHenrq

php-grf

5 posts in this topic

Hi guys,

I'm here to share with you my new project php-grf, with this guy you can use PHP to read and write grf files.

  • This only supports grf files with version 0x200;
  • This supports read and writing in grf files;

This code is based on https://github.com/MagicalTux/grf

The code ahead will show you how to extract all files inside grf.

<?php
require_once 'php-grf/lib/autoload.php';

// Instance a reader/writer for your grf file
$grf = new GrfFile('php-grf/tests/test200.grf');

foreach ($grf->getEntries() as $entry) {
    $dir = dirname($entry->getFilename());

    if (is_dir($dir) === false)
        mkdir ($dir, 0777, true);

    $file = str_replace('\\', '/', $entry->getFilename());
    $buffer = $entry->getUnCompressedBuffer();

    $fp = fopen($file, 'wb');
    fwrite($fp, $buffer);
    fflush($fp);
    fclose($fp);
}

// Dispose all resources used
$grf = null;

 

Enjoy it, has any issue or problem with the lib? Please report it and help to keep it good for you all use.

Repo URL: https://github.com/carloshenrq/php-grf

 

Other useful repositories:

https://github.com/arminherling/GRF/ (Read-only C#)

https://github.com/MagicalTux/grf (Read-Write C)

Edited by CarlosHenrq

Share this post


Link to post
Share on other sites

nice effort. im a noob, what practical application does this have?

Share this post


Link to post
Share on other sites
1 hour ago, Myriad said:

nice effort. im a noob, what practical application does this have?

Hi!

As I'm building an updater (like thor patcher), this can allow me to create new features like check files inside GRF comparing local files with server files and download only files not equals to the server.

Another practical application is something like RoChargenPHP.

Edited by CarlosHenrq

Share this post


Link to post
Share on other sites
4 hours ago, vykimo said:

Yes in fact rochargenphp uses the same principle as you, isn't it? 

I don't know the code from ROChargenPHP, but I suppose yes. He reads GRF or a data folder extracted.

This is only for reading and writing at GRF files. Not for parsing .spr, .act or .pal files.

We can create an PHPGrfEditor with this one :v

I've searched a little and found this Grf class in ROChargenPHP https://github.com/ScDarko/ROChargenPHP/blob/master/loaders/class.Grf.php

 

Just for update, this now reads and writes grf files.

Edited by CarlosHenrq

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now