EnglishРусский  

   ..

   cab.g

   cab2g.dll

   cabdemo.g

   cab-x.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\lib\cab\cabdemo.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2009, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * Author: Alexey Krivonogov ( gentee )
 11 *
 12 ******************************************************************************/
 13 
 14 include : $"cab.g"
 15 
 16 func uint notify( uint code, str param, cabinfo cabi )
 17 {
 18    switch code
 19    {
 20       case $FLN_ERROR: congetch( param )
 21       case $FLN_FILEBEGIN
 22       {
 23          print( "\(param) 0% ")
 24          cabi.cabsize = 0
 25          cabi.percent = 0
 26       }
 27       case $FLN_PROGRESS
 28       {
 29          uint percent
 30           
 31          cabi.cabsize += ¶m
 32          percent = uint( 100.0 * double( cabi.cabsize ) / double( cabi.filesize ));
 33          percent = min( 100, percent )
 34          if percent > cabi.percent
 35          { 
 36             cabi.percent = percent
 37             print( " \( percent )%")
 38          }
 39       }
 40       case $FLN_FILEEND
 41       {
 42          print( " 100%\n")
 43       }
 44       case $FLN_ERROPEN
 45       {
 46          return !conrequest( "Cannot open file \( param )...Retry/Abort? [R/A]", 
 47                              "Rr|Aa" )
 48       }
 49    }
 50    return 0
 51 }
 52 
 53 func uint denotify( uint code, str param, decabinfo decab )
 54 {
 55    switch code
 56    {
 57       case $FLN_ERROR: congetch( param )
 58       case $FLN_ERROPEN
 59       {
 60          return !conrequest( "Cannot open file \( param )...Retry/Abort? [R/A]", 
 61                              "Rr|Aa" )
 62       }
 63       case $FLN_NOTVALID
 64       {
 65          return congetch( "File \( param ) is not a cabinet archive!\n" )
 66       }
 67       case $FLN_FILEBEGIN
 68       {
 69          str stemp
 70          
 71          stemp.fgetdir( decab.destfile )
 72          verifypath( stemp, 0->arrstr )
 73          decab.percent = 0
 74          decab.cursize = 0    
 75          if fileexist( decab.destfile )
 76          {
 77             setattribnormal( decab.destfile )
 78             deletefile( decab.destfile )
 79          }
 80          print("Unpack \( decab.fileinfo->finfo.fullname ) 0%")
 81          return 1
 82       }
 83       case $FLN_PROGRESS
 84       {
 85          uint percent
 86          
 87          decab.cursize += ¶m;
 88          percent = min( 100, uint( 100.0 * double( decab.cursize ) / 
 89                                  double( decab.fileinfo->finfo.sizelo )));
 90          if percent > decab.percent
 91          { 
 92             decab.percent = percent
 93             print( " \( percent )%")
 94          }
 95       }
 96       case $FLN_FILEEND
 97       {
 98          print(" 100%\n")
 99       }
100    }
101    return 0
102 }
103 
104 func main<main>
105 {
106    cabinit cabi
107    arrstr  files = %{ "c:\\temp\\*.*" }
108    arr     flags of uint 
109    
110    flags = %{ $FL_FILES  //$FL_EMPTYFLD//$FL_RECURSIVE 
111    }
112  
113    cabi.exclude = %{ "*.exe", "ci", "*.cab", "my" }
114    cabi.notify = ¬ify
115 //   cabi.level = 2       
116    cabi.volumesize = 300000
117    //cabi.disk = "mydisk"
118    cab_create( $"c:\temp\my.cab", files, flags, cabi )
119    print("==============================\n")
120    arr cablist of finfo
121    cab_list( $"c:\temp\my.cab", cablist, &denotify )
122    foreach curi, cablist
123    {
124       str date time
125       getfiledatetime( curi.lastwrite, date, time )
126       print("\( curi.fullname ) size = \(curi.sizelo ) date = \(date) time =\(time) \n")
127    }
128    print("==============================\n")
129    cab_decode( $"c:\temp\my.cab", $"c:\temp\my", &denotify )
130   
131    congetch("Press any key...")   
132 }