▼ |  | Unstable

1 | Guidelines for developing unstable libraries
2 | Bytes
3 | Classes and Objects
4 | Contracts
5 | Definitions
6 | Dictionaries
7 | Directories
8 | Exceptions
9 | Filesystem
10 | Functions
11 | Lists
12 | Net
13 | Path
14 | PLane T Packages
15 | Ports
16 | Pretty-Printing
17 | Regular Expressions
18 | Requiring Modules
19 | Sandboxed Evaluation
20 | Scribble Documentation
21 | Sets
22 | S-Expression Diff
23 | Source Locations
24 | Strings
25 | Structs
26 | Syntax
27 | Planet Package Macros
28 | Text Representations
29 | Multiple Values
30 | XML and CSS
31 | Polymorphic Contracts
32 | Finding Mutated Variables
33 | Find
34 | Interface-Oriented Programming for Classes
35 | Sequences
36 | Hash Tables
37 | Match
38 | Generics
39 | Mark Parameters
40 | Debugging
41 | Contracts for macro subexpressions
42 | Contracts for struct type properties
43 | GUI libraries

On this page:

path->directory-relative-string
library-relative-directories
setup-relative-directories

Version: 5.0.2
top ← prev up next →

### 7`` Directories

Carl Eastlund <cce@ccs.neu.edu>

( require unstable/dirs )

This library is unstable; compatibility will not be maintained. See Unstable for more information.

This library defines utilities dealing with the directory paths used by the Racket distribution.

( path->directory-relative-string |  | path |
| [ | #:default default |
|  | #:dirs dirs]) |

→ ( or/c string? ( one-of/c default))
path : path-string?
default : any/c = ( if ( path? path) ( path->string path) path)

| dirs |  | : |  | ( listof ( cons/c ( -> path? ) any/c ))
|  |  | = |  | library-relative-directories

Produces a string rendering of path, replacing distribution-specific paths (normally: collections, user-installed collections, or PLanet cache) with short abbreviations.

The set of paths and their abbreviations may be overridden by the #:dirs option, which accepts an association list. Its keys must be thunks which produce a path. Its values may be either #f for no abbreviation (the directory prefix is simply omitted) or any other value to be displayed in the output. For instance, "document.txt" relative to a path abbreviated "path" would be rendered as "<path>/document.txt".

If the path is not relative to one of the given directories, the default return value is a string rendering of the unmodified path. This default may be overridden by providing default.

Examples:

> ( path->directory-relative-string
( build-path "source" "project.rkt"))

"source/project.rkt"

> ( path->directory-relative-string
( build-path ( current-directory ) "source" "project.rkt"))

"<collects>/unstable/source/project.rkt"

> ( path->directory-relative-string
( build-path "/" "source" "project.rkt"))

"/source/project.rkt"

> ( path->directory-relative-string
( build-path "/" "source" "project.rkt")
#:default #f)

#f

> ( path->directory-relative-string
( build-path "/" "source" "project.rkt")
#:dirs ( list
( cons ( lambda () ( build-path "/" "source"))
'src)))

"<src>/project.rkt"

library-relative-directories : ( listof ( cons ( -> path? ) any/c ))

Represents the default directory substitutions for path->directory-relative-string. By default, the collections directory is replaced by collects, the user-installed collections directory is replaced by user, and the PLaneT cache is replaced by planet.

setup-relative-directories : ( listof ( cons ( -> path? ) any/c ))

Represents the directory substitutions used by setup-plt. The collections directory is omitted, the user-installed collections directory is replaced by user, and the PLaneT cache is replaced by planet.
top ← prev up next →