.tar.gz in Blitzmax?

BlitzMax Forums/BlitzMax Programming/.tar.gz in Blitzmax?

Does anyone happen to know of any source to read/extract a .tar.gz archive from within BlitzMax?

Yeah, but probably not using the modules you'd like :

'
' A sample to show processing of a .tar.gz file using class factories.
'
' 2008 Bruce A Henderson
'

SuperStrict

Framework wx.wxApp
Import wx.wxArchiveClassFactory
Import wx.wxFilterClassFactory
Import wx.wxArchive
Import BRL.StandardIO

New MyApp.run()


Type MyApp Extends wxApp

	Method OnInit:Int()

		Local filename:String = "example.tar.gz"

		' load in some text
		Local in:wxInputStream = New wxFileInputStream.Create(filename)
		
		If in And in.IsOk() Then
		
			' look for a filter handler, e.g. for '.gz'
			Local fcf:wxFilterClassFactory = wxFilterClassFactory.Find(filename, wxSTREAM_FILEEXT)
			
			If fcf Then
				in = fcf.NewInputStream(in)
				' pop the extension, so if it was '.tar.gz' it is now just '.tar'
				filename = fcf.PopExtension(filename)
			End If
			
			' look for a archive handler, e.g. for '.zip' or '.tar'
			Local acf:wxArchiveClassFactory = wxArchiveClassFactory.Find(filename, wxSTREAM_FILEEXT)
			
			If acf Then
			
				Local arc:wxArchiveInputStream = acf.NewInputStream(in)
				Local entry:wxArchiveEntry = arc.GetNextEntry()
				
				' list the contents of the archive
				While entry
					Print entry.GetName()
					
					entry = arc.GetNextEntry()
				Wend
			
			Else
				DebugLog "Can't handle '" + filename + "'"
			End If
		
		End If
		
	
		Return False
	
	End Method

End Type

Output for example :
Executing:targzip.debug
icons/
icons/copy.xpm
icons/cut.xpm
icons/help.xpm
icons/new.xpm
icons/open.xpm
icons/preview.xpm
icons/print.xpm
icons/save.xpm


To extract the data, you could do something like this :
While entry
	Local size:Int = entry.GetSize()
	Local buf:Byte[] = New Byte[size]
				
	arc.Read(buf, size)
	
	entry = arc.GetNextEntry()
Wend


The example is in samples/archiveclassfactory

;-)

Ah, thanks.

I did look through all the installed mods on my computers, but didn't see anything that appeared relevant. Must have overlooked this one.

Unfortunately the downside of the wxwidgets modules are the massive size increase of the final executable -- ~4MB instead of the 80KB my app currently takes up. :-?

Unfortunately the downside of the wxwidgets modules...

Yeah, I said you wouldn't like it :-)