This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jakejakey's profile picture

Self extracting file structure creator!

Started by jakejakey, 12 November 2016 - 01:28 AM
jakejakey #1
Posted 12 November 2016 - 02:28 AM
Okay, so I've seen one of these "compression" programs before, but that one ran into issues with special characters, and required you to specify the directory to extract to, so I made my own that is entirely safe with special characters. The file format has no compression, and is probably significantly larger than the actual file, but it is meant to be used with pastebin and not actually have to exist on a cc-computer.

Now that we have that out of the way, I will explain what it does.
It takes a directory, and then compresses every directory and file within that directory into a
single, self extracting file.

So lets say you make a program, but I has lots of config files and textures that need to be installed with it, pastebinning each item would be less than ideal, so you can use this to compile it into an installer for the program!

Usage:

Compiling

compile myGame gameInstaller

Installing

gameInstaller
OR

pastebin run installerPbCode

So now that you know what you can do with this program, here is how you get it

pastebin get sr3r17q5 compile
Bomb Bloke #2
Posted 12 November 2016 - 02:03 PM
Er um, remember what I was saying about textutils.serialise() the other day? May be worth actually trying that out… The relevant behaviour isn't present in older ComputerCraft versions, but you might consider attempting to replicate it yourself. Your output would be a lot smaller.

io.lines() may also be worth looking into. You'd be able to simplify your file-reading loop significantly.
jakejakey #3
Posted 12 November 2016 - 08:14 PM
Er um, remember what I was saying about textutils.serialise() the other day? May be worth actually trying that out… The relevant behaviour isn't present in older ComputerCraft versions, but you might consider attempting to replicate it yourself. Your output would be a lot smaller.

io.lines() may also be worth looking into. You'd be able to simplify your file-reading loop significantly.
I'm aware my file size is stupidly large, but I tried storing it in long strings, and it didn't work.
Edited on 12 November 2016 - 07:15 PM
Sewbacca #4
Posted 15 November 2016 - 10:03 PM
Wow wow wow wooooooooow.
Compiling rom into rom.zip errored after exact 10245 lines with the error message out of space on a blank computer with just the compile program installed and after 10245 lines with just run compile through pastebin (pastebin run ******* rom rom.zip).

Some tips:

Do not use indents in large files
Do not save bytes in 2-4 charachters (count the '-') (CC just cannot handle write speacial charachterson the screen (older versions), but it can writ onto a file normally)
If you use string.format('%q', str) for a file without saving all lines as table indexes, you will save about lines - 2 (note that ' "" ' will stay there (yes this is a better but not a good solution))

Sewbacca
Edited on 15 November 2016 - 09:04 PM