# Directory Paths in J

### Directory Foreigns

`1!:43 y` | Query Current Working Directory
`1!:44 y` | Set Current Working Directory
`1!:45 y` | Query Default Profile

See J Help on `!:` (foreign conjunctions) for further details.

### Folder Tables

The J profile defines the following two folder tables in the `j` locale:

`SYSTEMFOLDERS_j_` is a 2-column table of folder names and paths. This table is required by the system scripts. If you need to modify the paths (second column) in this table, change the profile script used on start up. You should not modify the entries in the first column. For example:

    +-------+-----------------+
    |system |c:\j5\system     |
    +-------+-----------------+
    |profile|c:\j5            |
    +-------+-----------------+
    |home   |c:\j5            |
    +-------+-----------------+
    |temp   |c:\j5\temp       |
    +-------+-----------------+
    |addons |c:\jx\addons     |
    +-------+-----------------+
    |user   |c:\jx\user       |
    +-------+-----------------+
    |config |c:\jx\user\config|
    +-------+-----------------+

Here:

`system` | system directory
`profile` | profile directory (i.e. file `profile.ijs`)
`home` | HOME in UNIX, otherwise same as profile
`temp` | temporary directory
`addons` | addons directory
`user` | user directory
`config` | user configuration directory

`USERFOLDERS_j_` has the same form, and is defined from the user's configuration script, `config.ijs`, and read in by the standard profile. This table is referenced by Find in Files, and Project Manager. You can modify this table as you wish. For example:

    +------+-----------------+
    |LTsrc |c:\lt\source     |
    +------+-----------------+
    |LTrel |c:\lt\release    |
    +------+-----------------+
    |JPB   |d:\jss\jpb\source|
    +------+-----------------+
    |JST   |d:\jst\source    |
    +------+-----------------+
    |JSTdev|d:\jst\dev       |
    +------+-----------------+
    ...

Note that some paths in the default USERFOLDERS table are the same as in the SYSTEMFOLDERS table. This is intentional, nevertheless you are free to remove or modify such entries in USERFOLDERS. To avoid conflicts between the folder names (first column) in the two tables, we suggest that you use an initial capital letter in the folder names of USERFOLDERS, since folder names in SYSTEMFOLDERS are all lowercase.

### Directory Verbs

The profile defines the following verbs in the `z` locale:

`jpath` | converts argument to a full path name
`jcwdpath` | return current working directory
`jhostpath` | convert separators in filename to host operating system

These verbs are used to provide the full pathname for files, and to ensure that the path separator is correct for the host operating system. For example:

       jpath '~system\main\dates.ijs'
    c:\j5\system\main\dates.ijs

       jhostpath 'system\main/dates.ijs'    NB. in Windows
    system\main\dates.ijs

       jcwdpath ''
    c:\j5

       jcwdpath 'system\main'
    C:\j5\system\main

### jpath

Verb `jpath` references the folder tables. It converts strings with folder names preceded with `~`, for example `~mywork`. The folder name is read up to the first path separator (`/\`) or the end, for example:

      jpath '~temp'
    c:\j5\temp

      jpath '~temp\t2.ijs'
    c:\j5\temp\t2.ijs

      jpath '~JPB\classes\board\init.ijs'
    d:\jss\jpb\source\classes\board\init.ijs

Where the folder name is preceded with `~.`, for example `~.mywork`, this refers to the corresponding parent directory, for example:

      jpath '~.JPB\dev\regtest.ijs'
    d:\jss\jpb\dev\regtest.ijs

      jpath '~..JPB\release\pbr.ijs'
    d:\jss\release\pbr.ijs

Verb `jpath` also converts path separators to the current path separator, and so can be used instead of `jhostpath` (which is still supported).
Verbs `load`, `require` and `script` call `jpath`, and so recognize `~path` names, e.g.

      load '~JPB\classes\board\init.ijs'
      require '~user\projects\run\run.ijs'

### Project Manager

Project Manager stores names in `~path` form, when files are added to the project. This means that developers working on the same project can use different directories, as long as they have made appropriate folder definitions.

The conversion process:

- searches for the best fit, i.e. the jpath id that results in the shortest remaining name.
- if no jpath id fits the name, then check for parents of the current lookin folder, as long as they are below the root
- if no parent of the current lookin folder matches, then the full path name is used.

Existing names in a project are not converted. Therefore you can edit the project file to replace any `~path` name with a full filename, and this will be preserved.

Earlier versions of Project Manager stored some names as a relative path name, starting from the J executable directory. Such names are converted to `~path` form.

The Look In combobox in Project Manager displays entries in USERFOLDERS, except those pointing to the J system directory. The reason for the exclusion is that projects should not be developed in the J system directory.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User
>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User