Extract archive with XAD plugin

Find quick help here to get you started with Hollywood
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Extract archive with XAD plugin

Post by Flinx »

I'll look at it tomorrow.
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Thanks Flinx !
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Extract archive with XAD plugin

Post by Flinx »

Now I have tried with Linux, Windows and OS3 (in WinUAE). The example script works with your lha archive and I get even the empty directory OpenBOR/Paks.
What happens if you try only the following line (in the same directory where you tried the example script)?

Code: Select all

MakeDirectory("OpenBOR/Paks")
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Extract archive with XAD plugin

Post by Flinx »

Because I have an idea what could be causing the error I made the script a bit more informative.

Code: Select all

@REQUIRE "xad"
filename$="test.lha"
If Not Exists(filename$) Then DebugPrint(filename$,"not found")
xad.OpenArchive(1, filename$)
XAD_ARCHIVE = xad.GetObjectType()
numentries = GetAttribute(XAD_ARCHIVE, 1, #XADATTRNUMENTRIES)
For Local k = 0 To numentries - 1
	Local file$=xad.GetFileAtIndex(1, k)
	Local path$=PathPart(file$)
	DebugPrint(file$)
	If Not Exists(path$) And Not EmptyStr(path$)
		MakeDirectory(path$)
	EndIf
	If xad.GetFileAttributes(1, k).Type = #DOSTYPE_DIRECTORY
		If Exists(file$)
			If Not IsDirectory(file$) Then Error("Cannot make the directory "..file$.." because a file with this name already exists.")
		EndIf
		MakeDirectory(file$)
	Else
		xad.ExtractFile(1, k, file$)
	EndIf
Next
xad.CloseArchive(1)
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Thanks a lot Flinx !!!!

It work perfectly on archives i have tested and works fine with OpenBOR archive too.

I have added progress bar support with max = numentries and level = k+1.
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Hello,

is there a limitation of number of files in an archive ?

I have an archive with 2226 files (Vim for MorphOS on Aminet) and the progress bar doesn't work... (work for all others for the moment).

Thanks for your return.

Andreas maybe ?
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Extract archive with XAD plugin

Post by Flinx »

I don't think that there is a limit at this small values. But such things you can test by yourself. I made a quick script to generate 50000 little text files (this can be done in a simple loop using StringToFile() ), made an archive from it, and my example script extracted this like expected.
Use DebugPrint() to look at the values in your program. If your code is based on the example then first check numentries.
Does the script extract all 2226 files? If yes, then the problem must be in your calculation of the value for your progressbar.
Can you show how you did this?
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Yes, the 2226 files are extracted.

Values for progress bar are:

max = numentries
level = k+1
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

ok sorry, it works...

i have a bad condition before... i'm a real newbie :-)

Sorry one more time...
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Bizarre, i have an error during extracting this archive with XAD:

https://www.morphos-storage.net/?id=1900112

I don't understand why...
Post Reply