Hello,
i would like to get the total files size from an archive LHA with XAD. It's possible?
Thanks for your help.
XAD: Get total files size from an archive LHA.
Re: XAD: Get total files size from an archive LHA.
ok, i must open the archive and get size of files like it was normal files...
[EDIT] Argggg. it's more difficult i thank...
I must get names files of the archive and get size of each file and do the result at the end of scan?
[EDIT] Argggg. it's more difficult i thank...
I must get names files of the archive and get size of each file and do the result at the end of scan?
Re: XAD: Get total files size from an archive LHA.
Couple quick tests... the latter seems to be faster. But I'm in really hurry so maybe I didn't think all options
Code: Select all
@REQUIRE "xad", {InstallAdapter = True}
Function p_GetUnpackedSizeXad(file$)
Local size = 0
If Exists(file$)
Local xid = xad.OpenArchive(Nil, file$)
Local xarc = xad.GetObjectType()
Local xnum = GetAttribute(xarc, xid, #XADATTRNUMENTRIES)
For Local i = 0 To xnum -1
Local t = xad.GetFileAttributes(xid, i)
size = size + t.size
Next
xad.CloseArchive(xid)
EndIf
Return(size)
EndFunction
StartTimer(1)
DebugPrint("Size:", p_GetUnpackedSizeXad("RAM:test.lha"))
DebugPrint("Time:", GetTimer(1))
Function p_GetUnpackedSizeDir(file$, size)
Local err, id = ?OpenDirectory(Nil, file$)
If Not err
Local e = NextDirectoryEntry(id)
While e <> Nil
If e.Type = #DOSTYPE_DIRECTORY
size = p_GetUnpackedSizeDir(FullPath(file$, e.name), size)
Else
size = size + e.size
EndIf
e = NextDirectoryEntry(id)
Wend
CloseDirectory(id)
EndIf
Return(size)
EndFunction
StartTimer(1)
DebugPrint("Size:", p_GetUnpackedSizeDir("RAM:test.lha"))
DebugPrint("Time:", GetTimer(1))
Re: XAD: Get total files size from an archive LHA.
Thanks a lot jPV! i will test them
Re: XAD: Get total files size from an archive LHA.
@jPV: i have tested but unfortunally it use many CPU for big archive...
i will found another solution using "lha l" command and get the value of total size with 'STRING' commands.
i get the value with commands from the MorphOS SDK like this syntax:
i will found another solution using "lha l" command and get the value of total size with 'STRING' commands.
i get the value with commands from the MorphOS SDK like this syntax:
Code: Select all
lha l ram:archive.lha | tail -4 | head -n 1 | xargs echo | head -n 1" >ram:value.txt