Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/filename.n @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

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