Replaceable User Files

Revision as of 13:08, 31 July 2008 by Paulb (Talk | contribs)

Construction.png Not Ready for Review: This Page is Under Development!

With the release of EiffelStudio 6.2 came the notion of user files, or user replaceable files. These are configuration files, and the like, the end-user (that's you) can author to override a matching file found in the stock EiffelStudio installation.

User Files

User files and folder can be replaced or augmented to files found under the installation under $ISE_EIFFEL\studio. The following indicate the corresponding user paths to place installation replacement/augment files (X.X indicates the Major.Minor version number of the compiler):

  • Under Windows the default location for Eiffel user files is %APPDATA%\Eiffel X.X User Files\studio
  • Under Unix/Linux the default location is ~/.esXX/studio
  • Under Mac OS X the default location is ~/Eiffel X.X User Files/studio

If any of these location do not suit your needs, the environment variable ISE_APP_DATA to point to the root user files folder. Defining ISE_APP_DATA means user replacement/augmented files will be located under $ISE_APP_DATA/studio.

To replace an install file with a user file simply mirror the directory structure found under $ISE_EIFFEL\studio in the user files folder, as explained above. Create or place a file with the same name in the user files respective folder and it will be utilized instead of the stock installed version. It's that simple!

Information.png Note: If running a workbench version of EiffelStudio remember to place user files under the user file folder with a _wkbench suffix. I.E. Under Linux place user files under ~/.esXX_wkbench/studio instead of ~/.esXX/studio. If the $ISE_APP_DATA environment variable has been defined then the _wkbench suffix is not used because of the explicit use of an overriding environment variable.

User Folders

In some cases, user files can be found in a user folder and will not be used to replace stock installation files but to augment a stock collection of files with a user set. This functionality can be found when working with code templates. Templates work a little differently because the folder under the installation does not have to be mirrored in the user files folder. Instead under the user folder there is a separate templates folder used to contain any and all code templates for tools like the contract tool and the editor.

Limitations

Not all files are currently supported with user files, just a select number of configuration files and template files. For all new developments, user files should be supported if applicable.

For now there is no support for those version of EiffelStudio built using the Unix Layout. Unix layouts distribute files across the system and prevent a clean and reliable means to replicate an EiffelStudio installation, required to detect and utilize user files.

Working with User Files

Most of the well know directories and files for the Eiffel compiler are located in a common class call EIFFEL_ENV, which is part of the environment library found in the EiffelStudio framework folder at $EIFFEL_SRC/framework/environment. There are effective implementations of EIFFEL_ENV; EC_EIFFEL_LAYOUT and ES_EIFFEL_LAYOUT used respectively in the Eiffel compiler and EiffelStudio.

Information.png Note: These classes need a little refactoring because most of the accessor functions live in EIFFEL_ENV instead of the more appropriate effective implementation class. It's just something to be aware of for future changes.

Most classes can access a single per-process instance of EIFFEL_ENV through inheriting EIFFEL_LAYOUT and accessing eiffel_layout or using it as a client. A single instance is used because (a) there are parts of the Eiffel system that have no idea if they are running inside EiffelStudio or as a TTY compiler (b) there are performance overheads of initializing EIFFEL_ENV so it's desirable to create and initialize the object once and once only.

EIFFEL_ENV contains the two necessary functions to map an installation path; user_priority_file_name and user_priority_path for retrieving a user file location and a folder path respectively. These functions take a path and return either an existing user based location or Void if no user specific file or folder was found.

Implementing User File Replacement

Here's an example from EIFFEL_ENV:

compiler_configuration: !FILE_NAME
    -- Platform specific system level resource specification file
  require
    is_valid_environment: is_valid_environment
  once
    create Result.make_from_string (eifinit_path)
    Result.set_file_name ("general")
    Result.add_extension ("cfg")
 
    if is_user_files_supported then
        -- Check user override file.
      if {l_user: like user_priority_file_name} user_priority_file_name (Result, True) then
        Result := l_user
      end
    end
  ensure
    not_result_is_empty: not Result.is_empty
  end

In the example the path to general.cfg is built, which will be the normal default file used. A check is done to ensure the notion of user files is supported and being so, a check to see if there is a user specific version under the user folder. In the event that there is a user general.cfg file then it will be taken over the installed general.cfg. In the example above the first argument represents the string path to map to a specific user file and the second Boolean argument indicates if a user file name should only be returned if the file actually exist.

The use of user_priority_path is exactly the same way, but typically user folders are used to augment the contents of the respective installation folder.