Extract archive with XAD plugin

Find quick help here to get you started with Hollywood
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Extract archive with XAD plugin

Post by papiosaur »

Hello,

i would like extract an archive LHA to a destination but i don't understand inputs indicated in xad.guide...

i understand id and idx (dst$ is ok). I try many things but nothing work...

Plugin is activate with:

@REQUIRE "xad", {InstallAdapter = True}

Another thing xad.ExtractFile() command don't change of color in IDE (on PC and on FlowStudio on MorphOS)

Andreas, if you see my post, an simple example for each command will be very appreciated :-)
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

The command copyfiles() work for extraction but in the documention it says it's lower speed than xad.ExtractFile().
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Extract archive with XAD plugin

Post by airsoftsoftwair »

Yes, CopyFile() is slower. If you want to use xad.ExtractFile() instead, you need to do something like this:

Code: Select all

xad.OpenArchive(1, "test.lha")
XAD_ARCHIVE = xad.GetObjectType()
numentries = GetAttribute(XAD_ARCHIVE, 1, #XADATTRNUMENTRIES)
For Local k = 0 To numentries - 1 Do xad.ExtractFile(1, k, <dstfile>)
xad.CloseArchive(1)
Not very difficult.
papiosaur wrote: Wed May 10, 2023 5:03 pm Another thing xad.ExtractFile() command don't change of color in IDE (on PC and on FlowStudio on MorphOS)
Don't know if FlowStudio supports highlighting plugin APIs but on Windows this definitely works if you have xad.hwp installed. Just tried it here.
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Thank a lot Andreas for your answer !

Yes, i didn't have installed hurl plugin...
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

@Andreas,

Bizarrely, it doesn't work.

i have the same code, a message error apppear "A Xad error has occured"...
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Re: Extract archive with XAD plugin

Post by evil »

I tried Andreas code, too. And got the same error-message, you got.
But only if I used a Pathname for "<destfile>". Using a filename here (as <destFILE> implies), lets the code work.

Best regards!

George
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

Thanks evil for your return.

A filename as destination ? Sorry i don't understand, i would extract files from an archive to a destination path not to a file...
papiosaur
Posts: 161
Joined: Fri Mar 31, 2023 1:34 pm

Re: Extract archive with XAD plugin

Post by papiosaur »

if i write "ram:toto" as dstfile, i obtain an ELF file (MorphOS Executable) when i "extract" the archive.

It's a file from the archive...
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Extract archive with XAD plugin

Post by Flinx »

xad.ExtractFile() extracts only one file from the archive (from position idx). If you want to extract the complete archive, you have to make a loop, create the directories and extract the files there. Example:

Code: Select all

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
	DebugPrint(xad.GetFileAtIndex(1, k))
	If Not Exists(PathPart(xad.GetFileAtIndex(1, k))) And Not EmptyStr(PathPart(xad.GetFileAtIndex(1, k)))
		MakeDirectory(PathPart(xad.GetFileAtIndex(1, k)))
	EndIf
	xad.ExtractFile(1, k, xad.GetFileAtIndex(1, k))
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 Flink ! it work fine !

Do you have a solution to extract directly to a destination path please ? ram: for example
Post Reply