使用external标志时仅复制{tmp}到DestDir的文件夹的问题排查
问题:Inno Setup使用external标志复制时仅文件夹被复制,PNG文件丢失
近期调整了Inno Setup的文件部署逻辑,将原本的直接压缩包嵌入改为下载后解压,再通过external标志把{tmp}目录下的文件复制到DestDir。但现在出现问题:只有文件夹及子文件夹被成功复制,其中的.png文件完全没被复制,此前该逻辑运行正常。
相关配置及代码如下:
[Files] 段配置
[Files] Source: "{tmp}\pack1\Dead by Daylight\DeadByDaylight\Content\UI\Icons\"; DestDir: "{app}"; Components: pack1; Flags: ignoreversion recursesubdirs createallsubdirs external Source: "{tmp}\pack2\Dead by Daylight\DeadByDaylight\Content\UI\Icons\"; DestDir: "{app}"; Components: pack2; Flags: ignoreversion recursesubdirs createallsubdirs external
[Code] 段实现
[Code] { —————————— Extraction Function ———————————————————————————————————————— } const NO_PROGRESS_BOX = 4; RESPOND_YES_TO_ALL = 16; procedure UnZip(ZipPath, FileName, TargetPath: string); var Shell: Variant; ZipFile: Variant; Item: Variant; TargetFolder: Variant; begin Shell := CreateOleObject('Shell.Application'); ZipFile := Shell.NameSpace(ZipPath); if VarIsClear(ZipFile) then RaiseException(Format('Cannot open ZIP file "%s" or does not exist', [ZipPath])); Item := ZipFile.ParseName(FileName); if VarIsClear(Item) then RaiseException(Format('Cannot find "%s" in "%s" ZIP file', [FileName, ZipPath])); TargetFolder := Shell.NameSpace(TargetPath); if VarIsClear(TargetFolder) then RaiseException(Format('Target path "%s" does not exist', [TargetPath])); TargetFolder.CopyHere(Item, NO_PROGRESS_BOX or RESPOND_YES_TO_ALL); end; { —————————— Download Progress ———————————————————————————————————————— } var DownloadPage: TDownloadWizardPage; function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean; begin if Progress = ProgressMax then Log(Format('Successfully downloaded file to {tmp}: %s', [FileName])); Result := True; end; { —————————— Setup Wizard ———————————————————————————————————————— } procedure InitializeWizard(); begin { Download Page } DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress); //DownloadPage.ShowBaseNameInsteadOfUrl := True; //Not working for some reason? Inno Setup 6.2.2* end; { —————————— Download Handling ———————————————————————————————————————— } function NextButtonClick(CurPageID: Integer): Boolean; var Temp: string; begin if CurPageID = wpReady then begin DownloadPage.Clear; if WizardIsComponentSelected('pack1') then DownloadPage.Add('MyDownloadLink1', 'pack1.zip', ''); if WizardIsComponentSelected('pack2') then DownloadPage.Add('MyDownloadLink2', 'pack2.zip', ''); DownloadPage.Show; try try DownloadPage.Download; Temp := ExpandConstant('{tmp}'); if WizardIsComponentSelected('pack1') then UnZip(Temp+'\pack1.zip', 'pack1', Temp); if WizardIsComponentSelected('pack2') then UnZip(Temp+'\pack2.zip', 'pack2', Temp); Result := True; except if DownloadPage.AbortedByUser then Log('Aborted by user.') else SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK); Result := False; end; finally DownloadPage.Hide; end; end else Result := True; end;
如需其他信息,请告知。
内容的提问来源于stack exchange,提问作者Lilith Helsente
相关产品推荐
相关产品推荐

