Working With Relative Paths

Relative paths apply to the following PeopleCode operations: the Open method of the File class and the CreateDirectory, FileExists, FindFiles, GetFile, GetTempFile, and RemoveDirectory built-in functions

If you specify a relative path, that path is appended to the path constructed from a system-chosen environment variable. Environment variables are checked in a particular order to find one that is set. This means if the first environment variable in order is found to be set, that's the one that is used. If the environment variable isn't found to be set, the next one is checked, and if found, is used, and so on.

If the PeopleCode operation is called from a program running in an environment started through psadmin (for example, within an application server domain), the PeopleCode operation checks in the following order to determine whether an environment variable is set:

  1. PS_FILEDIR

  2. PS_SERVDIR

If the PeopleCode operation is called from an environment not started through psadmin (for example, a stand-alone call to Application Engine), the PeopleCode operation checks in the following order to determine whether an environment variable is set:

  1. PS_FILEDIR

  2. PS_SERVDIR

  3. TEMP

In both cases, the PeopleCode operation then uses the value of the first environment variable that is found to be set and appends the specified relative path to it in order to determine the resulting full path that will be used to locate the file. The resulting path is shown in the following table:

Environment Variable

Resulting Path

PS_FILEDIR

PS_FILEDIR\relative_path

PS_SERVDIR

PS_SERVDIR\files\relative_path

TEMP

TEMP\relative_path

If the PeopleCode operation is not successful at the specified location, it will return Null or False (as appropriate for the invoking operation) and it will not attempt to use the value of one of the other environment variables.

Note: In the preceding examples, the Windows directory separator, a backslash, was used. For UNIX directories, the directory separator is a forward slash.

Note: The PS_FILEDIR environment variable is not initialized and set to a path automatically. If you want to use this environment variable, you must set it yourself.

Note: Your system security should verify if a user has the correct permissions before allowing access to a drive. (For example, if a user changes their TEMP environment variable to a network drive they don’t normally have access to, your system security should detect this.)