home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / LZFUNCS.PRG < prev    next >
Text File  |  1994-11-08  |  2KB  |  90 lines

  1. ////////////////////////////
  2. //
  3. //    Clip-4-Win LZ functions demo
  4. //
  5. //    Copyright (C) 1994 Skelton Software, Kendal Cottage, Hillam, Leeds, UK.
  6. //    All Rights Reserved.
  7. //
  8. //    Compile:    LZfuncs /n /w
  9. //    Link:        /se:600 LZfuncs,,,clip4win,clip4win.def
  10. //
  11. ////////////////////////////
  12.  
  13. #include "windows.ch"
  14. #include "openfile.ch"
  15.  
  16.  
  17. #define    nstr(i)     alltrim(str(i))
  18.  
  19.  
  20. static    hWnd
  21. static    cAppName := "Clip-4-Win"
  22.  
  23.  
  24. function main()
  25. local    nEv
  26.  
  27. hWnd = WinSetup(cAppName, "Clip-4-Win LZ functions demo")
  28.  
  29. do while .t.
  30.     do while (nEv := ChkEvent()) == EVENT_NONE
  31.     enddo
  32.  
  33.     do case
  34.     case nEv == EVENT_REDRAW
  35.         @ 5,2 say "Note: whenever you run COMPRESS.EXE, think about using /R"
  36.         @ 9,2 say "Hit SPACE..."
  37.     case nEv == EVENT_KEY .and. inkey(0) == 32
  38.         DoLZCopy()
  39.     endcase
  40. enddo
  41.  
  42. return 0
  43.  
  44.  
  45. procedure DoLZCopy()
  46. local    cFile, cDst
  47. local    hSrc, hDst
  48. local    cSrcOFS, cDstOFS
  49. local    nRet
  50.  
  51. cFile = GetOpenFileName( , "*.??_", "Pick a file created by COMPRESS.EXE")
  52. if cFile != nil
  53.     cDst = space(128)
  54.     nRet = GetExpandedName(cFile, @cDst)
  55. //    MessageBox( , nstr(nRet), "From GetExpandedName")
  56.     cDst = left(cDst, at(chr(0), cDst + chr(0)) - 1)
  57. //    MessageBox( , cDst, "From GetExpandedName")
  58.     cDst = GetSaveFileName( , cDst, "New name")
  59. endif
  60. if cFile != nil .and. cDst != nil
  61.     cSrcOFS = a2bin({0,0,0,space(4),space(128)}, OFS_A2BIN)
  62.     cDstOFS = a2bin({0,0,0,space(4),space(128)}, OFS_A2BIN)
  63.     hSrc = LZOpenFile(cFile, @cSrcOFS, OF_READ)
  64.     hDst = LZOpenFile(cDst, @cDstOFS, OF_CREATE)
  65.     nRet = LZCopy(hSrc, hDst)
  66.     LZClose(hSrc)
  67.     LZClose(hDst)
  68.     if nRet >= 0
  69.         MessageBox( , nstr(nRet), "Size of new file")
  70.     else
  71.         MessageBox( , nstr(nRet), "Error code from LZCopy")
  72.     endif
  73. endif
  74.  
  75. return
  76.  
  77.  
  78. // Get original file name (if COMPRESS /R was used), else cSrc
  79. _DLL function GetExpandedName(cSrc AS STRING, cDst AS STRING) ;
  80.               AS INT Pascal:LZEXPAND.GetExpandedName
  81.  
  82. _DLL function LZOpenFile(cFile AS STRING, cOFS AS STRING, nFlags AS UINT) ;
  83.               AS INT Pascal:LZEXPAND.LZOpenFile
  84.  
  85. _DLL function LZCopy(hSrc AS INT, hDst AS INT) AS LONG Pascal:LZEXPAND.LZCopy
  86.  
  87. _DLL function LZClose(hFile AS INT) AS VOID Pascal:LZEXPAND.LZClose
  88.  
  89.  
  90.