int UnzipFile(wxString src, wxString destdir, bool isInstall) { + wxZipEntryPtr entry; wxString in_str, progress_msg, buf; int errnum = 0, curfile = 0, totalfiles = 0; @@ -321,8 +324,12 @@ (entry.reset(in_zip->GetNextEntry()), entry.get() != NULL) ) { + curfile++; wxString name = entry->GetName(); + in_str = destdir + wxT("" PATH_SEP) + name; + + // set progress progress_msg = wxT("Unpacking ") + name; if (! progress->Update(curfile, progress_msg) ) { MESG_DIALOG(wxT("Unpacking cancelled by user")); @@ -330,20 +337,25 @@ break; } - in_str = destdir + wxT("" PATH_SEP) + name; + //check if the dir of the filename exists + if(!wxDirExists(wxPathOnly(in_str))) + { + if (! wxMkdir(in_str, 0777) ) + { + buf = wxT("Unable to create directory ") + in_str; + errnum = 100; + break; + } + } - if (entry->IsDir() ) { - if (!wxDirExists(in_str) ) { - if (! wxMkdir(in_str, 0777) ) { - buf = wxT("Unable to create directory ") + in_str; - errnum = 100; - break; - } - } + // if it is a dir, only log it + if (entry->IsDir() ) + { log->WriteFile(name, true); // Directory continue; } + // its a file, copy it wxFFileOutputStream* out = new wxFFileOutputStream(in_str); if (! out->IsOk() ) { @@ -389,6 +401,7 @@ if (log) delete log; wxLogVerbose(wxT("=== end UnzipFile")); return(errnum); + }