Zipping an application package by script

Chipp Walters chipp at chipp.com
Thu Sep 11 23:55:25 EDT 2008


Coming late to this party..but thought I'd throw this in and see if anyone
needs them...Thanks probably go to Sarah and perhaps Ken, too. Sorry I
sometimes forget who helps :-(

I don't have an altZip routine for Mac but I imagine one could be created
using ditto as well?


on altUnZip pFilePathToUnzip,pFolderPathToUnzipTo,pDeleteAllFirstBool
  --> MAKE FOLDER TO UNZIP TO
  if there is not a folder pFolderPathToUnzipTo then create folder
pFolderPathToUnzipTo
  put the result into tResult
  if tResult is not empty then
    put "Could Not Create ZIP folderpath: " & pFolderPathToUnzipTo into
tError
    return "Error!! " & tError &cr& tResult
  end if

  if there is not a file pFilePathToUnzip then
    put "Error! Could not find ZIP file: " & pFilePathToUnzip into tError
    return tError
  end if

  --> CLEAR ALL OLD FILES
  if pDeleteAllFirstBool is true then
    put the defaultFolder into tOldDF
    set the defaultFolder to pFolderPathToUnzipTo
    put the files into tList
    repeat for each line L in tList
      delete file L
      put the result into tResult
      if tResult is not empty and the platform is "Win32" then
        --> TRY UNLOCKING FILE
        get altUnlockWinFile(L)
        delete file L
        put the result into tResult
        if tResult is not empty then
          beep
          answer warning "Cannot Delete file: " & L &cr& tResult
        end if
      end if
    end repeat
    set the defaultFolder to tOldDF
  end if

  switch the platform
  case "MacOS"

    --> NOW NEED TO UNZIP IT
    if altGoodMacSystemForUnzip() is true then

      --> NEED TO UNZIP IT
      --> ditto -x -k -rsrc /Users/sarah/Desktop/dbsqlitemac102.zip
/Users/sarah/Desktop/

      put pFolderPathToUnzipTo into tPathToUnZipTo
      put "/" after tPathToUnZipTo

      put pFilePathToUnzip into tPath

      put "ditto -x -k -rsrc " & quote & tPath & quote & space & quote &
tPathToUnZipTo &quote into tCMD
      put shell(tCMD) into tResult
      if tResult is not "" then
        put "Error!! UnZip problem:" &cr& tResult into tErr
        return tErr
      else
        --> UnZipped correctly, now cleaning up..."
        return ""
      end if
    else
      --> SYSTEM NOT GOOD FOR UNZIPPING
      put "Error!! This version of MacOS cannot unZip correctly. Please go
to the website to download and install directly." into tErr
      return tErr
    end if
    break

  case "Win32"
    put false into tPreserve
    replace "/" with "\" in pFilePathToUnzip
    replace "/" with "\" in pFolderPathToUnzipTo
    try
      unzip pFilePathToUnzip,pFolderPathToUnzipTo,tPreserve
    catch Err
      put "Error!! Unsuccessful unZipped" && tFileName &cr& "No
revzipper.dll" into tError
      return tError
    end try
    return ""
    break

  end switch

end altUnZip

function altGoodMacSystemForUnzip
  put systemVersion() into tNum
  set itemDel to "."
  put item 1 of tNum into t1
  put item 2 of tNum into t2
  put item 3 of tNum into t3
  if t1 < 10 then return false
  if t2 < 2 then return false
  if t2 = 2 and t3 > 8 then return true
  if t2 > 2 then return true
  return false
end altGoodMacSystemForUnzip



More information about the use-livecode mailing list