Patch level :a2.2
Files correlati : Ricompilazione Demo : [ ] Commento : Migliorato unzipping delle sottocartelle git-svn-id: svn://10.65.10.50/trunk@13942 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									ee4a4f4bfe
								
							
						
					
					
						commit
						af646cd925
					
				| @ -14,16 +14,19 @@ | |||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| #include <wx/dir.h> | #include <wx/dir.h> | ||||||
|  | #include <wx/progdlg.h> | ||||||
| #include <wx/wfstream.h> | #include <wx/wfstream.h> | ||||||
| #include <wx/zipstrm.h> | #include <wx/zipstrm.h> | ||||||
| #include <wx/progdlg.h> |  | ||||||
| 
 | 
 | ||||||
| unsigned int aga_ziplist(const char* zipfile, wxArrayString& aFiles) | static unsigned int aga_getziplist(const char* zipfile, wxArrayString& aFiles) | ||||||
| { | { | ||||||
| 	wxFFileInputStream fin(zipfile); | 	wxFFileInputStream fin(zipfile); | ||||||
|   wxZipInputStream zip(fin); |   wxZipInputStream zip(fin); | ||||||
|   for (wxZipEntry* z = zip.GetNextEntry(); z; z = zip.GetNextEntry()) |   for (wxZipEntry* z = zip.GetNextEntry(); z; z = zip.GetNextEntry()) | ||||||
|     aFiles.Add(z->GetInternalName()); |   { | ||||||
|  |     const wxString str = z->GetInternalName(); | ||||||
|  |     aFiles.Add(str); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
| 	return aFiles.GetCount(); | 	return aFiles.GetCount(); | ||||||
| } | } | ||||||
| @ -53,7 +56,7 @@ void aga_create_dir(wxString strPath) | |||||||
| bool aga_unzip(const char* zipfile, const char* destdir) | bool aga_unzip(const char* zipfile, const char* destdir) | ||||||
| { | { | ||||||
| 	wxArrayString aFiles; | 	wxArrayString aFiles; | ||||||
| 	const unsigned int files = aga_ziplist(zipfile, aFiles); | 	const unsigned int files = aga_getziplist(zipfile, aFiles); | ||||||
| 
 | 
 | ||||||
|   wxProgressDialog pi("Unzip", "", files, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); |   wxProgressDialog pi("Unzip", "", files, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); | ||||||
| 
 | 
 | ||||||
| @ -63,7 +66,7 @@ bool aga_unzip(const char* zipfile, const char* destdir) | |||||||
|     if (!pi.Update(f, strFileName)) |     if (!pi.Update(f, strFileName)) | ||||||
|       break; |       break; | ||||||
| 
 | 
 | ||||||
|     if (wxEndsWithPathSeparator(strFileName))  // Is dir name
 |     if (wxEndsWithPathSeparator(strFileName) || strFileName.Find('.') < 0)  // Is dir name
 | ||||||
|     { |     { | ||||||
| 		  wxString strOutDir = destdir; | 		  wxString strOutDir = destdir; | ||||||
|       if (!wxEndsWithPathSeparator(strOutDir)) |       if (!wxEndsWithPathSeparator(strOutDir)) | ||||||
| @ -96,12 +99,6 @@ bool aga_unzip(const char* zipfile, const char* destdir) | |||||||
| // Zip support
 | // Zip support
 | ||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| static size_t AddFilesToList(const wxString& strBase, const wxString& strMask, wxArrayString& aFiles) |  | ||||||
| { |  | ||||||
|   const size_t n = wxDir::GetAllFiles(strBase, &aFiles, strMask); |  | ||||||
|   return n; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void AddFileToZip(const wxString& strPrefix, const wxString& strFile, | static void AddFileToZip(const wxString& strPrefix, const wxString& strFile, | ||||||
| 												 wxZipOutputStream& zip) | 												 wxZipOutputStream& zip) | ||||||
| { | { | ||||||
| @ -150,7 +147,7 @@ bool aga_zip(const char* srcfiles, const char* zipfile) | |||||||
| 	strMask += strExt; | 	strMask += strExt; | ||||||
| 
 | 
 | ||||||
| 	wxArrayString aFiles; | 	wxArrayString aFiles; | ||||||
| 	AddFilesToList(strBase, strMask, aFiles); |   wxDir::GetAllFiles(strBase, &aFiles, strMask); | ||||||
| 
 | 
 | ||||||
| 	return AddFilesToZip(strBase, aFiles, zipfile); | 	return AddFilesToZip(strBase, aFiles, zipfile); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user