最新消息:

Nsisunz是NSIS提取ZIP压缩包文件解压zip文件的插件

nsis 永恒心锁 3534浏览 0评论
/*
Nsisunz是NSIS提取ZIP压缩包文件解压zip文件的插件
Nsisunz允许你解压zip压缩文档,当你使用nsisdl从网上下载一个zip压缩文件的时候,你可以使用此插件将zip压缩文档解压至相应目录.
Nsisunz暂不支持使用密码保护的zip压缩文档,解压指定的压缩文件可以使用/file参数选项.
Nsisunz当使用/text参数的时候%f用于表示文件名,%c表示压缩包大小,%u表示各个文件的压缩大小.
*/
!addplugindir ".Release"
OutFile "nsisunz_test.exe"
Name "NSIS Unzip plug-in test"
Caption "NSIS Unzip plug-in test"
ShowInstDetails show
XPStyle on
CompletedText "Extracted!"
SubCaption 3 " - Extracting files"
SubCaption 4 " - Extracted"
LoadLanguageFile "${NSISDIR}ContribLanguage filesenglish.nlf"
; Installer pages
Page custom onZipPageShow onZipPageLeave " - Select Zip file"
Page instfiles
; Localized strings for use with nsisunz
; The '%f' in the string is replaced with the filename on run-time.
; "%c", "%u", "%p" and "%p" is replaced with compressed size,
; uncompressed size, percent complete (with "%") and byte complete
; respectively.
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %b) [%p]"
Function .onInit
 InitPluginsDir
 File "/oname=$PLUGINSDIRzippage.ini" "zippage.ini"
FunctionEnd
Function onZipPageShow
 ; Turn Text control into a button (HM NIS Edit v2.0b5 does not support "Button" type).
 WriteINIStr "$PLUGINSDIRzippage.ini" "Field 12" "Type" "Button"
 WriteINIStr "$PLUGINSDIRzippage.ini" "Field 12" "Flags" "NOTIFY"
 InstallOptions::dialog "$PLUGINSDIRzippage.ini"
FunctionEnd
Function onZipPageLeave
; $R0 = zip filename $R1 = dest. folder
 ReadINIStr $R0 "$PLUGINSDIRzippage.ini" "Field 4" "State"
 ReadINIStr $R1 "$PLUGINSDIRzippage.ini" "Field 6" "State"
 ; Remove trailing backslash if any
 StrCpy $0 $R1 1 -1
 StrCmp "$0" "" 0 notneeded
 StrCpy $R1 $R1 -1
 notneeded:
 IfFileExists $R0 checkdir
 MessageBox MB_ICONEXCLAMATION|MB_OK 'The file "$R0" does not exist!'
 Abort ;return to page
 checkdir:
 IfFileExists $R1*.* unzip
 MessageBox MB_ICONEXCLAMATION|MB_YESNO 'The folder "$R1" does not exist!$r$nDo you wish to create it?' IDNO skipcreate
 CreateDirectory $R1
 Goto unzip
 skipcreate:
 Abort ;return to page
 unzip:
; Just fall of the end, so the sections can be executed
FunctionEnd
Section -pre
 DetailPrint "ZIP file: $R0"
 DetailPrint "Dest. folder: $R1"
SectionEnd
Section
; Check if the checkbox is checked and if it is, then don't extract paths
 ReadINIStr $R2 "$PLUGINSDIRzippage.ini" "Field 7" "State"
 StrCmp $R2 "1" 0 usepaths
 nsisunz::UnzipToLog /text "$(nsisunz_text)" /noextractpath $R0 $R1
 Goto check
 usepaths:
 nsisunz::UnzipToLog /text "$(nsisunz_text)" $R0 $R1
 check:
; Always check for errors. Everything else than "success" means an error.
 Pop $0
 StrCmp $0 "success" ok
 Abort "$0"
 ok:
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » Nsisunz是NSIS提取ZIP压缩包文件解压zip文件的插件

您必须 登录 才能发表评论!