Zip Objects
by DragonSix · in Torque Game Builder · 04/02/2007 (9:05 am) · 26 replies
After looking a little into the documentation (which promise to be really good from the look of it), I found something called Zip Object with function to read, write, compress and extracts files within a .zip. Thats really promising for further .zip functions.
I have two question about Zip Object :
Does it support reading image and sound through it ? (or will do ?)
Does it support passworded archives ? (or will do ?)
I have two question about Zip Object :
Does it support reading image and sound through it ? (or will do ?)
Does it support passworded archives ? (or will do ?)
#22
07/30/2007 (3:22 pm)
I think you need to repost that one...
#23
REPOST:
When you say you tried ./water.png and ~/water.png ... did the file exist in those locations?
If the file resides on the E:, and the E: is not the location that your game project is located in, then it won't work (I don't believe they changed that in 1.5).
I think you might be getting a little confused as to how ./ and ~/ expando's work ... but I'm not 100% sure (as you say you tried to use both types of expandos). It is also possible that addFile is one of those oddities where it doesn't support expando's, and therefore you have to pass a fully qualified 'TGB' path to it -- or use the ExpandScriptFileName() console method.
Place the file "water.png" in the same directory as your projects main.cs file, and then use "/water.png" as the path to the file -- see if that works.
Also, why are you attempting to create the zip through TorqueScript? I believe the basic point behind ZipObjects is to be able to open them, not necessarily create them ... and without a Pro license, it's fairly pointless to create Zips with Code as the files have to reside in the game project (again, not 100% sure thats still true with 1.5)
07/30/2007 (3:33 pm)
Oops -- thats what I get for trying to write a forum through a remote desktop connection ... ;)REPOST:
When you say you tried ./water.png and ~/water.png ... did the file exist in those locations?
If the file resides on the E:, and the E: is not the location that your game project is located in, then it won't work (I don't believe they changed that in 1.5).
I think you might be getting a little confused as to how ./ and ~/ expando's work ... but I'm not 100% sure (as you say you tried to use both types of expandos). It is also possible that addFile is one of those oddities where it doesn't support expando's, and therefore you have to pass a fully qualified 'TGB' path to it -- or use the ExpandScriptFileName() console method.
Place the file "water.png" in the same directory as your projects main.cs file, and then use "/water.png" as the path to the file -- see if that works.
Also, why are you attempting to create the zip through TorqueScript? I believe the basic point behind ZipObjects is to be able to open them, not necessarily create them ... and without a Pro license, it's fairly pointless to create Zips with Code as the files have to reside in the game project (again, not 100% sure thats still true with 1.5)
#24
As I said, I had water.png in my main game folder.
Oh, I probably am. Feel free to educate me, just in case.
I just tried this, using "/", "./" and "~/". Same result in all cases: an empty zip file.
So that I can provide the users with an editor that will let them create custom scenarios. I want the editor to pack the graphics, sounds and text files for a scenario into a single archive, which can then be distributed and read from.
Are you saying there's no way to do this?
07/30/2007 (4:02 pm)
Quote:When you say you tried ./water.png and ~/water.png ... did the file exist in those locations?
As I said, I had water.png in my main game folder.
Quote:I think you might be getting a little confused as to how ./ and ~/ expando's work
Oh, I probably am. Feel free to educate me, just in case.
Quote:Place the file "water.png" in the same directory as your projects main.cs file, and then use "/water.png" as the path to the file
I just tried this, using "/", "./" and "~/". Same result in all cases: an empty zip file.
Quote:Also, why are you attempting to create the zip through TorqueScript?
So that I can provide the users with an editor that will let them create custom scenarios. I want the editor to pack the graphics, sounds and text files for a scenario into a single archive, which can then be distributed and read from.
Are you saying there's no way to do this?
#25
But, I close and restart TGB - then I can't open the archive for writing. Looks like a bug, but I haven't found where...
If anyone can resolve this - huge thanks.
P.S. I'm using getRealTime() just to make filenames unique within archive
P.P.S. Anyone have working ZipCryptWStream class implemented? :)
thanks
08/03/2007 (6:10 pm)
Okay. How it works (TGBP151):function createTestArchive()
{
%archive = new ZipObject();
if (!%archive.openArchive("game/testArchive.zip", "readwrite")) // one of: "read" / "write" / "readwrite"
{
error("Can't open archive for writing!");
%archive.delete();
return;
}
if (!%archive.addFile("game/main.cs", "main" @ getRealTime() @ ".cs"))
{
error("Can't add file 1 to archive!");
%archive.closeArchive();
%archive.delete();
return;
}
if (!%archive.addFile("game/main.cs.dso", "main" @ getRealTime() @ ".cs.dso"))
{
error("Can't add file 2 to archive!");
%archive.closeArchive();
%archive.delete();
return;
}
%archive.closeArchive();
%archive.delete();
}When I run this for the first time (there is no archive), it works perfectly. I can call this function many times (closing/opening archive many times) and saving files in there with no problems.But, I close and restart TGB - then I can't open the archive for writing. Looks like a bug, but I haven't found where...
If anyone can resolve this - huge thanks.
P.S. I'm using getRealTime() just to make filenames unique within archive
P.P.S. Anyone have working ZipCryptWStream class implemented? :)
thanks
#26
Thanks,
Steve
11/29/2009 (11:52 pm)
Anyone got this to work? I'm interested in the solution. Program does crash on restart in W7.Thanks,
Steve
Associate David Higgins
DPHCoders.com