Page 3 of 3
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Mon Feb 13, 2023 8:27 pm
by infratec
You know that you have
This is much easier than RestList() ... NextElement()
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Mon Feb 13, 2023 9:28 pm
by infratec
To extract this file:
https://files.scene.org/get/demos/group ... s-vrtg.lzx
I needed to do:
Code: Select all
Procedure .i open_output(Filename$, ArchiveName$)
Protected szDestination.s, subdir_count.i, i.i
ReplaceString(Filename$, "?", "_", #PB_String_InPlace)
ReplaceString(Filename$, "|", "_", #PB_String_InPlace)
szDestination.s = GetPathPart(ArchiveName$) + GetFilePart(ArchiveName$, #PB_FileSystem_NoExtension) + "/"
CreateDirectory(szDestination)
If FindString(Filename$, "/")
subdir_count = CountString(Filename$, "/")
For i = 1 To subdir_count
szDestination + StringField(Filename$, i, "/") + "/"
CreateDirectory(szDestination)
Next i
EndIf
ProcedureReturn CreateFile(#PB_Any, szDestination + GetFilePart(Filename$))
EndProcedure
else some files were not extracted.
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Mon Feb 13, 2023 9:35 pm
by Marty2PB
infratec wrote: Mon Feb 13, 2023 8:27 pm
You know that you have
This is much easier than RestList() ... NextElement()
Yes, that's right. I didn't have that on my radar at all. I did the routine this morning before I went to bed. But it's not even final yet.
infratec wrote: Mon Feb 13, 2023 9:28 pm
To extract this file:
https://files.scene.org/get/demos/group ... s-vrtg.lzx
I needed to do:
Code: Select all
Procedure .i open_output(Filename$, ArchiveName$)
Protected szDestination.s, subdir_count.i, i.i
ReplaceString(Filename$, "?", "_", #PB_String_InPlace)
ReplaceString(Filename$, "|", "_", #PB_String_InPlace)
szDestination.s = GetPathPart(ArchiveName$) + GetFilePart(ArchiveName$, #PB_FileSystem_NoExtension) + "/"
CreateDirectory(szDestination)
If FindString(Filename$, "/")
subdir_count = CountString(Filename$, "/")
For i = 1 To subdir_count
szDestination + StringField(Filename$, i, "/") + "/"
CreateDirectory(szDestination)
Next i
EndIf
ProcedureReturn CreateFile(#PB_Any, szDestination + GetFilePart(Filename$))
EndProcedure
else some files were not extracted.
Yes. I already thought so. The Amiga file system allows characters that do not work under Windows.
I had an archive with 2 disk images in it, but they were all "0" in size. CRC is equal to 0 for sum and crc. I initially treated it as an error.
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Mon Feb 13, 2023 9:36 pm
by infratec
There should be return values:
Code: Select all
Procedure .i Process_DataContent(*UnLZX.LZX_ARCHIVE )
With *UnLZX
ResetList(\FileData() )
ResetList(\ListData() )
While NextElement( \FileData() )
If ( Len( \FileData()\File) > 0 )
AddElement( \ListData() )
\ListData()\PathFile = \FileData()\File
\ListData()\Position = ListIndex( \FileData() )
EndIf
Wend
ResetList(\FileData() )
ResetList(\ListData() )
EndWith
ProcedureReturn ListSize(*UnLZX\ListData())
EndProcedure
Code: Select all
Procedure .i Examine_Archive( *UnLZX.LZX_ARCHIVE )
Protected.i Result
If ( *UnLZX > 0 )
Result = Process_DataContent(*UnLZX )
Debug_View_Archiv(*UnLZX)
EndIf
ProcedureReturn Result
EndProcedure
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Tue Feb 14, 2023 8:46 am
by Marty2PB
This works now good
- Extract to given target directory
- Extract All or
- Extract single files by Name or Position Number
- External Content List usable outside of pbUnLZX
v-0.6
Adding: Verify Archive UnLZX::Verify_Archive(*LzxMemory)
Resault are BAD Crc's Only
Extracting WHDload LZX Archive (543 Files Merged packed)
Extracting Single File
https://github.com/MartyShepard/LHvSyst ... hiveLZX.pb
greetings
Re: Conversion UnLZX (LZX decompress ) in C to PB Nativ
Posted: Wed Feb 15, 2023 9:41 am
by Fred
Good work !! Just tried with
https://www.purebasic.com/download/PureBasic.lzx and it worked as expected.