Page 1 of 5
Extract archive with XAD plugin
Posted: Wed May 10, 2023 5:03 pm
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

Re: Extract archive with XAD plugin
Posted: Wed May 10, 2023 6:57 pm
by papiosaur
The command copyfiles() work for extraction but in the documention it says it's lower speed than
xad.ExtractFile().
Re: Extract archive with XAD plugin
Posted: Sat May 13, 2023 8:39 pm
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.
Re: Extract archive with XAD plugin
Posted: Mon May 15, 2023 10:32 am
by papiosaur
Thank a lot Andreas for your answer !
Yes, i didn't have installed hurl plugin...
Re: Extract archive with XAD plugin
Posted: Tue May 16, 2023 3:10 pm
by papiosaur
@Andreas,
Bizarrely, it doesn't work.
i have the same code, a message error apppear "A Xad error has occured"...
Re: Extract archive with XAD plugin
Posted: Tue May 16, 2023 11:18 pm
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
Re: Extract archive with XAD plugin
Posted: Wed May 17, 2023 9:21 am
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...
Re: Extract archive with XAD plugin
Posted: Wed May 17, 2023 1:07 pm
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...
Re: Extract archive with XAD plugin
Posted: Wed May 17, 2023 1:57 pm
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)
Re: Extract archive with XAD plugin
Posted: Wed May 17, 2023 2:34 pm
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