On this page:
path->main-collects-relative
main-collects-relative->path
Version: 4.1

7 Paths Relative to "collects"

 (require setup/main-collects)

(path->main-collects-relative path)

  (or/c path? (cons/c 'collects (listof bytes?)))

  path : (or bytes? path-string?)

Checks whether path has a prefix that matches the prefix to the main "collects" directory as determined by (find-collects-dir). If so, the result is a list starting with 'collects and containing the remaining path elements as byte strings. If not, the path is returned as-is.

The path argument should be a complete path. Applying simplify-path before path->main-collects-relative is usually a good idea.

For historical reasons, path can be a byte string, which is converted to a path using bytes->path.

(main-collects-relative->path rel)  path?

  

rel

 

:

 

(or/c path?

      (cons/c 'collects

              (or/c (listof bytes?) bytes?)))

The inverse of path->main-collects-relative: if rel is a pair that starts with 'collects, then it is converted back to a path relative to (find-collects-dir).

For historical reasons, a single byte string is allowed in place of a list of byte strings after 'collects, in which case it is assumed to be a relative path after conversion with bytes->path.

Also for historical reasons, if rel is any kind of value other than specified in the contract above, it is returned as-is.