Jump to content




Looking for a compression program

api lua help

  • You cannot reply to this topic
17 replies to this topic

#1 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 10: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

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 10 April 2015 - 10:43 AM

Well, there's this, I suppose.

#3 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 April 2015 - 10: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.

#4 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 10:55 AM

View PostBomb Bloke, on 10 April 2015 - 10:43 AM, said:

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

View PostSquidDev, on 10 April 2015 - 10:44 AM, said:

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)

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 10 April 2015 - 11:19 AM

View PostSquidDev, on 10 April 2015 - 10:44 AM, said:

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

View PostDannySMc, on 10 April 2015 - 10:55 AM, said:

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 by Bomb Bloke, 10 April 2015 - 11:19 AM.


#6 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 11:26 AM

View PostBomb Bloke, on 10 April 2015 - 11:19 AM, said:

View PostSquidDev, on 10 April 2015 - 10:44 AM, said:

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

View PostDannySMc, on 10 April 2015 - 10:55 AM, said:

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? :)

#7 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 10 April 2015 - 11:35 AM

Check my signature. :)

#8 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 11:45 AM

View PostBomb Bloke, on 10 April 2015 - 11:35 AM, said:

Check my signature. :)
Ahh.... *facepalm*

#9 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 April 2015 - 01:09 PM

View PostDannySMc, on 10 April 2015 - 10:36 AM, said:

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.

#10 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 April 2015 - 01: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.

#11 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 01:54 PM

View PostSquidDev, on 10 April 2015 - 01:44 PM, said:

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

#12 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 April 2015 - 02:12 PM

View PostDannySMc, on 10 April 2015 - 01:54 PM, said:

View PostSquidDev, on 10 April 2015 - 01:44 PM, said:

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 by SquidDev, 10 April 2015 - 02:12 PM.


#13 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 02:29 PM

View PostSquidDev, on 10 April 2015 - 02:12 PM, said:

View PostDannySMc, on 10 April 2015 - 01:54 PM, said:

View PostSquidDev, on 10 April 2015 - 01:44 PM, said:

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

#14 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 10 April 2015 - 04:29 PM

View PostDannySMc, on 10 April 2015 - 10:36 AM, said:

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 ( [[ ]] )

#15 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 10 April 2015 - 04:33 PM

Sure

#16 Tag365

  • Members
  • 109 posts

Posted 10 April 2015 - 05: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 by Tag365, 10 April 2015 - 05:09 PM.


#17 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 April 2015 - 05:28 PM

View PostTag365, on 10 April 2015 - 05:01 PM, said:

-snip-
This is almost like compress. Not that compress has a very original idea

#18 ElvishJerricco

  • Members
  • 803 posts

Posted 10 April 2015 - 06:18 PM

View PostBomb Bloke, on 10 April 2015 - 11:19 AM, said:

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users