Application GPApplication GPSecDomain
When calling load() to execute scripts, then the file name can be given with either an absolute or a relative path. An absolute path starts at the root of the file system, e.g. "C:\" on Windows or "/" on a UNIX like system. It uniquely identifies the file on the host system and requires no additional processing. However, specifying a relative file path allows a more flexible setup of script files and directories, in particular if scripts shall be reused or run on systems with different directory configurations.
The shell maintains 3 different directories
When a relative file name given, then the file is first searched relative to the current working directory. If it can not be found, then the workspace directory and finally the system directory is examined. If it can not be found in either location, then an error is returned.
The system directory (SYS) is determined by the location of the plug-in directory and does not change once the shell is started. The location of the plug-in is selected during the Eclipse installation process (e.g. C:\eclipse\plugins\de.cardcontact.sse4eclipse_3.5.386). It is used to locate common scripts that are distributed together with the plug-in.
The workspace directory (USR) is selected by the user when Eclipse is started. Projects in the workspace are located by the project name (e.g. using load("scripts/gp/explore.js"); will find the explore.js script in the gp directory of the scripts project in the current Eclipse workspace.
Initially the current working directory (CWD) is set to the directory from which the script is started. When calling a script from within another script, the location of the subordinate script is again determined by a search for the file in the current working directory, the workspace directory and the system directory. After the script terminated, the previous current working directory is restored.
Care should be taken when script files have the same name but reside in different directories. File name resolution for a relative file path always starts with the current working directory, which is determined by the location of the script that is containing the load() statement. Therefore a script executed from the system directory has the current working directory set to the system directory and will therefore find files in this location first. Only if the included file can not be found in the current working directory, then the user and system directories are searched in turn. Overwriting a file in the system directory with a file of the same name in the user directory has no effect, if this file is included from a script in the system directory.
If you want to select a specific file, you should use the GPSystem.mapFilename() method to obtain an absolute path for use in the load() statement.
© Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany