Replaceable User Files

Revision as of 09:53, 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.

Working with User Files

User Directories

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.

Here's an example from EIFFEL_ENV:

compiler_configuration: !FILE_NAME
    -- Platform specific system level resource specification file
    -- ($ISE_EIFFEL/eifinit/application_name/spec/$ISE_PLATFORM)
  require
    is_valid_environment: is_valid_environment
  local
    l_user: like user_priority_file_name
  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.
      l_user := user_priority_file_name (Result)
      if l_user /= Void and then (create {RAW_FILE}.make (l_user)).exists then
        Result ?= l_user
      end
    end
  ensure
    not_result_is_empty: not Result.is_empty
  end