inno-setupinno-setup-v6

Why are only my folders/subfolders being copied from {tmp} to 'DestDir' when using 'external' flag?


I recently switched from compressing my Source: directories in [Files] to downloading/unzipping them, then coping them from {tmp} to my DestDir: using the external flag, but for some reason only the folders and subfolders are copied over, the actual files in them (.png files) aren't being copied with them.

I'm not sure why this is happening, it worked fine like this before the switch.

[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]⠀(very lengthy, sorry)

{ —————————— 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; // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //

Let me know if anything else is needed in the comments.


Solution

  • You are missing wildcards in the Source command (e.g. *).

    The correct script is for example:

    [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
    

    You can use Excludes parameter to exclude some file types.

    See the Inno Setup Help for more details ([Files]):

    This can be a wildcard to specify a group of files in a single entry. When a wildcard is used, all files matching it use the same options.

    P.S. Your example is really bare and does not contain script with extracting files into tmp. Double check whether files are really present.