Modify Extract Installer Example | Qt Installer Framework Manual

Qt Installer Framework Manual | Modify Extract Installer Example

# Modify Extract Installer Example

Modify Extract Installer illustrates how to overwrite the `component.createOperationsForArchive()` function to be able to install a component to a modified path.

      <?xml version="1.0" encoding="UTF-8"?>
      <Installer>
          <Name>Modify Extract Installer Example</Name>
          <Version>1.0.0</Version>
          <Title>Modify Extract Installer Example</Title>
          <Publisher>Qt-Project</Publisher>
          <StartMenuDir>Qt IFW Examples</StartMenuDir>
          <TargetDir>@HomeDir@/IfwExamples/modifyextract</TargetDir>
      </Installer>

- The `<Default>` element is set to `true` to preselect the component in the installer.
- The `<Script>` element specifies the file name of the JavaScript file that is loaded to perform operations.

      <?xml version="1.0"?>
      <Package>
          <DisplayName>Modify extract operation</DisplayName>
          <Description>A component that uses a hook to modify the extract operation.</Description>
          <Version>1.0.1</Version>
          <ReleaseDate>2014-12-19</ReleaseDate>
          <Default>true</Default>
          <Script>installscript.js</Script>
      </Package>

## Modifying Target Path

In installscript.js, we overwrite the default `component.createOperationsForArchive()` implementation to be able to register an `Extract` operation with a custom argument:

      Component.prototype.createOperationsForArchive = function(archive)
      {
          component.addOperation("Extract", archive, "@TargetDir@/extractToAnotherPath");
      }

Files:

- modifyextract/config/config.xml
- modifyextract/packages/org.qtproject.ifw.example.modifyextract/data/my_content/test.txt
- modifyextract/packages/org.qtproject.ifw.example.modifyextract/meta/installscript.js
- modifyextract/packages/org.qtproject.ifw.example.modifyextract/meta/package.xml
- modifyextract/modifyextract.pro