Page 1 of 1
Unzip/unrar on Big Sur
Posted: Thu Jul 15, 2021 4:37 am
by CoopsOz
I want to uncompress files, but
UncompressPackFile doesn't work on Big Sur. The same code is fine on Windows, so I've posted this as a bug
http://forums.purebasic.com/english/vie ... e9#p572561.
Does anyone have a way of unzipping files on Big Sur?
Here's the code that works on Windows but not on Big Sur.
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
Re: Unzip/unrar on Big Sur
Posted: Fri Jul 16, 2021 9:45 am
by collectordave
Tried this on bigger as well and did not work.
Each pack entry name was repeaters W
Changed one line to
If OpenPack(0, zipfilelocation$,#PB_PackerPlugin_Zip )
and the pack entry names are reported correctly.
Re: Unzip/unrar on Big Sur
Posted: Fri Jul 16, 2021 10:04 am
by collectordave
Tried a little more and it seems you need the folder created ready for any file to be uncompressed.
Sorry about the scrappy code but this works for me on BigSur:
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 )
ExaminePack(0)
While NextPackEntry(0)
Debug PackEntryName(0)
Debug GetPathPart(PackEntryName(0))
CreateDirectory(destfolder$ + GetPathPart(PackEntryName(0)) )
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
Re: Unzip/unrar on Big Sur
Posted: Fri Jul 16, 2021 2:41 pm
by CoopsOz
Cheers,
That works for me too. Oddly, if I change
Code: Select all
destfolder$ = GetUserDirectory(#PB_Directory_Documents) + "test_unzip/"
to my working directory - it fails. I assume some permissions issue. I didn't want iCloud backing up many scraps* of files, so my PureBasic directory is top level. If I change the one line below it fails.
Code: Select all
destfolder$ = GetUserDirectory(#PB_Directory_Documents) + "test_unzip/"
I'm finding that I don't need to have the directory created; I even commented out the 2nd CreateDirectory (within the loop) and that works OK, too.
Thanks
* We all write scrappy code, no apologies required.
Re: Unzip/unrar on Big Sur
Posted: Fri Jul 16, 2021 3:41 pm
by collectordave
If you are trying to use:
Code: Select all
destfolder$ = GetCurrentDirectory()+ "test_unzip/"
That can fail as the current directory can be inside the application always best to use absolute addressing.
It is also not the same as the executable directory there are a few posts on the forum that explain that very well.
You mention iCloud the way I do it is to have a folder in documents for each app to hold the zip files I then have a small xcopy application that copies these to iCloud or anywhere else I tell it to but copies only the newer files.
Good luck with it all.