1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Generated from mzscheme.tex by tex2page, v 20050501
(running on MzScheme 352, unix),
(c) Dorai Sitaram,
http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
-->
<head>
<title>
PLT MzScheme: Language Manual
</title>
<link rel="stylesheet" type="text/css" href="mzscheme-Z-S.css" title=default>
<meta name=robots content="noindex,follow">
</head>
<body>
<div id=content>
<div align=right class=navigation><i>[Go to <span><a href="mzscheme.html">first</a>, <a href="mzscheme-Z-H-19.html">previous</a></span><span>, <a href="mzscheme-Z-H-21.html">next</a></span> page<span>; </span><span><a href="mzscheme.html#node_toc_start">contents</a></span><span><span>; </span><a href="mzscheme-Z-H-22.html#node_index_start">index</a></span>]</i></div>
<p></p>
<a name="node_chap_20"></a>
<h1 class=chapter>
<div class=chapterheading><a href="mzscheme.html#node_toc_node_chap_20">Chapter 20</a></div><br>
<a href="mzscheme.html#node_toc_node_chap_20">Windows Path Syntax</a></h1>
<p><a name="node_idx_3702"></a></p>
<p>
<a name="node_idx_3704"></a>
In general, a Windows pathname consists of an optional drive specifier
and a drive-specific path. As noted in section <a href="mzscheme-Z-H-11.html#node_sec_11.3">11.3</a>, a Windows
path can be <strong>absolute</strong> but still relative to the current
drive; such paths start with a forward slash or backslash separator
and are not UNC paths or paths that start
with <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt>.</p>
<p>
A path that starts with a drive specification is <strong>complete</strong>.
Roughly, a drive specification is either a Roman letter followed by a
colon, a UNC path of the
form <tt><strong><tt>\</tt><tt>\</tt><em>machine</em><tt>\</tt><em>volume</em></strong></tt>,
or a <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> form followed by
something other than <tt><strong>REL<tt>\</tt><em>element</em></strong></tt>. (Variants
of <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths are described
further below.)</p>
<p>
MzScheme fails to implement the usual Windows path syntax in one
way. Outside of MzScheme, a pathname <tt><strong>C:rant.txt</strong></tt> can be a
drive-specific relative path. That is, it names a
file <tt><strong>rant.txt</strong></tt> on drive <tt><strong>C:</strong></tt>, but the complete path to the
file is determined by the current working directory for
drive <tt><strong>C:</strong></tt>. MzScheme does not support drive-specific working
directories (only a working directory across all drives, as reflected
by the <code class=scheme>current-directory</code> parameter;
see section <a href="mzscheme-Z-H-7.html#node_sec_7.9.1.1">7.9.1.1</a>). Consequently, MzScheme implicitly
converts a path like <tt><strong>C:rant.txt</strong></tt>
into <tt><strong>C:<tt>\</tt>rant.txt</strong></tt>. More generally,
</p>
<ul><p>
</p>
<li><p><em>MzScheme-specific:</em> Whenever a path starts with a drive
specifier <tt><strong><em>letter</em>:</strong></tt> that is not followed by a
forward slash or backslash, a backslash is inserted as the path
is expanded.</p>
<p>
</p>
</ul><p>
Otherwise, MzScheme follows standard Windows path conventions, and
MzScheme adds a <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL</strong></tt>
convention plus conventions to deal with excessive backslashes in
<tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths. In the
following, <tt><strong><em>letter</em></strong></tt> stands for a Roman letter (case does
not matter), <tt><strong><em>machine</em></strong></tt> stands for any sequence of
characters that does not include backslashes or forward slashes and
is not <tt><strong>?</strong></tt>, <tt><strong><em>volume</em></strong></tt> stands for any sequence of
characters that does not include backslashes or forward slashes,
and <tt><strong><em>element</em></strong></tt> stands for any sequence of characters that
does not include backslashes.
</p>
<ul><p>
</p>
<li><p>Trailing spaces and periods in a path element are ignored when
the element is the last one in the path, unless the path starts
with <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> or the
element consists of only spaces and periods.</p>
<p>
</p>
<li><p>The following special ``files'', which access devices, exist in
all directories, case-insensitively, and with all possible
endings after a period or colon, except in pathnames that start
with <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt>: <tt><strong>NUL</strong></tt><a name="node_idx_3706"></a>,
<tt><strong>CON</strong></tt><a name="node_idx_3708"></a>, <tt><strong>PRN</strong></tt><a name="node_idx_3710"></a>, <tt><strong>AUX</strong></tt><a name="node_idx_3712"></a>,
<tt><strong>COM1</strong></tt><a name="node_idx_3714"></a>, <tt><strong>COM2</strong></tt><a name="node_idx_3716"></a>, <tt><strong>COM3</strong></tt><a name="node_idx_3718"></a>,
<tt><strong>COM4</strong></tt><a name="node_idx_3720"></a>, <tt><strong>COM5</strong></tt><a name="node_idx_3722"></a>,
<tt><strong>COM6</strong></tt><a name="node_idx_3724"></a>, <tt><strong>COM7</strong></tt><a name="node_idx_3726"></a>,
<tt><strong>COM8</strong></tt><a name="node_idx_3728"></a>, <tt><strong>COM9</strong></tt><a name="node_idx_3730"></a>, <tt><strong>LPT1</strong></tt><a name="node_idx_3732"></a>,
<tt><strong>LPT2</strong></tt><a name="node_idx_3734"></a>, <tt><strong>LPT3</strong></tt><a name="node_idx_3736"></a>, <tt><strong>LPT4</strong></tt><a name="node_idx_3738"></a>,
<tt><strong>LPT5</strong></tt><a name="node_idx_3740"></a>, <tt><strong>LPT6</strong></tt><a name="node_idx_3742"></a>,
<tt><strong>LPT7</strong></tt><a name="node_idx_3744"></a>, <tt><strong>LPT8</strong></tt><a name="node_idx_3746"></a>, <tt><strong>LPT9</strong></tt><a name="node_idx_3748"></a>.</p>
<p>
</p>
<li><p>Except for <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths,
forward slashes are equivalent to backslashes. Except
for <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths and the
start of UNC paths, multiple adjacent slashes and backslashes
count as a single backslash. In a path that
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths,
elements can be separated by either a single or double
backslash.</p>
<p>
</p>
<li><p>A directory can be accessed with or without a trailing
separator. In the case of a
non-<tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> path, the
trailing separator can be any number of forward slashes and
backslashes; in the case of
a <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> path, a trailing
separator must be a single backslash, except that two
backslashes can
follow <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>letter</em>:</strong></tt>.</p>
<p>
</p>
<li><p>Except for <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths,
a single period (<tt><strong>.</strong></tt>) as a path element means ``the
current directory'', and a double period (<tt><strong>..</strong></tt>) as a path
element means ``the parent directory.'' Up-directory path
elements (i.e., <tt><strong>..</strong></tt>) immediately after a drive are
ignored.</p>
<p>
</p>
<li><p>A pathname that
starts <tt><strong><tt>\</tt><tt>\</tt><em>machine</em><tt>\</tt><em>volume</em></strong></tt>
(where a forward slash can replace any backslash) is a UNC
path, and the
starting <tt><strong><tt>\</tt><tt>\</tt><em>machine</em><tt>\</tt><em>volume</em></strong></tt>
counts as the drive specifier.</p>
<p>
</p>
<li><p>Normally, a path element cannot contain any of the following
characters:</p>
<p>
<tt></p>
<p>
< > : " / <tt>\</tt> |
</p>
<p></tt></p>
<p>
Except for backslash, path elements containing these characters
can be accessed using
a <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> path (assuming
that the underlying filesystem allows the characters).</p>
<p>
</p>
<li><p>In a pathname that
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>letter</em>:<tt>\</tt></strong></tt>,
the
<tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>letter</em>:<tt>\</tt></strong></tt>
prefix counts as the path's drive, as long as the path does
not both contain non-drive elements and end with two
consecutive backslashes, and as long as the path contains no
sequence of three or more backslashes. Forward slashes cannot
be used in place of backslashes (but forward slashes can be
used in element names, though the result generally does not
name an actual directory or file).</p>
<p>
</p>
<li><p>In a pathname that
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>UNC<tt>\</tt><em>machine</em><tt>\</tt><em>volume</em></strong></tt>,
the
<tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>UNC<tt>\</tt><em>machine</em><tt>\</tt><em>volume</em></strong></tt>
prefix counts as the path's drive, as long as the path does
not end with two consecutive backslashes, and as long as the
path contains no sequence of three or more backslashes. Two
backslashes can appear in place of the backslash
after <tt><strong>UNC</strong></tt> and/or the backslash
after <tt><strong><em>machine</em></strong></tt>. The <tt><strong>UNC</strong></tt> part must be
exactly the three uppercase letters, and forward slashes
cannot be used in place of backslashes (but forward slashes
can be used in element names).</p>
<p>
</p>
<li><p><em>MzScheme-specific:</em> A pathname that
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL<tt>\</tt><em>element</em></strong></tt>
or <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL<tt>\</tt><tt>\</tt><em>element</em></strong></tt>
is a relative path, as long as the path does not end with two
consecutive backslashes, and as long as the path contains no
sequence of three or more backslashes. This MzScheme-specific
path form supports relative paths with elements that are not
normally expressible in Windows paths (e.g., a final element
that ends in a space). The <tt><strong>REL</strong></tt> part must be exactly the
three uppercase letters, and forward slashes cannot be used in
place of backslashes. If the path
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL<tt>\</tt>..</strong></tt>
then for as long as the path continues with reptitions
of <tt><strong><tt>\</tt>..</strong></tt>, each element counts as an
up-directory element; a single backslash must be used to
seperate the up-directory elements. As soon as a second
backslash is used to separate the elements, or as soon as a
non-<tt><strong>..</strong></tt> element is encountered, the remaining elements
are all literals (never up-directory elements). When
a <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL</strong></tt> path value
is converted to a string (or when the path value is written or
displayed), the string does not contain the
starting <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL</strong></tt> or
the immediately following backslashes; converting a path value
to a byte string preserves
the <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL</strong></tt> prefix.</p>
<p>
</p>
</ul><p>
Three additional MzScheme-specific rules provide meanings to
character sequences that are otherwise ill-formed as Windows paths:
</p>
<ul><p>
</p>
<li><p><em>MzScheme-specific:</em> In a pathname of the
form <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>any</em><tt>\</tt><tt>\</tt></strong></tt>
where <tt><strong><em>any</em></strong></tt> is any sequence of characters that
does not start <tt><strong><em>letter</em>:</strong></tt>, the entire path counts
as the path's (non-existent) drive.</p>
<p>
</p>
<li><p><em>MzScheme-specific:</em> In a pathname of the
form <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>any</em><tt>\</tt><tt>\</tt><tt>\</tt><em>elements</em></strong></tt>,
where <tt><strong><em>any</em></strong></tt> is any sequence of characters that
does not start <tt><strong><em>letter</em>:</strong></tt>
and <tt><strong><em>elements</em></strong></tt> is any sequence that does not start
with a backslash, does not end with two backslashes, and does
not contain a sequence of three backslashes,
the <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt><em>any</em><tt>\</tt><tt>\</tt><tt>\</tt></strong></tt>
part counts as the path's (non-existent) drive.</p>
<p>
</p>
<li><p><em>MzScheme-specific:</em> In a pathname that
starts <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> and does
not match either of the patterns from the preceding five
bullets, <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> counts
as the path's (non-existent) drive.</p>
<p>
</p>
</ul><p>
Outside of MzScheme, except
for <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths, pathnames are
typically limited to 259 characters. MzScheme internally converts
pathnames to <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> form as
needed to avoid this limit. The operating system cannot access files
through <tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt></strong></tt> paths that are
longer than 32,000 characters or so.</p>
<p>
Where the above descriptions says ``character,'' substitute ``byte''
for interpreting byte strings as paths. The encoding of Windows paths
into bytes preserves ASCII characters, and all special characters
mentioned above are ASCII, so all of the rules are the same.</p>
<p>
Beware that the backslash path separator is an escape character in
MzScheme strings. Thus, the path
<tt><strong><tt>\</tt><tt>\</tt>?<tt>\</tt>REL<tt>\</tt>..<tt>\</tt><tt>\</tt>..</strong></tt>
as a string must be written <code class=scheme><span class=selfeval>"\\\\?\\REL\\..\\\\.."</span></code>.</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<div align=right class=navigation><i>[Go to <span><a href="mzscheme.html">first</a>, <a href="mzscheme-Z-H-19.html">previous</a></span><span>, <a href="mzscheme-Z-H-21.html">next</a></span> page<span>; </span><span><a href="mzscheme.html#node_toc_start">contents</a></span><span><span>; </span><a href="mzscheme-Z-H-22.html#node_index_start">index</a></span>]</i></div>
<p></p>
</div>
</body>
</html>
|