[Gambas-user] UnCompress question

gian bagoneo at libero.it
Fri Sep 9 14:55:19 CEST 2022


Il 09/09/22 12:18, Bruce Steers ha scritto:
> 
> So i'm looking at using gb.compress
> 
> Documentation says all about using UnCompress like a standard file 
> handle so I guess...
> 
> 1. Open an archive file using Uncompress
> 2. Open another file handle..
> 3. Read from uncompress and write data to std file handle.
> 
> That all makes sense if my file only contains one file
> 
> But how do you go about writing/unpacking multiple archive file contents 
> out to a directory?
> 
> Or can gb.compress component not be used that way?
> I had a look around the IDE code to see if i could find native 
> uncompression methods but only found Shell commands.
> 
> Many thanks for any advice
> BruceS
> 
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


Hi,

I don't know if I understand the question but do you mean something like 
this?

'----------------------------------------
Private $sPath As String = "/tmp/Foo"

Public Sub Main()

   Dim hCompress As New Compress

   If Not Exist($sPath) Then Mkdir $sPath
   For i As Integer = 1 To 9
     hCompress.Type = "zlib"
     hCompress.Open($sPath &/ "foo" & i & ".txt.gz")
     Write #hCompress, "Hello World !"
     Close #hCompress
   Next

   Decomprimi

End

Private Sub Decomprimi()

   Dim hUncompress As New Uncompress

   For Each sfile As String In Dir($sPath, "*.gz")
     hUncompress.Type = "zlib"
     hUncompress.File($sPath &/ sfile, $sPath &/ Left(sfile, -3))
   Next

End
'----------------------------------------

Regards
Gianluigi


More information about the User mailing list