Browse Source

Fixed bizarro miniz/zipfile bug.

Mark Sibly 7 years ago
parent
commit
643d503caa
2 changed files with 15 additions and 8 deletions
  1. 4 4
      modules/std/filesystem/filesystem.monkey2
  2. 11 4
      modules/std/misc/zipfile.monkey2

+ 4 - 4
modules/std/filesystem/filesystem.monkey2

@@ -354,7 +354,7 @@ Function ExtractRootDir:String( path:String )
 	Local j:=path.Find( ":" )
 	If j=-1 Or (i<>-1 And j>i) Return ""
 	
-	If path.Slice( j,j+3 )="://" Return path.Slice( 0,j+3)
+	If path.Slice( j,j+3 )="://" Return path.Slice( 0,j+3 )
 	
 	If path.Slice( j,j+2 )=":/" Return path.Slice( 0,j+2 )
 	
@@ -372,7 +372,9 @@ End
 #end
 Function IsRootDir:Bool( path:String )
 	
-	Return ExtractRootDir( path )=path
+	Local root:=ExtractRootDir( path )
+	
+	Return root And root.Length=path.Length
 End
 
 #rem monkeydoc Gets the process current directory.
@@ -697,8 +699,6 @@ Function LoadDir:String[]( path:String )
 		
 		path=path.Slice( 10 )
 		
-		Print "Asset dir path 3="+path
-		
 		Local assetDir:=AAssetManager_openDir( GetAssetManager(),path )
 		
 		If assetDir

+ 11 - 4
modules/std/misc/zipfile.monkey2

@@ -63,7 +63,7 @@ Class ZipFile
 	#rem monkeydoc @hidden
 	#end	
 	Method Extract:Bool( dir:String,prefix:String="" )
-	
+		
 		If Not dir.EndsWith( "/" ) dir+="/"
 		
 		Local result:=True
@@ -75,13 +75,20 @@ Class ZipFile
 			
 			If prefix And Not name.StartsWith( prefix ) Continue
 			
+			Local path:=dir+name
+				
+			If mz_zip_reader_is_file_a_directory( _zip,i )
+				
+				filesystem.CreateDir( path )
+				
+				Continue
+			Endif
+			
 			Local size:=_sizes[i]
 
 			Local buf:=New DataBuffer( size )
-		
-			If mz_zip_reader_extract_to_mem( _zip,i,buf.Data,size,0 ) 
 			
-				Local path:=dir+name
+			If mz_zip_reader_extract_to_mem( _zip,i,buf.Data,size,0 ) 
 				
 				filesystem.CreateDir( ExtractDir( path ) )