OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [filename.n] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1995-1996 Sun Microsystems, Inc.
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" RCS: @(#) $Id: filename.n,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
8
'\"
9
.so man.macros
10
.TH filename n 7.5 Tcl "Tcl Built-In Commands"
11
.BS
12
'\" Note:  do not modify the .SH NAME line immediately below!
13
.SH NAME
14
filename \- File name conventions supported by Tcl commands
15
.BE
16
.SH INTRODUCTION
17
.PP
18
All Tcl commands and C procedures that take file names as arguments
19
expect the file names to be in one of three forms, depending on the
20
current platform.  On each platform, Tcl supports file names in the
21
standard forms(s) for that platform.  In addition, on all platforms,
22
Tcl supports a Unix-like syntax intended to provide a convenient way
23
of constructing simple file names.  However, scripts that are intended
24
to be portable should not assume a particular form for file names.
25
Instead, portable scripts must use the \fBfile split\fR and \fBfile
26
join\fR commands to manipulate file names (see the \fBfile\fR manual
27
entry for more details).
28
 
29
.SH PATH TYPES
30
.PP
31
File names are grouped into three general types based on the starting point
32
for the path used to specify the file: absolute, relative, and
33
volume-relative.  Absolute names are completely qualified, giving a path to
34
the file relative to a particular volume and the root directory on that
35
volume.  Relative names are unqualified, giving a path to the file relative
36
to the current working directory.  Volume-relative names are partially
37
qualified, either giving the path relative to the root directory on the
38
current volume, or relative to the current directory of the specified
39
volume.  The \fBfile pathtype\fR command can be used to determine the
40
type of a given path.
41
 
42
.SH PATH SYNTAX
43
.PP
44
The rules for native names depend on the value reported in the Tcl
45
array element \fBtcl_platform(platform)\fR:
46
.TP 10
47
\fBmac\fR
48
On Apple Macintosh systems, Tcl supports two forms of path names.  The
49
normal Mac style names use colons as path separators.  Paths may be
50
relative or absolute, and file names may contain any character other
51
than colon.  A leading colon causes the rest of the path to be
52
interpreted relative to the current directory.  If a path contains a
53
colon that is not at the beginning, then the path is interpreted as an
54
absolute path.  Sequences of two or more colons anywhere in the path
55
are used to construct relative paths where \fB::\fR refers to the
56
parent of the current directory, \fB:::\fR refers to the parent of the
57
parent, and so forth.
58
.RS
59
.PP
60
In addition to Macintosh style names, Tcl also supports a subset of
61
Unix-like names.  If a path contains no colons, then it is interpreted
62
like a Unix path.  Slash is used as the path separator.  The file name
63
\fB\&.\fR refers to the current directory, and \fB\&..\fR refers to the
64
parent of the current directory.  However, some names like \fB/\fR or
65
\fB/..\fR have no mapping, and are interpreted as Macintosh names.  In
66
general, commands that generate file names will return Macintosh style
67
names, but commands that accept file names will take both Macintosh
68
and Unix-style names.
69
.PP
70
The following examples illustrate various forms of path names:
71
.TP 15
72
\fB:\fR
73
Relative path to the current folder.
74
.TP 15
75
\fBMyFile\fR
76
Relative path to a file named \fBMyFile\fR in the current folder.
77
.TP 15
78
\fBMyDisk:MyFile\fR
79
Absolute path to a file named \fBMyFile\fR on the device named \fBMyDisk\fR.
80
.TP 15
81
\fB:MyDir:MyFile\fR
82
Relative path to a file name \fBMyFile\fR in a folder named
83
\fBMyDir\fR in the current folder.
84
.TP 15
85
\fB::MyFile\fR
86
Relative path to a file named \fBMyFile\fR in the folder above the
87
current folder.
88
.TP 15
89
\fB:::MyFile\fR
90
Relative path to a file named \fBMyFile\fR in the folder two levels above the
91
current folder.
92
.TP 15
93
\fB/MyDisk/MyFile\fR
94
Absolute path to a file named \fBMyFile\fR on the device named
95
\fBMyDisk\fR.
96
.TP 15
97
\fB\&../MyFile\fR
98
Relative path to a file named \fBMyFile\fR in the folder above the
99
current folder.
100
.RE
101
.TP
102
\fBunix\fR
103
On Unix platforms, Tcl uses path names where the components are
104
separated by slashes.  Path names may be relative or absolute, and
105
file names may contain any character other than slash.  The file names
106
\fB\&.\fR and \fB\&..\fR are special and refer to the current directory
107
and the parent of the current directory respectively.  Multiple
108
adjacent slash characters are interpreted as a single separator.
109
The following examples illustrate various forms of path names:
110
.RS
111
.TP 15
112
\fB/\fR
113
Absolute path to the root directory.
114
.TP 15
115
\fB/etc/passwd\fR
116
Absolute path to the file named \fBpasswd\fR in the directory
117
\fBetc\fR in the root directory.
118
.TP 15
119
\fB\&.\fR
120
Relative path to the current directory.
121
.TP 15
122
\fBfoo\fR
123
Relative path to the file \fBfoo\fR in the current directory.
124
.TP 15
125
\fBfoo/bar\fR
126
Relative path to the file \fBbar\fR in the directory \fBfoo\fR in the
127
current directory.
128
.TP 15
129
\fB\&../foo\fR
130
Relative path to the file \fBfoo\fR in the directory above the current
131
directory.
132
.RE
133
.TP
134
\fBwindows\fR
135
On Microsoft Windows platforms, Tcl supports both drive-relative and UNC
136
style names.  Both \fB/\fR and \fB\e\fR may be used as directory separators
137
in either type of name.  Drive-relative names consist of an optional drive
138
specifier followed by an absolute or relative path.  UNC paths follow the
139
general form \fB\e\eservername\esharename\epath\efile\fR.  In both forms,
140
the file names \fB.\fR and \fB..\fR are special and refer to the current
141
directory and the parent of the current directory respectively.  The
142
following examples illustrate various forms of path names:
143
.RS
144
.TP 15
145
\fB\&\e\eHost\eshare/file\fR
146
Absolute UNC path to a file called \fBfile\fR in the root directory of
147
the export point \fBshare\fR on the host \fBHost\fR.
148
.TP 15
149
\fBc:foo\fR
150
Volume-relative path to a file \fBfoo\fR in the current directory on drive
151
\fBc\fR.
152
.TP 15
153
\fBc:/foo\fR
154
Absolute path to a file \fBfoo\fR in the root directory of drive
155
\fBc\fR.
156
.TP 15
157
\fBfoo\ebar\fR
158
Relative path to a file \fBbar\fR in the \fBfoo\fR directory in the current
159
directory on the current volume.
160
.TP 15
161
\fB\&\efoo\fR
162
Volume-relative path to a file \fBfoo\fR in the root directory of the current
163
volume.
164
.RE
165
 
166
.SH TILDE SUBSTITUTION
167
.PP
168
In addition to the file name rules described above, Tcl also supports
169
\fIcsh\fR-style tilde substitution.  If a file name starts with a
170
tilde, then the file name will be interpreted as if the first element
171
is replaced with the location of the home directory for the given
172
user.  If the tilde is followed immediately by a separator, then the
173
\fB$HOME\fR environment variable is substituted.  Otherwise the
174
characters between the tilde and the next separator are taken as a
175
user name, which is used to retrieve the user's home directory for
176
substitution.
177
.PP
178
The Macintosh and Windows platforms do not support tilde substitution
179
when a user name follows the tilde.  On these platforms, attempts to
180
use a tilde followed by a user name will generate an error.  File
181
names that have a tilde without a user name will be substituted using
182
the \fB$HOME\fR environment variable, just like for Unix.
183
 
184
.SH PORTABILITY ISSUES
185
.PP
186
Not all file systems are case sensitive, so scripts should avoid code
187
that depends on the case of characters in a file name.  In addition,
188
the character sets allowed on different devices may differ, so scripts
189
should choose file names that do not contain special characters like:
190
\fB<>:"/\e|\fR.  The safest approach is to use names consisting of
191
alphanumeric characters only.  Also Windows 3.1 only supports file
192
names with a root of no more than 8 characters and an extension of no
193
more than 3 characters.
194
 
195
.SH KEYWORDS
196
current directory, absolute file name, relative file name,
197
volume-relative file name, portability

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.