<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[GMan's Mods & Stuff — Support for CRX (Chrome Extension Files)]]></title>
		<link>https://gprogs.com/viewtopic.php?id=471</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=471&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Support for CRX (Chrome Extension Files).]]></description>
		<lastBuildDate>Wed, 13 Feb 2013 15:41:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Support for CRX (Chrome Extension Files)]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1756#p1756</link>
			<description><![CDATA[<p>Hi there, </p><p>the method ScanCentralHeader of Type TZipFileList can be changed to the following code (or similar), in order to make extraction of CRX (Chrome Extension Files) possible via zipengine.</p><div class="codebox"><pre><code>    

    Rem
        bbdoc: Scans the central header for files.  Returns true if successful.
    End Rem
    Method ScanCentralHeader:Int()
    
        SeekStream(zipFile, 0)
        Local magic_number:Int = ReadInt(zipFile);
        Local zip_start_pos:Int = 0;
        
        &#039; CRX FILE (Google Chrome Extension File), see: http://developer.chrome.com/extensions/crx.html
        If magic_number = $34327243 Then
            
            zip_start_pos:+4;
            
            ReadInt(zipFile); &#039; CRX Version
            zip_start_pos:+4;
            
            zip_start_pos:+ReadInt(zipFile); &#039; length of crx public key
            zip_start_pos:+4;
            
            zip_start_pos:+ReadInt(zipFile); &#039; length of crx signature
            zip_start_pos:+4;
            
            SeekStream(zipFile, zip_start_pos);
            magic_number:Int = ReadInt(zipFile);
            
        EndIf
        
        &#039; first check to see if its even a valid ZIP file
        If magic_number &lt;&gt; $04034b50 Then 
            DebugLog(&quot;Invalid ZIP file!&quot;)
            Return False
        EndIf
        
        Local header_start:Int = 0
        
        &#039; jump to the end
        SeekStream(zipFile, StreamSize(zipFile) - 4)
        
        &#039; seek the end central directory structure
        While Not StreamPos(zipFile) = 0
            Local sig:Int = ReadInt(zipFile)
            If sig = $06054b50 Then
                &#039; jump to start of central dir location    
                SeekStream(zipFile, StreamPos(zipFile) + 12)
                header_start = ReadInt(zipFile)
                Exit                
            Else
                &#039; rewind 3 bytes and try again
                SeekStream(zipFile, StreamPos(zipFile) - 5)
            EndIf
        EndWhile
    
        &#039; if we found the header, then process
        If Not header_start Then 
            DebugLog(&quot;unable to locate central directory!&quot;)
            Return False
        EndIf
        
        header_start:+zip_start_pos;
        
        &#039; seek to the start of the central directory
        SeekStream(zipFile, header_start)
        
        While True And Not Eof(zipFile)
            Local entry:SZipFileEntry = SZipFileEntry.Create()
            If entry.header.fill(zipFile) Then
                FileList.AddLast(entry)

                &#039; read filename
                entry.zipFileName = entry.header.FileName            
                extractFilename(entry)                                 
            Else
                Exit
            EndIf
        EndWhile
    
        Return True
    EndMethod</code></pre></div><p><img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (paramausi)]]></author>
			<pubDate>Wed, 13 Feb 2013 15:41:48 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1756#p1756</guid>
		</item>
	</channel>
</rss>
