Ah. I use nsWebBrowserPersist to download the file to disk. (I sent a code
sample for that to this list about a month ago - I don't know if there's an
archive or not.)

Andy

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Manel Mateos
Sent: Wednesday, June 09, 2004 11:54 AM
To: [EMAIL PROTECTED]
Subject: Re: nsZipReader, nsZipEntry


This answer assumes that you have the zip located into a directory!
But the problem is that the zip is the GET RESPONSE from a servlet!
I mean:

function getZip(){
        
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        var mGET = new XMLHttpRequest();
        mGET.open("GET","/whatever.zip");
        mGET.onload=function(){
                if (mGET.status==200) {
        
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        // here goes the zip handle
                        // here you have nsInputStream with the zip bytes
                        // but how do you get the zip contents from the
response nsInputStream?
                }
                else{
                        alert(""+mGET.status + " : " + mGET.statusText);
                }
        }
        mGET.send(null);
}


M.


Hardacker, Andrew wrote:

> This presumes that the zip file is downloaded into the location where it
> will be unzipped.
> The one difficulty I had with this is that my zip file contained:
>   appdir/file1.exe
>   appdir/file2.exe
> 
> but getNext() returned *three* entries: appdir, file1.exe, and file2.exe.
> "appdir" was added as a file; a situation which then had to be corrected
> before "file1.exe" could be added with its proper parent. There may be a
> better solution than the one I devised.
> 
> function unzip() {
>     const FileFactory = new
> Components.Constructor("@mozilla.org/file/local;1",
>                                                    "nsILocalFile",
>                                                    "initWithPath");
>     var zip = Components.classes["@mozilla.org/libjar/zip-reader;1"]
>                    .createInstance(Components.interfaces.nsIZipReader);
> 
>     var zipped = new FileFactory("C:/target/dir");
>     zipped.append("whatever.zip");
>     zip.init(zipped);
>     zip.open();
> 
>     var entry;
>     var newDir;
>     var entries = zip.findEntries("*");
>     var targetPath = zipped.parent.path;
>     var destbase = new FileFactory(appPath);
>     
>     while(entries.hasMoreElements()) {
>         entry =
> entries.getNext().QueryInterface(Components.interfaces.nsIZipEntry);
>         var f = new FileFactory(targetPath);
>         f.setRelativeDescriptor(destbase, entry.name);
>         newDir = f.parent;
>         // this corrects an odd situation where a prior entry
>         // was added as a file although it should have been a directory 
>         if (newDir.exists() && newDir.isFile()) {
>             newDir.remove(false);
>             newDir = f.parent;
>         }
>         if (!newDir.exists()) {
>             newDir.create(newDir.DIRECTORY_TYPE, 0777);
>         }
>         zip.extract(entry.name, f);
>     }
>     zip.close();
>     zipped.remove(false); // if you want to delete the zip fle
> }
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Manel Mateos
> Sent: Wednesday, June 09, 2004 7:46 AM
> To: [EMAIL PROTECTED]
> Subject: nsZipReader, nsZipEntry
> 
> 
> hi!
> 
> I'm trying to handle a GET response from a server that is suposed to be 
> a zip file! I make the request throw XMLHTTPRequest() but I don't know 
> how to use the mozilla API (zipreader, zipentry) to extract files inside 
> de zip in the response.
> 
> help would be appreciated!
> tx.
> _______________________________________________
> Mozilla-xpcom mailing list
> [EMAIL PROTECTED]
> http://mail.mozilla.org/listinfo/mozilla-xpcom
> 
> 
> 
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or
disclose
> it to anyone else. If you received it in error please notify us
immediately
> and then destroy it. 
> 
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to