;ZipDLL include file for NSIS
;Written by Tim Kosse (mailto:tim.kosse@gmx.de)
;Compatible with Modern UI 1.62

!ifndef MUI_MACROS_USED
  !error "Please include modern UI first!!"
!endif

!ifndef MUI_ZIPDLL_USED

!define MUI_ZIPDLL_USED

function ZipDLL_ExtractAllFunc

  Push $R3
  Exch
  Exch $R2
  Exch 2
  Exch $R1

  StrCpy $R3 ""

  ;The strings that will be translated are:

  ;"Extracting contents of %s to %s"
  ;"  Extracting %d files and directories"
  ;"  Extract : %s"
  ;"  Error: Could not extract %s"
  ;"Could not extract %s"
  ;"Error: Could not get file attributes."
  ;"Could not get file attributes."
  ;"  Error: %s"


  !ifdef "MUI_LANGUAGEFILE_GERMAN_USED"
    strcmp $LANGUAGE ${LANG_GERMAN} 0 ZipDLL_German_Done
    StrCpy $R3 "done"
    ZipDLL::extractall "/TRANSLATE" \
                       "Dekomprimiere Inhalt von %s nach %s" \
                       "  Dekomprimiere %d Dateien und Verzeichnisse" \
                       "  Dekomprimiere: %s" \
                       "  Fehler: %s konnte nicht dekomprimiert werden." \
                       "%s konnte nicht dekomprimiert werden." \
                       "Fehler: Dateiattribute konnten nicht ermittelt werden." \
                       "Dateiattribute konnten nicht ermittelt werden." \
                       "  Fehler: %s" \
                       "$R1" "$R2"
    goto ZipDLL_Done
   ZipDLL_German_Done:
  !endif

  !ifdef "MUI_LANGUAGEFILE_FRENCH_USED"
    strcmp $LANGUAGE ${LANG_FRENCH} 0 ZipDLL_French_Done
    StrCpy $R3 "done"
    ZipDLL::extractall "/TRANSLATE" \
                       "Décompression des données de %s vers %s" \
                       "  Décompression de %d fichiers et répertoires" \
                       "  Décompression : %s" \
                       "  Erreur : Impossible de décompresser %s." \
                       "Impossible de décompresser %s." \
                       "Erreur : Impossible de récupérer les informations sur le fichier." \
                       "Impossible de récupérer les informations sur le fichier." \
                       "  Erreur : %s" \
                       "$R1" "$R2"
    goto ZipDLL_Done
   ZipDLL_French_Done:
  !endif

  StrCmp $R3 "" 0 ZipDLL_Done
  ZipDLL::extractall "$R1" "$R2"

 ZipDLL_Done:
  
  Pop $R1
  Pop $R2
  Pop $R3
  Exch $R1

functionend

function ZipDLL_ExtractFileFunc

  Push $R4
  Exch
  Exch $R3
  Exch 2
  Exch $R2
  Exch 3
  Exch $R1

  StrCpy $R4 ""

  ;The strings that will be translated are:

  ;"Extracting the file %s from %s to %s"
  ;"Error: Specified file does not exist in archive."
  ;"Specified file does not exist in archive."
  ;"  Error: Could not extract %s"
  ;"Could not extract %s"
  ;"Error: Could not get file attributes."
  ;"Could not get file attributes."
  ;"  Error: %s"

  !ifdef "MUI_LANGUAGEFILE_GERMAN_USED"
    strcmp $LANGUAGE ${LANG_GERMAN} 0 ZipDLL_File_German_Done
    StrCpy $R4 "done"
    ZipDLL::extractfile "/TRANSLATE" \
                       "Dekomprimiere Datei %s von %s nach %s" \
                       "Fehler: Die angegebene Datei existiert nicht im Archiv" \
                       "Die angegebene Datei existiert nicht im Archiv" \
                       "  Fehler: %s konnte nicht dekomprimiert werden." \
                       "%s konnte nicht dekomprimiert werden." \
                       "Fehler: Dateiattribute konnten nicht ermittelt werden." \
                       "Dateiattribute konnten nicht ermittelt werden." \
                       "  Fehler: %s" \
                       "$R1" "$R2" "$R3"
    goto ZipDLL_File_Done
   ZipDLL_File_German_Done:
  !endif

  !ifdef "MUI_LANGUAGEFILE_FRENCH_USED"
    strcmp $LANGUAGE ${LANG_FRENCH} 0 ZipDLL_French_Done
    StrCpy $R3 "done"
    ZipDLL::extractall "/TRANSLATE" \
                       "Décompression du fichier %s depuis %s vers %s" \
                       "Erreur : Le fichier spécifié n'existe pas dans l'archive" \
                       "Le fichier spécifié n'existe pas dans l'archive" \
                       "  Erreur : Impossible de décompresser %s." \
                       "Impossible de décompresser %s." \
                       "Erreur : Impossible de récupérer les informations sur le fichier." \
                       "Impossible de récupérer les informations sur le fichier." \
                       "  Erreur : %s" \
                       "$R1" "$R2"
    goto ZipDLL_Done
   ZipDLL_French_Done:
  !endif

  StrCmp $R4 "" 0 ZipDLL_File_Done
  ZipDLL::extractfile "$R1" "$R2" "$3"

 ZipDLL_File_Done:
  
  Pop $R2
  Pop $R1
  Pop $R4
  Pop $R3
  Exch $R2

functionend

!macro MUI_ZIPDLL_EXTRACTFILE SOURCE DESTINATION FILE

  Push "${SOURCE}"
  Push "${DESTINATION}"
  Push "${FILE}"
  call ZipDLL_ExtractFileFunc

!macroend

!macro MUI_ZIPDLL_EXTRACTALL SOURCE DESTINATION

  Push "${SOURCE}"
  Push "${DESTINATION}"
  call ZipDLL_ExtractAllFunc

!macroend

!endif