The Copy file Hook
This hook dumps an interceped File Prototype in a local directory
For instance, let us hook a output File Prototype fic of a dummy SystemExec Task, which:
> takes an Integer Prototype nb as input and as output (to render it hookable),
> sets the nb value to a fake value (let say 7)
> passes it as argument to an external C code, which creates a file out.txt and write in this file the value of nb passed as parameter,
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
ofstream outputFile("out.txt");
outputFile << argv[1] << "\n";
outputFile.close();
return 0;
}
> sets the path of the model as resource
> sets the command line
> maps the out.txt file to a File Prototype out (which is then implicitely provided as output of the Task). This way the file as a File Prototype can continue navigating throug the workflow.
> create the dummy Task ccode and add it on the Scene
> select the fic Prototype from the ccode Capsule and enter the text /tmp/out_${nb}.txt. This way the fic File Prototype will be hooked and save in /tmp with a name depending of nb. (${nb} is the value of nb at runtime : in this case it will be evaluated at 7)
> create a Copy file Hook
> map the out Prototype to the path /tmp/out_${nb}.txt. This way the out File Prototype will be hooked and save in /tmp with a name depending of nb. (${nb} is the value of nb at runtime : in this case it will be evaluated at 7)
> add the Task on the Scene, click on the output circle (the right one). Indeed, the Hooks listen on the outputs of a Task and set the Hook previously built.
> press the build Button
> press the play button
![]()
> a file named out_7.txt has been created and saved in /tmp
