Converts the specified absolute file pathname to the relative one against the specified context directory.

Parameters:

pathname

Specifies the pathname to be converted. The allowed name-separator character may be '/' or '\'.

Note: The passed parameter value is expected to be an absolute file pathname. However, there are two special situations:

  1. If this is a relative pathname, it is converted to the absolute pathname against the current system directory
  2. If the parameter value is a URL, the function returns that URL as is.
contextDir
Specifies the pathname of the context directory against which the result relative pathname should be produced.

Note: The passed parameter value is expected to be an absolute pathname. However, if this is a relative pathname, it will be converted to the absolute one against the current system directory.

The allowed name-separator character may be '/' or '\'.

asURL
Specify whether the returned pathname will be converted to URL.

When true, all name-separator character in the result relative pathname will be '/'. If the result is absolute pathname, it will be converted to a local URL.

When false, the name-separator character in the result pathname will be system-dependent.

Note: When this parameter is not specified, its default value is false.

Returns:

The result relative pathname, or absolute pathname (or URL) if conversion was impossible.

Example:

The following call:

makeRelativePath (
  "C:\doc\images\diagram.gif",
  "C:\doc\package1\package2",
  true
)
will return:
"../../images/diagram.gif"