Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Etwas
Sunday, July 15th, 2007 at 10:04:20am UTC 

  1. int UnzipFile(wxString src, wxString destdir, bool isInstall)
  2.  {
  3. +
  4.      wxZipEntryPtr       entry;
  5.      wxString            in_str, progress_msg, buf;
  6.      int                 errnum = 0, curfile = 0, totalfiles = 0;
  7. @@ -321,8 +324,12 @@
  8.             (entry.reset(in_zip->GetNextEntry()), entry.get() != NULL) )
  9.      {
  10.  
  11. +
  12.          curfile++;
  13.          wxString name = entry->GetName();
  14. +        in_str = destdir + wxT("" PATH_SEP) + name;
  15. +
  16. +        // set progress
  17.          progress_msg = wxT("Unpacking ") + name;
  18.          if (! progress->Update(curfile, progress_msg) ) {
  19.              MESG_DIALOG(wxT("Unpacking cancelled by user"));
  20. @@ -330,20 +337,25 @@
  21.              break;
  22.          }
  23.  
  24. -        in_str = destdir + wxT("" PATH_SEP) + name;
  25. +        //check if the dir of the filename exists
  26. +        if(!wxDirExists(wxPathOnly(in_str)))
  27. +        {
  28. +            if (! wxMkdir(in_str, 0777) )
  29. +            {
  30. +               buf = wxT("Unable to create directory ") + in_str;
  31. +               errnum = 100;
  32. +               break;
  33. +            }
  34. +        }
  35.  
  36. -        if (entry->IsDir() ) {
  37. -            if (!wxDirExists(in_str) ) {
  38. -                if (! wxMkdir(in_str, 0777) ) {
  39. -                    buf = wxT("Unable to create directory ") + in_str;
  40. -                    errnum = 100;
  41. -                    break;
  42. -                }
  43. -            }
  44. +        // if it is a dir, only log it
  45. +        if (entry->IsDir() )
  46. +        {
  47.              log->WriteFile(name, true); // Directory
  48.              continue;
  49.          }
  50.  
  51. +        // its a file, copy it
  52.          wxFFileOutputStream* out = new wxFFileOutputStream(in_str);
  53.          if (! out->IsOk() )
  54.          {
  55. @@ -389,6 +401,7 @@
  56.      if (log) delete log;
  57.      wxLogVerbose(wxT("=== end UnzipFile"));
  58.      return(errnum);
  59. +
  60.  }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right