EN RU
Log in
Home
Download
Purchase
Documentation
Support
Contact us
 
Help  /  FAQ

How to specify a filter for installation files

For example, you need to install only some files , depending on user's settings. You can use the If Condition parameter in the Installation Files command, but what should you do if there are many files and conditions. Inserting many Installation Files commands is not a good technique . In this case, the CreateInstall installer allows you to set an unpacking filter for installation files. This function is called for each file before the file is decompressed. If the function returns 1 then the file will be installed. If the function returns 0 then the file will be skipped.

Step 1

Insert the Xfilter variable into the Additional Settings list of Installation Files command. Specify your function name as the value of the variable. Notice, its name must be end with cmdproc!

Xfilter => myfiltercmdproc

Step 2

Insert the Source Code command at the beginning of the installation script. Check the 'External source code' checkbox there. Also, you can use the existing Source code command if it exists in your script. Append the pattern of your function there.
func uint myfiltercmdproc( geafile gf  )
{
   return 1
}
In this case, our filter function does nothing and allows all files to be unpacked. Look at the fields of the geafile structure. It contains information about the installing file.
type geafile
{
   filetime  ft              // File time
   uint      size            // File size
   uint      attrib        // File attribute
   uint      hiver         // Hi version
   uint      lowver      // Low version
   str       name          // Name of the file
   str       subfolder  // Name of the subfolder
}

Step 3

Now, you can specify a filter for your installation. For example, let's develop a function, which doesn't allow the unpacking of .jpg files if the variable nojpg equals 1.
func uint myfiltercmdproc( geafile gf  )
{
   if macrox_getint( "nojpg" )
   {
      str ext = gf.name.fgetext()
      ext.lower()
      if ext == "jpg" : return 0
   }
   return 1
}
You can change the filename name and the target subfolder subfolder in the gf variable.

See also

  • Decompress Files
  • Installation Files
Eonza automation software - free, open source cross-platform program for easy creation and management of scripts.
  • Help
    • Introduction
    • Get to know CreateInstall
    • Compare installers
    • License Agreement
    • License Light
    • License Free
    • Program features
    • Command Reference
    • FAQ
      • Antivirus false positives
      • Command Prompt Mode
      • How to create shortcuts
      • How to get Control ID
      • How to sign an installation
      • How to use environment variables
      • Installing 64-bit applications
      • Local variables
      • Portable version
      • Unpacking filter
      • Common dialog parameters
      • Custom dialog function
      • Global variables
      • How to move and resize controls
      • How to use If Condition
      • Language-dependent variables
      • Multi build setups
      • Predefined folders
      • Predefined variables
      • Variables of dialogs
    • Examples & tips
    • CreateInstall Assistant
    • Problem solving
    • Setup Extractor
Copyright © Novostrim, OOO, 2009-2026 All rights reserved.