Pack Up Multiple Files into a Single .rb File?
-
I may have asked this before, but isn't it possible (and not even that hard) to package-up all of a plugin's file into a single .rb which would self-extract itself to the Plugins folder?
I know Unix has had command-line utilities to do this type of thing forever (shar, for example.)
-
~
WinZip could do this since forever. It creates a self-extracting exe, that (dependant on the archiver's choice,) can prompt the enduser, where he/she wants to extract the files to.7zip can also do a similar job. See the 7z help file, "Command Line Version" section, "Switches" subsection, -sfx (Create SFX archive) switch.
There used to be a company called PKware that made archivers as well.
~
*PS: WinZip is not the built-in zip folder feature in Windows XP+, it's the application WinZip. -
BTW.. 7zip is a plug-in capable app. There may be plugins out there that simplfy creating self-extracting archives.
.
EDIT: Oh.. I just tried creating a self-extracting archive using the checkbox in 7zip's create archive dialog, and it wrote out a exe file.
-
I found the 7z's sxe documentation lacking, and it isn't cross-platform, is it?
-
Should be able to. There is a keyword in Ruby you can use to indicate the end of the file - as far as the ruby processor is concerned.
So stuff the files you need after that point and have the script unpack it.
Just need to find out how you indicate the start and end of the embedded files. -
It seems like it would be straight forward. I think pack and unpack can do base64 encoding/decoding, and so just encode every file, binary or not, to make it simpler. I'm just being lazy.
-
Yea, base64 encoding would be doing it pretty much like you do with emails - using a unique indentifier to indicate the file splits.
-
I did something like that in timetrack.rb - here is the uncompress part
zap_files = <<EOL {"tt_stop_l.png"=>"... removed ...", "tt_go_s.png"=>"... removed ..."} EOL if not FileTest.exists?("tt_stop_l.png") eval(zap_files).each_pair do |x,y| File.open(File.join(Sketchup.find_support_file("Plugins"), x),"wb") do |f| f.write y.unpack("m") end end end
Advertisement