Copying hidden files in Inno Setup

前端 未结 2 907
我寻月下人不归
我寻月下人不归 2020-12-20 02:09

How to use copy hidden external files in Inno Setup? Not to make a file hidden, but to work with hidden files. Because for now: the hidden files are being ignored

An

2条回答
  •  死守一世寂寞
    2020-12-20 02:26

    When you select files in [Files] section entry using a wildcard, Inno Setup installer explicitly skips hidden files.

    You cannot do anything about it.

    See RecurseExternalCopyFiles function in Projects\Install.pas, particularly this part:

    if SourceIsWildcard then begin
      if FindData.dwFileAttributes and FILE_ATTRIBUTE_HIDDEN <> 0 then
        Continue; { <-- Skip hidden files, comment by @MartinPrikryl }
      FileName := FindData.cFileName;
    end
    else
      FileName := SearchWildcard;  { use the case specified in the script }
    

    (This is for external files, as that's what you use. But for compile-time files, it's the same. See BuildFileList in Compile.pas).


    All you can do, is to implement the installation in [Code] script yourself, instead of using the [Files] section.

    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if CurStep = ssInstall then
      begin
        Log('Installing files');
        DirectoryCopy(ExpandConstant('{src}\folder'), ExpandConstant('{app}'));
      end;
    end;
    

    For implementation of DirectoryCopy, see my answer to question Inno Setup: copy folder, subfolders and files recursively in Code section.


    For compile-time files (without external flag), you can generate list of [Files] entries using a preprocessor function FindFirst.

提交回复
热议问题