Managing generated files

 

Overview

Files are managed by a work product.  This allows the easy addition or deletion of a file, according to the changes made to the model.

 

For example, the files managed by a work product can be automatically deleted when the work product is deleted.

 

 

Features

On a generation work product, two methods can be used to manage the generated files.  These are used to add or delete a file managed by the work product.

 

The ... method

is used to ...

mngFile (fileName : in String, contents : in String)

create the "fileName" file with its "contents" and to add it as a manager of the generation work product.

reverseAllFiles()

reverses all files generated by the product and modified by an editor.

 

Note:      If mngFile(…) is called on a file that is already managed, its content is updated if there are any differences.

 

 

Example

JavaProduct:default#external#Code#Java#generate ()

{

String content;

String fileName;

 

   // method used to generate Java code

   content = generateJava ();

 

   fileName.strcat (getAttributeVal("path"),

                    "/",

                    Name,

                    ".",

                    getAttributeVal("suffix"));

 

   // create and manage the generated file

   mngFile (fileName, content);

 

   // update all the open editors

   updateAllEditors ();

}