[dev Tool] Ratpak 1.0


synkro

0xdeadbeef
Joined
Aug 26, 2003
Messages
823
Location
Germany
Website
Visit site
[About Ratpak]
A simple tool to put all your assets (.WAVs, .BMPs or what ever you use) into
one file. It also provides code to load files from ratpak files for usage in
your games or whatever you code (I hope not emus). THIS IS A FIRST RELEASE TO
SEE IF THERE IS ANY DEMAND FOR A TOOL LIKE THIS.
Ratpak does not support
compression/encryption yet. At the moment the files just checked with Crc32.

[Usage of Ratpak]
You can create a pakfile by calling ratpak like this:

CODE
ratpak <folder_with_assets> <yourfile.pak>


This will add all files in the folder and its subfolders to the pakfile with
the given name. As an example, with the following command you can create a
test pakfile (in the folder this READ.ME is in).

CODE
ratpak assets test.pak


[Test Ratpak]
In the folder catpak is example code for reading from pakfiles. Catpak also
works as a tester to check the crcs of all files. Try catpak with the pakfile
created above:

CODE
catpak test.pak test.dat


OR
CODE

catpakk test.pak bump.wav


[API]
Well, there is no real API per se. To get a file from a pakfile just use this
function:
CODE

char *Ratpak_getFile(const char *ratpakFile, const char *asset, uint32_t *out_filesize)


This function takes the name of the pakfile and the name of the file in the
pakfile as parameter. it returns a pointer to a buffer containig that file or
NULL otherwise. You can directly access the file now or something like
SDL_Rwops. Adding catpak.c and catpak.h to your project should work in most
cases. You can get details to the ratpak file format in the file
ratpakFormat.hpp. Extensions are welcome!

P.S. :

I have no Windows toolchain and can't provide a Windows executable at the moment. Anyone willing to help me out? I am going to release Ratpak when it has all the features I want it to have anyway. This is more a Beta realease. Maybe someone else did something similar/better; let me knwo. Same goes for anykind of C/C and feature request. (I promise nothing!)
 
This is excellent! Thank you so much for working on this, it will make development a lot easier, without having to bin2h every graphics sheet and sound file.

I hope the final will have a Windows binary, other than that, this is really cool :)
 
Alex. said:
I hope the final will have a Windows binary, other than that, this is really cool :)
I just need someone to compile it for win...
 
Last edited by a moderator:
Squidge said:
How come you come up with your own format rather than just using zlib?
so, where is the challenge in that?

PokeParadox said:
I had a look to see if I could quickly provide a win32 binary, but I couldn't see source for the actual packer... only the testing app and the ratpack format header...
I have to clean up the code first. I am also not quiet sure if there is dirent.h un Windows
 
Last edited by a moderator:
Buffers should be 'unsigned char' types as well; 'signed char' ('char' default is signed in most compilers) implies the buffers can go negative and wlel.. who wants byte -35? :)

Should allow ratpack to be a file or a buffer; a good packer shoudl allow for bin2c pak files :)

Good stuff, fun little project; I use zip myself.

jeff
 
skeezix said:
Buffers should be 'unsigned char' types as well; 'signed char' ('char' default is signed in most compilers) implies the buffers can go negative and wlel.. who wants byte -35? :)
yeah right! fixed!

skeezix said:
Should allow ratpack to be a file or a buffer; a good packer shoudl allow for bin2c pak files :)
you mean "somebody" would build a pakfile --> bin2c -> and then would like to access the pakfile from mem?!? sounds like a good idea... noted. Even though that would be a waste of mem, you have the assets two times loaded into mem (in the pakfile and extracted)

skeezix said:
Good stuff, fun little project; I use zip myself.
most people do, I think beginners avoid using "huge" libs with APIs they don't understand at first glance.
 
Last edited by a moderator:
synkro, you read in my brain !
this after noon i've search exactly this type of "lib" for gp2x :)

you save me lot of search and time :)

thank you !

EDIT: I suppose ratpak binary is only for linux OS ?
 
JyCet said:
synkro, you read in my brain !
this after noon i've search exactly this type of "lib" for gp2x :)

you save me lot of search and time :)

thank you !

EDIT: I suppose ratpak binary is only for linux OS ?
Yes, I can't compile a windows binary. I saw your "play mod from mem question" question and I just coded it for you!
 
Last edited by a moderator:
In truth I usually just use a perlscript .. it reads a dir full of files, and spits out a C and H files, as well as a function that loads them all into a linked list. I don't compress or the like, so I can just cal a 'resource-get' type function to get the pointer by name, and then good to go. Easy to install, and no waste of RAM.

When I want external files, I usually quake-it .. either files raw in trhe system, or in a zip file using that same path.

I usually end up lazy.. using my perl script just converts as part of the makefile, and is easier to install :)

jeff

Good stuff though; people need these sorts of things.
 
rlyeh said:
I can compile it for windows

PS: synkro, would you mind compiling my VFS tool for linux? (which is almost the same as your ratpack btw)
Alrighty!
 
Last edited by a moderator:
synkro said:
Yes, I can't compile a windows binary. I saw your "play mod from mem question" question and I just coded it for you!
It doesnt matter I've tested it on my laptop with ubuntu :)
To play mod from mem, I've posted a solution in the thread and it work very nice with mikmod library (I dont like SDL_mixer) ... play a mod from memory have the advantage of no sd access and no frame killing (this is my personnal test and conclusion)

I've generated a PAK file now I learn how can I use it to load ressource in directly in memory :rolleyes:
 
Last edited by a moderator:
Back
Top