From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC

XDCscript - xdc.csd

Get current script directory

Contents

Synopsis

 
var dir = xdc.csd();

Description

When a script file is first loaded, the directory containing the script is the "Current Script Directory" or csd. This is not the same as the current working directory. xdc.csd() returns the current script directory of the script that calls this method if xdc.csd() is run when the script is being loaded. This allows a script to reference (and possibly load) other scripts relative to its location rather than having to rely on the package path.

Return Value

xdc.csd() returns a string that names an absolute path to a directory. This string always ends with a directory separator so that clients can simply append a relative path to this string to obtain an absolute path; there is no need for clients to use a host platform specific directory separator.

Example

A script named foo.xs in the package my.pkg.of.scripts can compute the path to a script named bar.xs in the same directory as foo.xs with the following statement:

 
var barFullPath = xdc.csd() + "/bar.xs";

Note that

  1. it is not possible to simply use "./bar.xs" since this will refer to the bar.xs file in the current working directory of the process running foo.xs rather than the directory containing foo.xs; and
  2. the statement above must appear outside any function definition in foo.xs to ensure that the current script directory corresponds to the directory containing foo.xs.
[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC
Copyright © 2008 The Eclipse Foundation. All Rights Reserved


Views
Personal tools
package reference