214 posts
Location
/home/marcus/
Posted 08 June 2015 - 12:38 AM
MakePack
Basic usage
Spoiler
makepack [help] – display help
makepack pack <from folder> <to archive> – compresses the contents of <folder> to <archive>
makepack unpack <archive> <destination folder> – uncompresses the main folder from <archive> as <destination>
makepack sfx <directory> <archive> – creates a runnable Lua file that transforms itself into a directory
<archive> <directory> – extracts the contents of the SFX archive to the directoryDownload it from
Pastebin.
pastebin get xE5J2GS2 makepack
File format
Spoiler
Strings: string_length:byte + content:string
Node: name:string + type:byte + info:int + body:bytebuf
Directory: type=0, info=#nodes, body=Node[]
File: type=1, info=filesize, body=compression_method:byte + compressed_stream:bytebuf
The pack'd file contains a root Directory node named "/", and all the things branch out of there.The whole rom folder is 265451 bytes big, but it's 179357 bytes compressed! :P/>
Screenies
Spoiler

http://puu.sh/ihhQK/010892d81b.png

http://puu.sh/iiKDt/809dcd4d1e.pngIntegration
Spoiler
local pk = loadfile("makepack")("api")
pk.compress(wat, where) -- compresses <wat> to <where>
pk.decompress(wat, where, [isSFX]) -- decompresses <wat> to <where>, but if [isSFX] then only use the binary part of the SFX
Changelog-thingy
Spoiler
- Added packing/unpacking of archives
- Added SFX (SelF-eXtracting archive) creation
- Added file-packaging support (no directory needed)
- Added program integration thru an API
Edited on 09 June 2015 - 08:14 PM
7083 posts
Location
Tasmania (AU)
Posted 08 June 2015 - 12:55 AM
windows's file sizes are very inaccurate -_-/>
No they're not. :P/>
If you're getting confused between "size" and "size on disk", that has to do with cluster sizes. Your file system doesn't keep track of where every byte of data on your drive is - that'd mean using up a massive chunk of your drive space just to store the table of contents - so instead it tracks
groups (or clusters) of bytes.
The rule is that data from only one file can be stored in a given cluster, so if you stick a 1kb file in a 4kb cluster then the whole 4kb of space is effectively consumed. Likewise, a 13kb cluster would effectively cover four 4kb clusters, taking up 16kb of space.
All clusters on your drive are the same size, but what that size is can vary from drive to drive (based on how it was formatted). 4kb is by far the most common. Space lost due to this system is referred to as "slack space", and applies to most any file system; Windows is simply nice enough to tell you about it.
214 posts
Location
/home/marcus/
Posted 08 June 2015 - 12:59 AM
windows's file sizes are very inaccurate -_-/>
No they're not. :P/>
–snip–
But in my language they translate to "size", and "size on disk" :P/> That's confusing
Edit: "DIR /S" ftw + updated #1Post
Edited on 07 June 2015 - 11:01 PM
387 posts
Location
in a chair in my room, probably
Posted 08 June 2015 - 07:14 PM
Nice! This would be useful for when you have a large program made in CC and you need to make it more efficiently downloadable. Nice job! :D/>
Edited on 08 June 2015 - 05:14 PM
214 posts
Location
/home/marcus/
Posted 08 June 2015 - 07:41 PM
HOLY COW, that was hard :D/>
Anyways, updated the program. Now added SFX (SelF-eXtracting archive) functionality :D/> Pack those dirs into one file!
214 posts
Location
/home/marcus/
Posted 08 June 2015 - 07:48 PM
Nice! This would be useful for when you have a large program made in CC and you need to make it more efficiently downloadable. Nice job! :D/>
Sorry, I didn't refresh the page :P/> Btw, thanks :D/>
387 posts
Location
in a chair in my room, probably
Posted 08 June 2015 - 09:27 PM
Nice! This would be useful for when you have a large program made in CC and you need to make it more efficiently downloadable. Nice job! :D/>
Sorry, I didn't refresh the page :P/> Btw, thanks :D/>
No prob! :D/>
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 08 June 2015 - 10:28 PM
Actually, I don't think this could be used to do so, without some sort of special service to send you a number 1-256 representing the byte.
You see, CC's strings can only handle 7 bits–or bytes up to 127, so this would not work, as it uses 1-256. That's the really simple version of it.
Edited on 08 June 2015 - 08:29 PM
7083 posts
Location
Tasmania (AU)
Posted 09 June 2015 - 01:03 AM
You see, CC's strings can only handle 7 bits–or bytes up to 127, so this would not work, as it uses 1-256. That's the really simple version of it.
More accurately, certain functions fail when passed strings containing non-ASCII characters. But not
all of them, and the strings themselves can hold such characters without issues.