Announcement

Collapse
No announcement yet.

Creating a standard zip file with zlib v1.2.3.0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a standard zip file with zlib v1.2.3.0

    wrappers: zlib1.inc
    http://www.powerbasic.com/support/pb...ad.php?t=25053

    function definitions:
    http://refspecs.freestandards.org/lsb_3.0.0/lsb-core-generic/lsb-core-generic/libzma n.html


    dll:
    http://www.zlib.net/

    why does this not produce a standard .zip file?


    added:
    extra functions required:
    http://www.winimage.com/zlibdll/

    .inc file updated



    [this message has been edited by mike trader (edited december 19, 2006).]

  • #2
    I don't see on their web site where they promise to create a 'standard' ZIP file.

    They state zlib..
    ..is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms.
    .. which does not include any statement of compatibility or portability with other vendors' compression formats or software.


    Comment


    • #3
      life is easy if you use my updated zlib include...
      Code:
      #compile exe
      #include "win32api.inc" 
      #include "pbzlib.inc"      ' see: http://www.powerbasic.com/support/pb...ad.php?t=23813 
           
      function pbmain()
        addtozipex( "filetoadd.txt", "zipfilename.zip", %zip_close)
      end function
      ------------------
      regards,
      peter

      [this message has been edited by peter lameijn (edited december 17, 2006).]
      Regards,
      Peter

      Comment


      • #4
        Peter,
        This is a great implementation. Thank you, but it supports
        zlib DLL v1.14
        The newest version of zlib is v1.2.3.0
        This is 10% faster.

        I am guessing that there are functions in v1.14 that are not in
        v1.2.3.0 as I cannot get your code to work with the new dll.

        Does this mean someone added functionality to the original code
        and included it in the dll?

        Do these functions use the basic functions found in v1.2.3.0?

        Can I implement them somehow in a PB wrapper?



        ------------------
        Kind Regards
        Mike

        Comment


        • #5
          Mike,

          Due to the nature of being an open project, there are multiple versions of version 1.2.3 floating around to make things easier...
          The version on the zlib site doesn't support the zip/unzip functions at all... (only g(un)zip)
          The zip functions are implemented by Gilles Volant and his 1.2.3 version is downloadable on his site:
          http://www.winimage.com/zLibDll/ , the file: http://www.winimage.com/zLibDll/zlib123dll.zip
          Just rename the zlibwapi.dll to zlib.dll and the include will work...


          ------------------
          Regards,
          Peter

          [This message has been edited by Peter Lameijn (edited December 18, 2006).]
          Regards,
          Peter

          Comment


          • #6
            Some testcode I made a few years back to see contents of a zipfile.
            (Was for comparing unzip results with winzip to see if date/time/size reported OK...)
            Code:
            #Compile Exe
            #Dim All
            #Include "WIN32API.INC"
            #Include "COMMCTRL.INC"
            #Include "COMDLG32.INC"
            #Include "PBZLIB.INC"
             
            %IDD_DIALOG1 = 101  : %IDC_SYSLISTVIEW32_1 = 1001 : %IDC_BUTTON1 = 1002
            %IDC_BUTTON2 = 1003 : %IDR_MENU1 = 102 : %IDM_FILE_OPEN = 1004 : %IDM_FILE_EXIT = 1005
             
            Global hDlg As Dword, hlView As Dword
             
            Declare Function AttachMENU1(ByVal hDlg As Dword) As Dword
            Declare CallBack Function ShowDIALOG1Proc()
            Declare Function SampleListView(ByVal hDlg As Dword, ByVal lID As Long, ByVal _
                lColCnt As Long, ByVal lRowCnt As Long) As Long
            Declare Function ShowDIALOG1(ByVal hParent As Dword) As Long
             
            '--------------------------------------------------------------------------------
            Sub LV_SetItemText (ByVal iRow As Long, ByVal iCol As Long, ItemText As String)
              Local szStr As Asciiz * 64, lvi As LV_ITEM
              On Error Resume Next
             
              If iCol Then lvi.iItem = 0 Else lvi.iItem = iRow -1
              lvi.iSubItem = iCol
              lvi.mask = %LVIF_TEXT  Or %LVIF_PARAM Or %LVIF_STATE
              szStr = ItemText
              lvi.pszText = VarPtr(szStr)
              lvi.iImage = 0
              If iCol Then
                Control Send hDlg, %IDC_SYSLISTVIEW32_1, %LVM_SETITEMTEXT, iRow-1, VarPtr(LVi)
              Else
                Control Send hDlg,  %IDC_SYSLISTVIEW32_1,%LVM_SETITEM, 0, VarPtr(LVi)
              End If
              Exit Sub
            End Sub
             
            '--------------------------------------------------------------------------------
            Function GetFileNames(ZipName As Asciiz) As Long
              Local hZip As Dword, szFilePath As Asciiz * %MAX_PATH, dwRet As Dword, fCnt As Dword
              Local szStr As Asciiz * %MAX_PATH, Extra As Asciiz * %MAX_PATH, FIS As unz_file_info_s
              Local Path As String, CreatePath As String, hFile As Long, RxBuf As String, ST As SYSTEMTIME
              Local FT As FILETIME, hWinFile As Dword, fLen As Dword
              fCnt = 0
              hZip = UnzOpen (ZipName)                                              'Open zipfile
              If hZip Then                                                          'If success, go to 1st file
                dwRet = UnzGotoFirstFile(hZip)                                      'in zip archive
                While IsFalse(dwRet)                                                '
                  UnzGetCurrentFileInfo hZip, _                                     'Get info of file
                                        FIS, _                                      '
                                        szFilePath, _                               '
                                        SizeOf(szFilePath), _                       '
                                        Extra, _                                    '
                                        SizeOf(Extra), _                            '
                                        szStr, _                                    '
                                        SizeOf(szStr)                               '
                  Path = szFilePath                                                 '
                  If Right$(Path,1) <> "/" Then                                     '
                    Replace Any "/" With "\" In Path
                    ST.wSecond    = FIS.tmu_date.tm_sec                             'same as  stored date
                    ST.wMinute    = FIS.tmu_date.tm_min                             '
                    ST.wHour      = FIS.tmu_date.tm_hour                            '
                    ST.wDay       = FIS.tmu_date.tm_mday                            '
                    ST.wMonth     = FIS.tmu_date.tm_mon + 1                         '
                    ST.wYear      = FIS.tmu_date.tm_year                            '
                    SystemTimeToFileTime ST, FT                                     '
                    SetFileTime hWinFile, FT, FT, FT                                '
                    FileTimeToSystemTime FT, ST
                    Incr fCnt                                                       '
                    LV_SetItemText fCnt, 0, Path
                    LV_SetItemText fCnt, 1, Format$(ST.wMonth,"00") + "/" + Format$(ST.wDay,"00") + "/" + (Format$(ST.wYear,"0000"))
                    LV_SetItemText fCnt, 2, Format$(St.wHour,"00") + ":" + Format$(ST.wMinute,"00")+ ":" + Format$(ST.wSecond,"00")
                    LV_SetItemText fCnt, 3, Format$(FIS.Uncompressed_Size, "#,")
                    LV_SetItemText fCnt, 4, Format$(FIS.Compressed_Size, "#,")
                  End If                                                            '
                  dwRet = UnzGotoNextFile(hZip)                                     '
                Wend                                                                '
              UnzClose hZip                                                         '
              End If                                                                '
              Function = fCnt                                                       '
            End Function                                                            '
             
            '--------------------------------------------------------------------------------
            Function PBMain()
                ShowDIALOG1 %HWND_DESKTOP
            End Function
             
            '--------------------------------------------------------------------------------
            Function AttachMENU1(ByVal hDlg As Dword) As Dword
                Local hMenu As Dword, hPopUp1 As Dword
             
                Menu New Bar To hMenu
                Menu New PopUp To hPopUp1
                Menu Add PopUp, hMenu, "File", hPopUp1, %MF_ENABLED
                    Menu Add String, hPopUp1, "Open", %IDM_FILE_OPEN, %MF_ENABLED
                    Menu Add String, hPopUp1, "Exit", %IDM_FILE_EXIT, %MF_ENABLED
                Menu Attach hMenu, hDlg
                Function = hMenu
            End Function
             
            '--------------------------------------------------------------------------------
            CallBack Function ShowDIALOG1Proc()
              Local Row As Long, Col As Long, lString As String, lzStr As Asciiz * %MAX_PATH
              Select Case CbMsg
                Case %WM_COMMAND
                  Select Case CbCtl
                    Case %IDC_SYSLISTVIEW32_1
                    Case %IDM_FILE_OPEN
                      lString = "*.zip"
                      If OpenFileDialog(hDlg, "Zip archive location:", lString, CurDir$, "Zip archives|*.zip", "", _
                              %OFN_NOVALIDATE Or %OFN_HIDEREADONLY) Then
                        For Row = 1 To 300
                          For Col = 0 To 6
                            LV_SetItemText Row, Col, ""
                          Next
                        Next
                        lzStr = lString
                        GetFileNames lzStr
                      End If
                    Case %IDM_FILE_EXIT
                      Dialog End CbHndl
                  End Select
              End Select
            End Function
             
            '--------------------------------------------------------------------------------
            Function SampleListView(ByVal hDlg As Dword, ByVal lID As Long, ByVal lColCnt As _
                Long, ByVal lRowCnt As Long) As Long
                Local lStyle  As Long
                Local tLVC    As LV_COLUMN
                Local tLVI    As LV_ITEM
                Local szBuf   As Asciiz * 32
                Local lCol    As Long
                Local lRow    As Long
                Local hCtl    As Dword
             
                Control Handle hDlg, lID To hCtl
             
                lStyle = ListView_GetExtendedListViewStyle(hCtl)
                ListView_SetExtendedListViewStyle hCtl, _
                    lStyle Or %LVS_EX_FULLROWSELECT Or %LVS_EX_GRIDLINES
             
                'Load column headers.
                tLVC.mask    = %LVCF_FMT Or %LVCF_TEXT Or %LVCF_SUBITEM
                tLVC.fmt     = %LVCFMT_LEFT
                tLVC.pszText = VarPtr(szBuf)
             
                tLVC.iOrder = 0
                szBuf = "Extracted file name and path"
                ListView_InsertColumn hCtl, 0, tLVC
             
                tLVC.iOrder = 1
                szBuf = "File date"
                ListView_InsertColumn hCtl, 1, tLVC
             
                tLVC.iOrder = 2
                szBuf = "File time"
                ListView_InsertColumn hCtl, 2, tLVC
             
                tLVC.iOrder = 3
                szBuf = "File size"
                ListView_InsertColumn hCtl, 3, tLVC
             
                tLVC.iOrder = 4
                szBuf = "Packed"
                ListView_InsertColumn hCtl, 4, tLVC
             
                For lRow = 0 To lRowCnt - 1
                    tLVI.stateMask   = %LVIS_FOCUSED
                    tLVI.pszText     = VarPtr(szBuf)
                    tLVI.iItem       = lRow
                    For lCol = 0 To lColCnt - 1
                        szBuf           = ""
                        tLVI.iSubItem   = lCol
                        tLVI.lParam     = lRow
                        If lCol = 0 Then
                            tLVI.mask = %LVIF_TEXT Or %LVIF_PARAM Or %LVIF_STATE
                            ListView_InsertItem hCtl, tLVI
                        Else
                            tLVI.mask = %LVIF_TEXT
                            ListView_SetItem hCtl, tLVI
                        End If
                    Next lCol
                Next i
             
                ListView_SetColumnWidth hCtl, 0, 250
                ListView_SetColumnWidth hCtl, 1, 80
                ListView_SetColumnWidth hCtl, 2, 60
                ListView_SetColumnWidth hCtl, 3, 80
                ListView_SetColumnWidth hCtl, 4, 80
             
            End Function
            '--------------------------------------------------------------------------------
             
            '--------------------------------------------------------------------------------
            '   ** Dialogs **
            '--------------------------------------------------------------------------------
            Function ShowDIALOG1(ByVal hParent As Dword) As Long
                Local lRslt As Long, szPtr As Asciiz Ptr
             
              InitCommonControls
              Local Icc As Init_Common_ControlsEx
              Icc.dwSize = SizeOf(Icc)
              Icc.dwIcc = %ICC_DATE_CLASSES Or %ICC_BAR_CLASSES Or %ICC_LISTVIEW_CLASSES
              InitCommonControlsEx Icc
             
              Dialog New hParent, "ZLib version " & ZLibVersion, , , 392, 176, To hDlg
              Control Add "SysListView32", hDlg, %IDC_SYSLISTVIEW32_1, "SysListView321", _
                  5, 5, 385, 155, %WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_TABSTOP _
                  Or %LVS_REPORT Or %LVS_SHOWSELALWAYS, %WS_EX_LEFT Or _
                  %WS_EX_RIGHTSCROLLBAR
              Control Handle hDlg, %IDC_SYSLISTVIEW32_1 To hLView
              AttachMENU1 hDlg
              SampleListView hDlg, %IDC_SYSLISTVIEW32_1, 5, 300
              Dialog Show Modal hDlg, Call ShowDIALOG1Proc To lRslt
              Function = lRslt
            End Function
            '--------------------------------------------------------------------------------

            ------------------
            Regards,
            Peter
            Regards,
            Peter

            Comment


            • #7
              Not that this has anything to do with ZIP file format, but...
              Code:
              #Include "COMMCTRL.INC"
              ...
              Sub LV_SetItemText ...
              ...
              You did know there is a Listview_SetITemText in COMMCTRL.INC, right?
              Code:
              VOID ListView_SetItemText(
                  HWND hwnd,
                  int i,
                  int iSubItem,
                  LPCSTR pszText
              );

              But if there some reason you didn't want to use use that...

              Code:
              If iCol Then    
                Control Send hDlg, %IDC_SYSLISTVIEW32_1, %LVM_SETITEMTEXT, iRow-1, VarPtr(LVi)
              Else    
                Control Send hDlg,  %IDC_SYSLISTVIEW32_1,%LVM_SETITEM, 0, VarPtr(LVi)
              End If
              ???

              Don't you have Row (ie lvi.iItem) and Column confused in a few places here? And setting the text should always reset the row 'lparam' ??

              e.g., if a zero 'iCol' is passed, then you want to update ROW zero, otherwise you update the ROW represented by iCOL-1 ???

              Or have I just read too much into the data names you have selected?

              Comment


              • #8
                The zlib.net's faq says:

                11. Can zlib handle .zip archives?

                Not by itself, no. See the directory contrib/minizip in the zlib distribution.

                If you download the zlib source the folder contrib/minizip is available.
                However it's not compiled (of course)

                Maybe someone can.. ever.

                I have no real need for that, v1.14 works fine (zip compatible)

                I find it ackward they never really mention (afaik) why the abandoned zip support.

                The new lib was "just there" at some day.



                ------------------
                http://www.hellobasic.com
                hellobasic

                Comment


                • #9
                  See: http://www.winimage.com/zLibDll/zlib123dll.zip for version 1.2.3 with zip compatible functions...


                  ------------------
                  Regards,
                  Peter
                  Regards,
                  Peter

                  Comment


                  • #10
                    This site is not related to zlib development.
                    You can't trust such a dll for professional use.



                    ------------------
                    http://www.hellobasic.com
                    hellobasic

                    Comment


                    • #11
                      The DLL by Gilles Volant is just a version with ZLib and MiniZip/UnZip compiled into one DLL, no more. If you don't
                      trust third-party compiled DLL's, there are guidelines on the site how to compile the sources into one DLL yourself.
                      In previous versions it was already compiled with the MiniZip/unZip code...
                      (The ZLib and (Un)Zip functions are two separate sources; only the (Un)Zip is based on the ZLib functions, so it makes
                      sense to put them into one DLL)


                      ------------------
                      Regards,
                      Peter
                      Regards,
                      Peter

                      Comment


                      • #12
                        What we need is zlib converted to PB so that it can be included
                        in an install and/or zip creation program. Not just the include
                        file(s) that are available but the algorithm(s) too.

                        I still use pkzip to make zip files most of the time even though
                        I have Powerzip. I have used zlib in the past for unzipping and
                        it works well as most of you know. Just wished we had something
                        to include that could be made into 1 program without having to
                        call an additional dll.

                        ------------------
                        Client Writeup for the CPA


                        mailto:[email protected][email protected]</A>
                        Client Writeup for the CPA

                        buffs.proboards2.com

                        Links Page

                        Comment


                        • #13
                          At least:

                          Bundling and running the zlib 1.14 dll from your app without extraction to disk is a simple matter.
                          (Using the special dll loading stuff i mean)


                          ------------------
                          http://www.hellobasic.com
                          hellobasic

                          Comment


                          • #14
                            I like this feature a lot. I use it with PEBundle (which is no longer
                            available). Is someone else doing this now, too?

                            Pretty neat stuff.

                            -John

                            ------------------
                            LOCAL MyEMail AS STRING , MySkype AS STRING
                            MyEmail = STRREVERSE$("letnitj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")
                            MySkype = STRREVERSE$("adirolftj")
                            LOCAL MyEMail AS STRING
                            MyEmail = STRREVERSE$("53pmohtj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")

                            Comment


                            • #15
                              >What we need is zlib converted to PB so that it can be included
                              in an install and/or zip creation program. Not just the include
                              file(s) that are available but the algorithm(s) too.
                              I still use pkzip to make zip files most of the time even though
                              I have Powerzip. I have used zlib in the past for unzipping and
                              it works well as most of you know. Just wished we had something
                              to include that could be made into 1 program without having to
                              call an additional dll.


                              I agree.

                              ------------------
                              Kind Regards
                              Mike

                              Comment


                              • #16
                                I really don't see a problem in using the DLL as it is... It would be a huge effort porting everything to PB,
                                and it probably would get slower (Most of the algorithm stuff is in assember)
                                It would also imply a major overhaul on every new version...
                                It's quite neat to have all zip related functions in one DLL)
                                Don't mind having a few DLL's, as long as it doesn't get too much.

                                (Lately I installed a package for programming Eproms and MCU's. It installs some 82 DLL's. I find that a
                                little bit too much )

                                ------------------
                                Regards,
                                Peter
                                Regards,
                                Peter

                                Comment


                                • #17
                                  Wow, 82 dlls, sounds like the VB or .NET run time requirements!

                                  would it not be possible to just copy and paste the asm into the
                                  PB compiler? From my limited knowledge of asm, it would seem
                                  that this would work?

                                  I reworked my include file to include the ZIP functions for v1.2.3.0
                                  This example gives me:
                                  ' My results using AddToZip() (INCLUDES DISK READ/WRITE) on a 1MB .exe (your milage may vary)'
                                  %Z_DEFAULT_COMPRESSION Compression Speed = 120 m/s per Megabyte (9.82% Compression)'
                                  %Z_DEFAULT_COMPRESSION DeCompression Speed = 22 m/s per Megabyte

                                  Great to have Zip Compatability tho. Thx Peter.


                                  Code:
                                  #COMPILE EXE  "ZLibTest.exe"
                                  
                                  #INCLUDE "WIN32API.INC" 
                                  #INCLUDE "zlibwapi.inc" 
                                  
                                  
                                  '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' 
                                  FUNCTION PBMAIN   
                                                    
                                    LOCAL RetVal, hFile, FileLen, ZipFileLen AS LONG
                                    LOCAL sFile, sComp, t, sOrigPathnFile, sZipPathnFile, sContents AS STRING
                                                                 
                                    LOCAL PerfFreq, t1, t2 AS QUAD 
                                    LOCAL Elapsed AS SINGLE   
                                  
                                      RetVal = QueryPerformanceFrequency(PerfFreq) ' Checkhardware supports High Resolution Timer
                                                              
                                      sOrigPathnFile = "1MBBinary.exe"   
                                      sZipPathnFile  = "1MBBinary.zip"
                                  
                                                         
                                      hFile = FREEFILE ' Save the Declarations
                                      OPEN sOrigPathnFile FOR BINARY SHARED AS hFile 
                                        IF ERR THEN MSGBOX "Problem opening file",48,"File Error"+STR$(ERRCLEAR)  
                                        FileLen = LOF(hFile)
                                      CLOSE hFile '
                                      sFile = ""   
                                      t = t + "Input File length :" + STR$(FileLen) + $CRLF ' 
                                  
                                      QueryPerformanceCounter t1   
                                      RetVal = AddToZip( sOrigPathnFile, sZipPathnFile )  
                                      IF RetVal THEN MSGBOX "CompressFile Error1:"+STR$(RetVal) : EXIT FUNCTION
                                      RetVal = AddToZip( "", "" ) 'Close the zip file
                                      IF RetVal THEN MSGBOX "CompressFile Error2:"+STR$(RetVal) : EXIT FUNCTION
                                      QueryPerformanceCounter t2 : Elapsed = (t2-t1)/PerfFreq*1000 ' m/s  
                                  
                                      t = t + "Compression:"+STR$(Elapsed)+" m/s" + $CRLF
                                                     
                                                    
                                      hFile = FREEFILE ' Save the Declarations
                                      OPEN sZipPathnFile FOR BINARY SHARED AS hFile 
                                        IF ERR THEN MSGBOX "Problem opening file",48,"File Error"+STR$(ERRCLEAR)  
                                        ZipFileLen = LOF(hFile)
                                      CLOSE hFile '
                                      sFile = ""             
                                      t = t + "Compressed File length :" + STR$(ZipFileLen) + $CRLF  
                                      t = t + "Compression " + FORMAT$( (1-(ZipFileLen/FileLen))*100, "0.00"  ) + "%" + $CRLF 
                                                       
                                  
                                      QueryPerformanceCounter t1 
                                      RetVal = ExtractFromzip( sZipPathnFile )
                                      IF RetVal = 0 THEN MSGBOX "UnCompressFile Error:"+STR$(RetVal) : EXIT FUNCTION
                                      QueryPerformanceCounter t2 : Elapsed = (t2-t1)/PerfFreq*1000 ' m/s 
                                  
                                  
                                      hFile = FREEFILE ' Save the Declarations
                                      OPEN sOrigPathnFile FOR BINARY SHARED AS hFile 
                                        IF ERR THEN MSGBOX "Problem opening file",48,"File Error"+STR$(ERRCLEAR)  
                                        FileLen = LOF(hFile)
                                      CLOSE hFile '
                                      sFile = ""   
                                      t = t + "UnCompress File length :" + STR$(FileLen) + $CRLF 
                                  
                                      t = t + "DeCompression:"+STR$(Elapsed)+" m/s"
                                  
                                      CALL ShowFileNames( sZipPathnFile, sContents )
                                  
                                      MSGBOX t+$CRLF+$CRLF+sContents,64,ZLibCurrentVersion 
                                  
                                  END FUNCTION
                                  ------------------
                                  Kind Regards
                                  Mike

                                  [This message has been edited by Mike Trader (edited December 19, 2006).]

                                  Comment


                                  • #18

                                    Compressing a string in memory

                                    ' My results using CompressString() on a 1MB .exe (your milage may vary)
                                    ' %Z_DEFAULT_COMPRESSION Compression Speed = 108 m/s per Megabyte (9.83% Compression)
                                    ' %Z_DEFAULT_COMPRESSION DeCompression Speed = 11 m/s per Megabyte

                                    Code:
                                    #COMPILE EXE  "ZLibTest.exe"
                                    
                                    #INCLUDE "WIN32API.INC" 
                                    #INCLUDE "zlibwapi.inc" 
                                    
                                    
                                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' 
                                    FUNCTION PBMAIN   
                                                      
                                      LOCAL RetVal, hFile AS LONG
                                      LOCAL sFile, sComp, t, sOrigPathnFile AS STRING
                                                                   
                                      LOCAL PerfFreq, t1, t2 AS QUAD 
                                      LOCAL Elapsed AS SINGLE   
                                    
                                        RetVal = QueryPerformanceFrequency(PerfFreq) ' Checkhardware supports High Resolution Timer
                                                      
                                        sOrigPathnFile = "1MBBinary.exe"   
                                    
                                        hFile = FREEFILE ' Save the Declarations
                                        OPEN sOrigPathnFile FOR BINARY SHARED AS hFile 
                                          IF ERR THEN MSGBOX "Problem opening file",48,"File Error"+STR$(ERRCLEAR)
                                          GET$ #hFile, LOF(hFile), sFile
                                        CLOSE hFile '
                                    
                                        t = t + "Input File length :" + STR$(LEN(sFile)) + $CRLF ' 4 bytes prepended
                                                          
                                        QueryPerformanceCounter t1   
                                        RetVal = CompressString( sFile, sComp, %Z_DEFAULT_COMPRESSION ) ' %Z_BEST_SPEED, %Z_BEST_COMPRESSION, %Z_DEFAULT_COMPRESSION 
                                        IF RetVal THEN MSGBOX "CompressFile Error="+STR$(RetVal),48,"CompressFile Error" : EXIT FUNCTION
                                        QueryPerformanceCounter t2 : Elapsed = (t2-t1)/PerfFreq*1000 ' m/s  
                                    
                                        t = t + "Compression:"+STR$(Elapsed)+" m/s" + $CRLF
                                    
                                        t = t + "Compressed File length :" + STR$(LEN(sComp)-4) + $CRLF  
                                        t = t + "Compression " + format$( (1-((LEN(sComp)-4)/LEN(sFile)))*100, "0.00"  ) + "%" + $CRLF 
                                    
                                        QueryPerformanceCounter t1 
                                        RetVal = UnCompressString( sComp, sFile )  ' For Rx data over internet etc 
                                        IF RetVal THEN MSGBOX "UnCompressFile Error="+STR$(RetVal),48,"UnCompressFile Error"
                                        QueryPerformanceCounter t2 : Elapsed = (t2-t1)/PerfFreq*1000 ' m/s  
                                        t = t + "UnCompress File length :" + STR$(LEN(sFile)) + $CRLF 
                                    
                                        t = t + "DeCompression:"+STR$(Elapsed)+" m/s"
                                    
                                        MSGBOX t,64,ZLibCurrentVersion
                                    
                                    END FUNCTION
                                    ------------------
                                    Kind Regards
                                    Mike

                                    Comment


                                    • #19
                                      What we need is zlib converted to PB so that it can be included in an install and/or zip creation program.
                                      Um, why?

                                      If you are creating compressed files for use with your application, who cares what algorithm you use, as long as you provide de-compression software?

                                      Just wished we had something to include that could be made into 1 program without having to call an additional dll.
                                      For crying out loud, every single Windows program you create with the PB compilers calls functions in multiple DLLs anyway.

                                      And if the issue is "one file download/install", get yourself an Installer package (that's what Installer packages do) . A lot of folks here use Inno Setup which is really really excellent.

                                      MCM

                                      Comment


                                      • #20
                                        >For crying out loud, every single Wi...

                                        And you have a problem lacking affinity with other type of programmers.

                                        -----------------------
                                        PS, i meant the plain PB code for bundling..


                                        ------------------
                                        http://www.hellobasic.com
                                        hellobasic

                                        Comment

                                        Working...
                                        X