► |  | The Racket Reference

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

► | 15 | Operating System

15.1 | Paths
15.2 | Filesystem
15.3 | Networking
15.4 | Processes
15.5 | Logging
15.6 | Time
15.7 | Environment Variables
15.8 | Environment and Runtime Information
15.9 | Command-Line Parsing
15.10 | Additional Operating System Functions

▼ | 15.1 | Paths

15.1.1 | Manipulating Paths
15.1.2 | More Path Utilities
15.1.3 | Unix and Mac OS Paths
15.1.4 | Windows Paths

top ← prev up next →

#### 15.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. Beware that some paths may not be representable as strings; see Unix Path Representation and Windows Path Representation for more information. 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 Paths and Windows Paths.

top ← prev up next →