UncompressPackFile on Big Sur

Just starting out? Need help? Post your questions and find answers here.
CoopsOz
User
User
Posts: 11
Joined: Mon Jul 12, 2021 9:39 am

UncompressPackFile on Big Sur

Post by CoopsOz »

Hi all,

As a newbie, I'm unsure if this is a bug or my inexperience.
EDIT - now tested on Windows and works OK, so I'm confident that it IS a bug

I'm running PureBasic 5.73 LTS (MacOS X - x64) on macOS Big Sur 11.4 on a Mac mini (M1, 2020)

In the following code PackEntryName(0) returns only the first letter of the file to be uncompressed, and therefore never actually decompresses anything. File size looks OK.

macOS Debug looks like this;
/Users/minim1/PureBasic/Archive4.zip
/Users/minim1/PureBasic/test_unzip/
1 Name e Size 2542775 Type 0 D&F /Users/minim1/PureBasic/test_unzip/
2 Name a Size 5096673 Type 0 D&F /Users/minim1/PureBasic/test_unzip/
3 Name b Size 6241755 Type 0 D&F /Users/minim1/PureBasic/test_unzip/
4 Name c Size 3563622 Type 0 D&F /Users/minim1/PureBasic/test_unzip/
5 Name d Size 3134203 Type 0 D&F /Users/minim1/PureBasic/test_unzip/

The test archive was created using Finder to ensure that there were no incompatibility issues.

This code works on the same .ZIP under Windows 10
Debug shows different behaviour;
C:\Users\Admin\OneDrive\Documents\PureBasic\Archive4.zip
C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
1 Name egg.jpg Size 2542775 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
2 Name __MACOSX/._egg.jpg Size 183 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
3 Name atest.jpg Size 5096673 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
4 Name __MACOSX/._atest.jpg Size 183 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
5 Name bgfgf.jpg Size 6241755 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
6 Name __MACOSX/._bgfgf.jpg Size 183 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
7 Name cnhnh.jpg Size 3563622 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
8 Name __MACOSX/._cnhnh.jpg Size 183 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
9 Name dasf.jpg Size 3134203 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/
10 Name __MACOSX/._dasf.jpg Size 183 Type 0 D&F C:\Users\Admin\OneDrive\Documents\PureBasic\test_unzip/

Code: Select all

zipfilelocation$  = OpenFileRequester("Choose a Zip", "", "", 0)

If zipfilelocation$ =""
  Text$ + "No File Chosen"
  MessageRequester("Information", Text$)
Else
  
  UseZipPacker()
  
  destfolder$ = GetCurrentDirectory()+ "test_unzip/"
  
  CreateDirectory(destfolder$ )
  Debug zipfilelocation$
  Debug destfolder$
  
  OpenPack(0, zipfilelocation$)
  
  ExaminePack(0) 
  
  While NextPackEntry(0)
    Result = UncompressPackFile(0, destfolder$ + PackEntryName(0)  )
    n=n+1
    Test$=StrF(n) +" Name " +PackEntryName(0) + " Size "+ PackEntrySize(0) + " Type "+ PackEntryType(0) +" D&F "+destfolder$ + filename$ 
    Debug Test$
  Wend
  
  ClosePack(0)
EndIf/code]
Mac Mini M1, 2020
Mac Mini i7 2018
Acer Nitro i5, RTX 3050
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: UncompressPackFile on Big Sur

Post by collectordave »

Just answered this on another thread.

You need to add the packer to use when opening the pack and create the folders if any before unzipping any files in the zip which are in folders.


Scrappy code below:

Code: Select all

zipfilelocation$  = OpenFileRequester("Choose a Zip", "", "", 0)

If zipfilelocation$ =""
  Text$ + "No File Chosen"
  MessageRequester("Information", Text$)
Else
  
  UseZipPacker()
  
  destfolder$ = GetUserDirectory(#PB_Directory_Documents) + "test_unzip/"
  
  CreateDirectory(destfolder$ )
  ;Debug zipfilelocation$
  ;Debug destfolder$
  
  OpenPack(0, zipfilelocation$,#PB_PackerPlugin_Zip ) ;this seems to be needed
  
  ExaminePack(0) 
  
  While NextPackEntry(0)
    
     Debug PackEntryName(0)
    Debug GetPathPart(PackEntryName(0))
    
    
      CreateDirectory(destfolder$ + GetPathPart(PackEntryName(0)) )   ;create any folder before unzipping
    
    
    
    Result = UncompressPackFile(0, destfolder$ + PackEntryName(0)) ;,PackEntryName(0) )
    Debug ""
    Debug Result

    
    Debug destfolder$ + PackEntryName(0)
    
    
    n=n+1
    Test$=StrF(n) +" Name " +PackEntryName(0) + " Size "+ PackEntrySize(0) + " Type "+ PackEntryType(0) +" D&F "+destfolder$ + filename$ 
    Debug Test$
  Wend
  
  ClosePack(0)
EndIf
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply