► |  | The Racket Reference

1 | Language Model
2 | Syntactic Forms
3 | Datatypes
4 | Structures
5 | Classes and Objects
6 | Units
7 | Contracts
8 | Pattern Matching
9 | Control Flow
10 | Concurrency and Parallelism
11 | Macros
12 | Input and Output
13 | Reflection and Security
14 | Operating System
15 | Memory Management
16 | Unsafe Operations
17 | Running Racket
| Bibliography
| Index

► | 14 | Operating System

14.1 | Paths
14.2 | Filesystem
14.3 | Networking
14.4 | Processes
14.5 | Logging
14.6 | Time
14.7 | Environment and Runtime Information
14.8 | Command-Line Parsing

▼ | 14.1 | Paths

14.1.1 | Manipulating Paths
14.1.2 | More Path Utilities
14.1.3 | Unix and Mac OS X Paths
14.1.4 | Windows Path Conventions

top ← prev up next →

#### 14.1`` Paths

When a Racket procedure takes a filesystem path as an argument, the path can be provided either as a string or as an instance of the path datatype. If a string is provided, it is converted to a path using string->path. A Racket procedure that generates a filesystem path always generates a path value.

By default, paths are created and manipulated for the current platform, but procedures that merely manipulate paths (without using the filesystem) can manipulate paths using conventions for other supported platforms. The bytes->path procedure accepts an optional argument that indicates the platform for the path, either 'unix or 'windows. For other functions, such as build-path or simplify-path, the behavior is sensitive to the kind of path that is supplied. Unless otherwise specified, a procedure that requires a path accepts only paths for the current platform.

Two path values are equal? when they are use the same convention type and when their byte-string representations are equal?. A path string (or byte string) cannot be empty, and it cannot contain a nul character or byte. When an empty string or a string containing nul is provided as a path to any procedure except absolute-path?, relative-path?, or complete-path?, the exn:fail:contract exception is raised.

Most Racket primitives that accept paths first cleanse the path before using it. Procedures that build paths or merely check the form of a path do not cleanse paths, with the exceptions of cleanse-path, expand-user-path, and simplify-path. For more information about path cleansing and other platform-specific details, see Unix and Mac OS X Paths for Unix and Mac OS X paths and Windows Path Conventions for Windows paths.

top ← prev up next →