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

Looking for a compression program

Started by DannySMc, 10 April 2015 - 09:36 AM
DannySMc #1
Posted 10 April 2015 - 11:36 AM
Hey everyone,

I am planning to add a feature into the app store that will allow you to package a whole directory and save it, of course it needs to be packaged as one file and then when it is run it will decompress all files.

Now I have tried the following:
Installer Maker (SGunner) -> This errored and didn't work.
Craft Compress -> Everytime I attempted to run the file to unpackage it it just errored saying there was a / character.
Packman -> Doesn't even download. Just errors.

If anyone has made or has a decent program that is reliable and able to package everything in a folder, this being multiple files or even more folders with files in. This would be very helpful thank you!

Cheers
Bomb Bloke #2
Posted 10 April 2015 - 11:43 AM
Well, there's this, I suppose.
SquidDev #3
Posted 10 April 2015 - 11:44 AM
The only tool that actually implements decent compression would be Grin. However it would require being built outside ComputerCraft, though if this is for a web server you could always allow the user to upload a directory and handle everything on the server. The alternative would be to minify the code like Howl does.

If you are just looking for a packager then you can't go wrong with Bomb Bloke's Package. You might also want to read through this. Packman works fine on my computer so it is strange that it is broken.
DannySMc #4
Posted 10 April 2015 - 11:55 AM
Well, there's this, I suppose.

I have to ask can this actually package everything and save it to file? or does it have to upload to pastebin?:s

The only tool that actually implements decent compression would be Grin. However it would require being built outside ComputerCraft, though if this is for a web server you could always allow the user to upload a directory and handle everything on the server. The alternative would be to minify the code like Howl does.

If you are just looking for a packager then you can't go wrong with Bomb Bloke's Package. You might also want to read through this. Packman works fine on my computer so it is strange that it is broken.

No it needs to all be done in program (lua)
Bomb Bloke #5
Posted 10 April 2015 - 12:19 PM
The only tool that actually implements decent compression would be Grin. However it would require being built outside ComputerCraft, though if this is for a web server you could always allow the user to upload a directory and handle everything on the server.

That is to say, Grin doesn't implement compression at all - it does the opposite. :P/>

I have to ask can this actually package everything and save it to file? or does it have to upload to pastebin?:s

If you load it as an API you can make it do pretty much whatever you want it to. ;)/>
Edited on 10 April 2015 - 10:19 AM
DannySMc #6
Posted 10 April 2015 - 12:26 PM
The only tool that actually implements decent compression would be Grin. However it would require being built outside ComputerCraft, though if this is for a web server you could always allow the user to upload a directory and handle everything on the server.

That is to say, Grin doesn't implement compression at all - it does the opposite. :P/>

I have to ask can this actually package everything and save it to file? or does it have to upload to pastebin?:s

If you load it as an API you can make it do pretty much whatever you want it to. ;)/>

Awesome thank you, would you be okay with it being used in my app store? :)/>
Bomb Bloke #7
Posted 10 April 2015 - 12:35 PM
Check my signature. :)/>
DannySMc #8
Posted 10 April 2015 - 12:45 PM
Check my signature. :)/>
Ahh…. *facepalm*
Creator #9
Posted 10 April 2015 - 02:09 PM
Hey everyone,

I am planning to add a feature into the app store that will allow you to package a whole directory and save it, of course it needs to be packaged as one file and then when it is run it will decompress all files.

Now I have tried the following:
Installer Maker (SGunner) -> This errored and didn't work.
Craft Compress -> Everytime I attempted to run the file to unpackage it it just errored saying there was a / character.
Packman -> Doesn't even download. Just errors.

If anyone has made or has a decent program that is reliable and able to package everything in a folder, this being multiple files or even more folders with files in. This would be very helpful thank you!

Cheers

Use Compress. It saves a folder structure into a single file. When you run the file it will extract itself to the desired path. YAY. Be sure to try it.
SquidDev #10
Posted 10 April 2015 - 02:44 PM
And another thing… Oeed "Hideously Smashed-Stuff-Togetherer for Copmute" (direct quote from the GitHub repo) and made this thing called Compilr. It is similar to Creator's Compress, but also allows you to run the file without extracting it.
DannySMc #11
Posted 10 April 2015 - 02:54 PM
And another thing… Oeed "Hideously Smashed-Stuff-Togetherer for Copmute" (direct quote from the GitHub repo) and made this thing called Compilr. It is similar to Creator's Compress, but also allows you to run the file without extracting it.

Err how do I run it?:s or do anything with it?:s
SquidDev #12
Posted 10 April 2015 - 03:12 PM
And another thing… Oeed "Hideously Smashed-Stuff-Togetherer for Copmute" (direct quote from the GitHub repo) and made this thing called Compilr. It is similar to Creator's Compress, but also allows you to run the file without extracting it.

Err how do I run it?:s or do anything with it?:s

Its slightly broken as it only works from root directory so you'll need to patch it. You just run it and it produces a file called build which when run, runs a file called startup. You can always change it so it is more customisable. It packages an entire virtual file system so you can run build –extract to extract it, or build to run the program. It was written to package bedrock files but should work with anything.

Just putting it out there: Read the source Luke.
Edited on 10 April 2015 - 01:12 PM
DannySMc #13
Posted 10 April 2015 - 03:29 PM
And another thing… Oeed "Hideously Smashed-Stuff-Togetherer for Copmute" (direct quote from the GitHub repo) and made this thing called Compilr. It is similar to Creator's Compress, but also allows you to run the file without extracting it.

Err how do I run it?:s or do anything with it?:s

Its slightly broken as it only works from root directory so you'll need to patch it. You just run it and it produces a file called build which when run, runs a file called startup. You can always change it so it is more customisable. It packages an entire virtual file system so you can run build –extract to extract it, or build to run the program. It was written to package bedrock files but should work with anything.

Just putting it out there: Read the source Luke.

Ahh never mind then :P/>
HPWebcamAble #14
Posted 10 April 2015 - 05:29 PM
Craft Compress -> Everytime I attempted to run the file to unpackage it it just errored saying there was a / character.

Craft Compress is my program, its on hold right now. Bug reports are still fine, I just won't be doing any new features any time soon

So it didn't like the '/' character? If you get a chance could you post a bug report with the error and the file you tried to compress?

I've been having problems, but as far as I know its just with nested multi line strings ( [[ ]] )
DannySMc #15
Posted 10 April 2015 - 05:33 PM
Sure
Tag365 #16
Posted 10 April 2015 - 06:01 PM
If you want I can give you a slightly modified version of my script I used to publish Lua Script System as one file on Pastebin.

Here it is:


local tArgs = {}
local savetable = {}
function compact(path)
	local file
	for k, v in ipairs(fs.list(path)) do
		if fs.isDir(path.."/"..v) then
			compact(path.."/"..v)
		elseif fs.exists(path.."/"..v) then
			file = fs.open(path.."/"..v, "r")
			if file then
				savetable[path.."/"..v] = file.readAll()
				file.close()
			end
		end
	end
end

if tArgs > 1 then
	print("Serializing...")
	compact(tArgs[1])
	print("Saving to File...")
	local file = fs.open(tArgs[2], "w")
	file.write(textutils.serialize(savetable))
	file.close()
else
	print("Usage: merge <folder merge="" to=""> <file path="">")
end
</file></folder>

Here is the code to uncompress a file.

local function createFolderForFile(path)
	local curpath = path
	local startHere = 1
	while true do
		local nextSlash = string.find(string.sub(path, startHere, -1), "/")
		if not nextSlash then return end
		nextSlash = nextSlash + startHere
		local folderToCreate = string.sub(curpath, 0, nextSlash - 1)
		if not fs.isDir(folderToCreate) then
			local ok, err = pcall(fs.makeDir, folderToCreate)
			if not ok then
				if string.find(err, "Out of space") then
					error("Out of space.")
				end
			end
		end
		startHere = nextSlash
	end
end

function uncompact(location)
	local handle = fs.open(location, "r")
	folderStructureS = handle.readAll()
	handle.close()
	local folderStructure = textutils.unserialize(folderStructureS)
	for k, v in pairs(folderStructure) do
		createFolderForFile(k)
		local file = fs.open(k, "w")
		if file then
			file.write(v)
			local ok, err = pcall(file.close)
			if not ok then
				if string.find(err, "Out of space") then
					outOfSpaceError()
				end
			end
		end
		sleep()
	end
end

if tArgs > 0 then
	print("Unserializing...")
	uncompact(Args[1])
else
	print("Usage: unmerge <file path to uncompact>")
end
Edited on 10 April 2015 - 04:09 PM
Creator #17
Posted 10 April 2015 - 06:28 PM
-snip-
This is almost like compress. Not that compress has a very original idea
ElvishJerricco #18
Posted 10 April 2015 - 07:18 PM
That is to say, Grin doesn't implement compression at all - it does the opposite. :P/>

Well to be fair, Grin supports DEFLATE in the zip files, which can do some substantial compression. Even with the base64 inflation, the 300kb JVML folder is only 180kb in its Grin-downloadable release form