Jump to content

Creating and opening custom file extension as a folder

Hi

I'm trying to make a custom file type and extension that I can open as a folder for a game I'm working on.

Link to comment
Share on other sites

Link to post
Share on other sites

Why?

 

I mean I can't see any reason to. There are plenty of tools for working with files and folders, why create something oddball?

 

Perhaps you should just tarball a folder.

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to comment
Share on other sites

Link to post
Share on other sites

You'd best get away with retro-fitting an archive format to do this. I'm not sure about speciality file types for games, I'd avoid making one unless I really need to, and the only reason I'd want to is making the files memory map friendly, in a form that could help to load parts of it directly into memory, so that I could load resources into the game on-demand almost instantaneously (John Carmack would approve).

Link to comment
Share on other sites

Link to post
Share on other sites

What do you mean by 'retro-fitting an archive format'. Sorry I'm a bit of a noob

 

Link to comment
Share on other sites

Link to post
Share on other sites

My advice would be to just use ZIP , or TAR (no compression) archives.

 

TAR is super simple format,  everything is in 512 bytes blocks, you have a header (1 or several 512 bytes blocks that hold file name, file size other stuff) followed by the file data (padded with empty bytes if it's not multiple of 512 bytes.

7zip can open, extract or create tar files...

See https://en.wikipedia.org/wiki/Tar_(computing)#File_format

 

You can code your game to quickly parse the TAR files in a folder jumping from file header to file header and storing the location of each file's content in memory and then when needed, your game can simply seek to an offset in file and copy the file in memory from within the tar file. As there's no compression, it would be super fast.

 

ZIP can be unpacked by free/open source zlib, or with the 7zip decompression library, Windows Explorer can open zip files. ZIP by default doesn't have a "solid mode", so each file inside an archive can be easily unpacked, you don't have to unpack every file in the archive that's before the file you need. 

So, if you use a fast compression preset, with the modern processors of today, individual files from a zip could be unpacked on the fly super fast.

 

If you want to go even more old school, there's the PAK format used by quake 2, half-life etc : https://quakewiki.org/wiki/.pak

Has limitations though, like maximum 56 characters for file path + file name,  4 GB limits (as it uses 32 bit values for offset and file size for each file inside the pak file)

 

TAR would make it super easy to release patches for your game though.

For example, you can have a version.txt file inside each tar, which changes every time you update the game. You can create a TAR archive with the contents of your game making sure the files inside are in the same order.

Then, you can make a super simple DIFF between the older and newest TAR files using xdelta or similar programs and your game can then just download the patch file (differences between the two TAR files) and apply the patch.

With zip files, due to the fact that even a single byte change in a file could make that file be compressed within the zip quite differently, making patches would be more difficult.

Link to comment
Share on other sites

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

×