OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / doc / filename.n
1 '\"
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 .TH filename n 7.5 Tcl "Tcl Built-In Commands"
8 .so man.macros
9 .BS
10 '\" Note:  do not modify the .SH NAME line immediately below!
11 .SH NAME
12 filename \- File name conventions supported by Tcl commands
13 .BE
14 .SH INTRODUCTION
15 .PP
16 All Tcl commands and C procedures that take file names as arguments
17 expect the file names to be in one of three forms, depending on the
18 current platform.  On each platform, Tcl supports file names in the
19 standard forms(s) for that platform.  In addition, on all platforms,
20 Tcl supports a Unix-like syntax intended to provide a convenient way
21 of constructing simple file names.  However, scripts that are intended
22 to be portable should not assume a particular form for file names.
23 Instead, portable scripts must use the \fBfile split\fR and \fBfile
24 join\fR commands to manipulate file names (see the \fBfile\fR manual
25 entry for more details).
26 .SH "PATH TYPES"
27 .PP
28 File names are grouped into three general types based on the starting point
29 for the path used to specify the file: absolute, relative, and
30 volume-relative.  Absolute names are completely qualified, giving a path to
31 the file relative to a particular volume and the root directory on that
32 volume.  Relative names are unqualified, giving a path to the file relative
33 to the current working directory.  Volume-relative names are partially
34 qualified, either giving the path relative to the root directory on the
35 current volume, or relative to the current directory of the specified
36 volume.  The \fBfile pathtype\fR command can be used to determine the
37 type of a given path.
38 .SH "PATH SYNTAX"
39 .PP
40 The rules for native names depend on the value reported in the Tcl
41 \fBplatform\fR element of the \fBtcl_platform\fR array:
42 .TP 10
43 \fBUnix\fR
44 On Unix and Apple MacOS X platforms, Tcl uses path names where the
45 components are separated by slashes.  Path names may be relative or
46 absolute, and file names may contain any character other than slash.
47 The file names \fB\&.\fR and \fB\&..\fR are special and refer to the
48 current directory and the parent of the current directory respectively.
49 Multiple adjacent slash characters are interpreted as a single
50 separator.  Any number of trailing slash characters at the end of a
51 path are simply ignored, so the paths \fBfoo\fR, \fBfoo/\fR and
52 \fBfoo//\fR are all identical, and in particular \fBfoo/\fR does not
53 necessarily mean a directory is being referred.
54 .RS
55 .PP
56 The following examples illustrate various forms of path
57 names:
58 .TP 15
59 \fB/\fR
60 Absolute path to the root directory.
61 .TP 15
62 \fB/etc/passwd\fR
63 Absolute path to the file named \fBpasswd\fR in the directory
64 \fBetc\fR in the root directory.
65 .TP 15
66 \fB\&.\fR
67 Relative path to the current directory.
68 .TP 15
69 \fBfoo\fR
70 Relative path to the file \fBfoo\fR in the current directory.
71 .TP 15
72 \fBfoo/bar\fR
73 Relative path to the file \fBbar\fR in the directory \fBfoo\fR in the
74 current directory.
75 .TP 15
76 \fB\&../foo\fR
77 Relative path to the file \fBfoo\fR in the directory above the current
78 directory.
79 .RE
80 .TP
81 \fBWindows\fR
82 On Microsoft Windows platforms, Tcl supports both drive-relative and UNC
83 style names.  Both \fB/\fR and \fB\e\fR may be used as directory separators
84 in either type of name.  Drive-relative names consist of an optional drive
85 specifier followed by an absolute or relative path.  UNC paths follow the
86 general form \fB\e\eservername\esharename\epath\efile\fR, but must at
87 the very least contain the server and share components, i.e.
88 \fB\e\eservername\esharename\fR.  In both forms,
89 the file names \fB.\fR and \fB..\fR are special and refer to the current
90 directory and the parent of the current directory respectively.  The
91 following examples illustrate various forms of path names:
92 .RS
93 .TP 15
94 \fB\&\e\eHost\eshare/file\fR
95 Absolute UNC path to a file called \fBfile\fR in the root directory of
96 the export point \fBshare\fR on the host \fBHost\fR.  Note that
97 repeated use of \fBfile dirname\fR on this path will give
98 \fB//Host/share\fR, and will never give just \fB//Host\fR.
99 .TP 15
100 \fBc:foo\fR
101 Volume-relative path to a file \fBfoo\fR in the current directory on drive
102 \fBc\fR.
103 .TP 15
104 \fBc:/foo\fR
105 Absolute path to a file \fBfoo\fR in the root directory of drive
106 \fBc\fR.
107 .TP 15
108 \fBfoo\ebar\fR
109 Relative path to a file \fBbar\fR in the \fBfoo\fR directory in the current
110 directory on the current volume.
111 .TP 15
112 \fB\&\efoo\fR
113 Volume-relative path to a file \fBfoo\fR in the root directory of the current
114 volume.
115 .TP 15
116 \fB\&\e\efoo\fR
117 Volume-relative path to a file \fBfoo\fR in the root directory of the current
118 volume.  This is not a valid UNC path, so the assumption is that the
119 extra backslashes are superfluous.
120 .RE
121 .SH "TILDE SUBSTITUTION"
122 .PP
123 In addition to the file name rules described above, Tcl also supports
124 \fIcsh\fR-style tilde substitution.  If a file name starts with a tilde,
125 then the file name will be interpreted as if the first element is
126 replaced with the location of the home directory for the given user.  If
127 the tilde is followed immediately by a separator, then the \fB$HOME\fR
128 environment variable is substituted.  Otherwise the characters between
129 the tilde and the next separator are taken as a user name, which is used
130 to retrieve the user's home directory for substitution.  This works on
131 Unix, MacOS X and Windows (except very old releases).
132 .PP
133 Old Windows platforms do not support tilde substitution when a user name
134 follows the tilde.  On these platforms, attempts to use a tilde followed
135 by a user name will generate an error that the user does not exist when
136 Tcl attempts to interpret that part of the path or otherwise access the
137 file.  The behaviour of these paths when not trying to interpret them is
138 the same as on Unix.  File names that have a tilde without a user name
139 will be correctly substituted using the \fB$HOME\fR environment
140 variable, just like for Unix.
141 .SH "PORTABILITY ISSUES"
142 .PP
143 Not all file systems are case sensitive, so scripts should avoid code
144 that depends on the case of characters in a file name.  In addition,
145 the character sets allowed on different devices may differ, so scripts
146 should choose file names that do not contain special characters like:
147 \fB<>:?"/\e|\fR.
148 '\""\" reset emacs highlighting
149 The safest approach is to use names consisting of
150 alphanumeric characters only.  Care should be taken with filenames
151 which contain spaces (common on Windows systems) and
152 filenames where the backslash is the directory separator (Windows
153 native path names).
154 .PP
155 On Windows platforms there are file and path length restrictions.
156 Complete paths or filenames longer than about 260 characters will lead
157 to errors in most file operations.
158 .PP
159 Another Windows peculiarity is that any number of trailing dots
160 .QW .
161 in filenames are totally ignored, so, for example, attempts to create a
162 file or directory with a name
163 .QW foo.
164 will result in the creation of a file/directory with name
165 .QW foo .
166 This fact is reflected in the results of \fBfile normalize\fR.
167 Furthermore, a file name consisting only of dots
168 .QW .........
169 or dots with trailing characters
170 .QW .....abc
171 is illegal.
172 .SH "SEE ALSO"
173 file(n), glob(n)
174 .SH KEYWORDS
175 current directory, absolute file name, relative file name,
176 volume-relative file name, portability