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

Packager - Compress a folder into a single executable file

Started by CrazedProgrammer, 18 March 2015 - 08:51 PM
CrazedProgrammer #1
Posted 18 March 2015 - 09:51 PM
Packager is a really useful program if you want to compress a folder into a single executable file (to publish on pastebin for example).
Usage:
packager <directory> <output file> [display name]

When you run packager it will compress a folder into a file (note that the paths are relative unless it starts with an /).
When you run the file it will ask:
Where do you want to extract <display name>?
If a file/directory with the same name already exists, it will be deleted.
Note: You can not compress files that have bytes higher than 127.

Download:
pastebin get Wy5vb6p0 packager

If you have any suggestions, bug reports or questions then please leave a reply.
Edited on 02 April 2015 - 11:18 AM
Lupus590 #2
Posted 18 March 2015 - 10:13 PM
Self extracting files, I've been waiting for one of these. Does it actually compress (make the files smaller) too?
Edited on 18 March 2015 - 09:15 PM
CrazedProgrammer #3
Posted 19 March 2015 - 07:02 AM
Self extracting files, I've been waiting for one of these. Does it actually compress (make the files smaller) too?
Nope, it converts the contents to base64 so you can upload binary files to pastebin.
Lupus590 #4
Posted 19 March 2015 - 07:43 AM
Feature request, file size shrinking (bonus for IRL compressed file format, .7z .zip .tar.gz - someone has made tar format)
Edited on 20 March 2015 - 06:56 AM
Geforce Fan #5
Posted 19 March 2015 - 11:15 PM
so you can upload binary files to pastebin.
This allows you to upload binary files? YESSSSSSSSS I've been needing this!!!!!!!!!!!
Right now, when installing game-engine, the testing map is stored as a table and is converted by the installer. So it's a pointless fs call.
MKlegoman357 #6
Posted 20 March 2015 - 06:46 AM
so you can upload binary files to pastebin.
This allows you to upload binary files? YESSSSSSSSS I've been needing this!!!!!!!!!!!
Right now, when installing game-engine, the testing map is stored as a table and is converted by the installer. So it's a pointless fs call.

And what about Bomb Bloke's script? It does the same, and even more - compression!
CrazedProgrammer #7
Posted 20 March 2015 - 07:49 AM
so you can upload binary files to pastebin.
This allows you to upload binary files? YESSSSSSSSS I've been needing this!!!!!!!!!!!
Right now, when installing game-engine, the testing map is stored as a table and is converted by the installer. So it's a pointless fs call.

And what about Bomb Bloke's script? It does the same, and even more - compression!
Wow that looks nice! But it doesn't support empty directories.
I will probably add compression in the future.

Feature request, file size shrinking (bonus for IRL compressed file format, .7z .zip .tar.gz - someone has made tar format)
I will add compression soon!
Lupus590 #8
Posted 20 March 2015 - 07:57 AM
I found that post with the .tar format archiver, I've added it to my previous post too.
http://www.computercraft.info/forums2/index.php?/topic/18280-cc-tar-create-and-unpack-real-tar-files-in-cc/
CrazedProgrammer #9
Posted 20 March 2015 - 08:05 AM
I found that post with the .tar format archiver, I've added it to my previous post too.
http://www.computercraft.info/forums2/index.php?/topic/18280-cc-tar-create-and-unpack-real-tar-files-in-cc/
Thanks, but the file should be executable in CC.
I'm going to search for some simple compression algorithms in lua.
Mr. Bateman #10
Posted 20 March 2015 - 11:41 PM
I found that post with the .tar format archiver, I've added it to my previous post too.
http://www.computerc...ar-files-in-cc/
That implementation doesn't have compression, so it's useless in this regard.
Thanks, but the file should be executable in CC.
I'm going to search for some simple compression algorithms in lua.
Keep in mind that you have to put the decompression script in every packaged file so it can decompress itself, so stay clear of any 30kb Huffman encoding algorithms.
Lupus590 #11
Posted 20 March 2015 - 11:55 PM
-snip-

The point was that someone had made a program that used a real life file format. I did reference my previous post, maybe you should have read it.
Mr. Bateman #12
Posted 21 March 2015 - 01:21 AM
The point was that someone had made a program that used a real life file format. I did reference my previous post, maybe you should have read it.
Assuming this is the post in question:
Feature request, file size shrinking (bonus for IRL compressed file format, .7z .zip .tar.gz - someone has made tar format)
\
You're asking for compression, and you state that it's a "bonus" if a real life format was used. The TAR implementation in CC doesn't support compression, so the first criteria is invalidated, therefore providing no fulfillment towards your request.
I don't think you've read your own post.
Bomb Bloke #13
Posted 21 March 2015 - 01:48 AM
It's a bit of a moot point, considering that you can only upload / download ASCII.
Lupus590 #14
Posted 21 March 2015 - 10:28 AM
.tar.gz is a combined format the .gz provides compression

anyway, enough arguing.
Edited on 21 March 2015 - 09:28 AM
CrazedProgrammer #15
Posted 21 March 2015 - 11:19 AM
It's a bit of a moot point, considering that you can only upload / download ASCII.
It converts binary data to base64 so you can upload everything to pastebin.
Bomb Bloke #16
Posted 21 March 2015 - 01:35 PM
That's great and all, but then what are you going to do - paste that content into your compression software of choice? ;)/>

You'll need a go-between converter, so it doesn't matter so much as to whether the pre-base64'd file uses a "standard" format or not.
CrazedProgrammer #17
Posted 21 March 2015 - 04:31 PM
I've updated Packager to use LZW compression and a more efficient way to make directories and files, and this can make the output file sometimes even smaller than the directory you compress.
To download it use the same command as before:
pastebin get Wy5vb6p0 packager
The usage is also exactly the same, you just see the difference in size.
Screenshot:
SpoilerLeft: Directory
Middle: File generated with the old Packager
Right: File generated with the new Packager
minebuild02 #18
Posted 25 March 2015 - 09:17 AM
Can I use this in my OS?
CrazedProgrammer #19
Posted 25 March 2015 - 10:08 AM
Can I use this in my OS?
Of course :D/>
This program was made for those kinds of things.
Creator #20
Posted 29 March 2015 - 12:40 PM
Packager 70: too long without yielding.

The folder I was trying to compress is this one.

If you want to get the folder structure, type this:


pastebin run 2DMDuHci TheOS

~Creator
CrazedProgrammer #21
Posted 29 March 2015 - 09:25 PM
Packager 70: too long without yielding.

The folder I was trying to compress is this one.

If you want to get the folder structure, type this:


pastebin run 2DMDuHci TheOS

~Creator
The code doesn't yield, so it probably won't compress files larger than 100-200kB.
I just found out that fs.open changes the bytes above 128, so that sucks.
Do you have any binary files in your OS?
I was able to compress the folder but it couldn't extract.
I'll probably make an update in the future, but now I'm busy, sorry.
MKlegoman357 #22
Posted 29 March 2015 - 10:24 PM
There is an "rb" and a "wb" file open mode for reading and writing in binary.