Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / mann / file.n
CommitLineData
920dae64
AT
1'\"
2'\" Copyright (c) 1993 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: file.n,v 1.23.2.2 2004/10/27 14:23:56 dkf Exp $
9'\"
10'\" The definitions below are for supplemental macros used in Tcl/Tk
11'\" manual entries.
12'\"
13'\" .AP type name in/out ?indent?
14'\" Start paragraph describing an argument to a library procedure.
15'\" type is type of argument (int, etc.), in/out is either "in", "out",
16'\" or "in/out" to describe whether procedure reads or modifies arg,
17'\" and indent is equivalent to second arg of .IP (shouldn't ever be
18'\" needed; use .AS below instead)
19'\"
20'\" .AS ?type? ?name?
21'\" Give maximum sizes of arguments for setting tab stops. Type and
22'\" name are examples of largest possible arguments that will be passed
23'\" to .AP later. If args are omitted, default tab stops are used.
24'\"
25'\" .BS
26'\" Start box enclosure. From here until next .BE, everything will be
27'\" enclosed in one large box.
28'\"
29'\" .BE
30'\" End of box enclosure.
31'\"
32'\" .CS
33'\" Begin code excerpt.
34'\"
35'\" .CE
36'\" End code excerpt.
37'\"
38'\" .VS ?version? ?br?
39'\" Begin vertical sidebar, for use in marking newly-changed parts
40'\" of man pages. The first argument is ignored and used for recording
41'\" the version when the .VS was added, so that the sidebars can be
42'\" found and removed when they reach a certain age. If another argument
43'\" is present, then a line break is forced before starting the sidebar.
44'\"
45'\" .VE
46'\" End of vertical sidebar.
47'\"
48'\" .DS
49'\" Begin an indented unfilled display.
50'\"
51'\" .DE
52'\" End of indented unfilled display.
53'\"
54'\" .SO
55'\" Start of list of standard options for a Tk widget. The
56'\" options follow on successive lines, in four columns separated
57'\" by tabs.
58'\"
59'\" .SE
60'\" End of list of standard options for a Tk widget.
61'\"
62'\" .OP cmdName dbName dbClass
63'\" Start of description of a specific option. cmdName gives the
64'\" option's name as specified in the class command, dbName gives
65'\" the option's name in the option database, and dbClass gives
66'\" the option's class in the option database.
67'\"
68'\" .UL arg1 arg2
69'\" Print arg1 underlined, then print arg2 normally.
70'\"
71'\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
72'\"
73'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74.if t .wh -1.3i ^B
75.nr ^l \n(.l
76.ad b
77'\" # Start an argument description
78.de AP
79.ie !"\\$4"" .TP \\$4
80.el \{\
81. ie !"\\$2"" .TP \\n()Cu
82. el .TP 15
83.\}
84.ta \\n()Au \\n()Bu
85.ie !"\\$3"" \{\
86\&\\$1 \\fI\\$2\\fP (\\$3)
87.\".b
88.\}
89.el \{\
90.br
91.ie !"\\$2"" \{\
92\&\\$1 \\fI\\$2\\fP
93.\}
94.el \{\
95\&\\fI\\$1\\fP
96.\}
97.\}
98..
99'\" # define tabbing values for .AP
100.de AS
101.nr )A 10n
102.if !"\\$1"" .nr )A \\w'\\$1'u+3n
103.nr )B \\n()Au+15n
104.\"
105.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106.nr )C \\n()Bu+\\w'(in/out)'u+2n
107..
108.AS Tcl_Interp Tcl_CreateInterp in/out
109'\" # BS - start boxed text
110'\" # ^y = starting y location
111'\" # ^b = 1
112.de BS
113.br
114.mk ^y
115.nr ^b 1u
116.if n .nf
117.if n .ti 0
118.if n \l'\\n(.lu\(ul'
119.if n .fi
120..
121'\" # BE - end boxed text (draw box now)
122.de BE
123.nf
124.ti 0
125.mk ^t
126.ie n \l'\\n(^lu\(ul'
127.el \{\
128.\" Draw four-sided box normally, but don't draw top of
129.\" box if the box started on an earlier page.
130.ie !\\n(^b-1 \{\
131\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132.\}
133.el \}\
134\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135.\}
136.\}
137.fi
138.br
139.nr ^b 0
140..
141'\" # VS - start vertical sidebar
142'\" # ^Y = starting y location
143'\" # ^v = 1 (for troff; for nroff this doesn't matter)
144.de VS
145.if !"\\$2"" .br
146.mk ^Y
147.ie n 'mc \s12\(br\s0
148.el .nr ^v 1u
149..
150'\" # VE - end of vertical sidebar
151.de VE
152.ie n 'mc
153.el \{\
154.ev 2
155.nf
156.ti 0
157.mk ^t
158\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159.sp -1
160.fi
161.ev
162.\}
163.nr ^v 0
164..
165'\" # Special macro to handle page bottom: finish off current
166'\" # box/sidebar if in box/sidebar mode, then invoked standard
167'\" # page bottom macro.
168.de ^B
169.ev 2
170'ti 0
171'nf
172.mk ^t
173.if \\n(^b \{\
174.\" Draw three-sided box if this is the box's first page,
175.\" draw two sides but no top otherwise.
176.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178.\}
179.if \\n(^v \{\
180.nr ^x \\n(^tu+1v-\\n(^Yu
181\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182.\}
183.bp
184'fi
185.ev
186.if \\n(^b \{\
187.mk ^y
188.nr ^b 2
189.\}
190.if \\n(^v \{\
191.mk ^Y
192.\}
193..
194'\" # DS - begin display
195.de DS
196.RS
197.nf
198.sp
199..
200'\" # DE - end display
201.de DE
202.fi
203.RE
204.sp
205..
206'\" # SO - start of list of standard options
207.de SO
208.SH "STANDARD OPTIONS"
209.LP
210.nf
211.ta 5.5c 11c
212.ft B
213..
214'\" # SE - end of list of standard options
215.de SE
216.fi
217.ft R
218.LP
219See the \\fBoptions\\fR manual entry for details on the standard options.
220..
221'\" # OP - start of full description for a single option
222.de OP
223.LP
224.nf
225.ta 4c
226Command-Line Name: \\fB\\$1\\fR
227Database Name: \\fB\\$2\\fR
228Database Class: \\fB\\$3\\fR
229.fi
230.IP
231..
232'\" # CS - begin code excerpt
233.de CS
234.RS
235.nf
236.ta .25i .5i .75i 1i
237..
238'\" # CE - end code excerpt
239.de CE
240.fi
241.RE
242..
243.de UL
244\\$1\l'|0\(ul'\\$2
245..
246.TH file n 8.3 Tcl "Tcl Built-In Commands"
247.BS
248'\" Note: do not modify the .SH NAME line immediately below!
249.SH NAME
250file \- Manipulate file names and attributes
251.SH SYNOPSIS
252\fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR?
253.BE
254
255.SH DESCRIPTION
256.PP
257This command provides several operations on a file's name or attributes.
258\fIName\fR is the name of a file; if it starts with a tilde, then tilde
259substitution is done before executing the command (see the manual entry for
260\fBfilename\fR for details). \fIOption\fR indicates what to do with the
261file name. Any unique abbreviation for \fIoption\fR is acceptable. The
262valid options are:
263.TP
264\fBfile atime \fIname\fR ?\fBtime\fR?
265.
266Returns a decimal string giving the time at which file \fIname\fR was last
267accessed. If \fItime\fR is specified, it is an access time to set
268for the file. The time is measured in the standard POSIX fashion as
269seconds from a fixed starting time (often January 1, 1970). If the file
270doesn't exist or its access time cannot be queried or set then an error is
271generated. On Windows, FAT file systems do not support access time.
272.TP
273\fBfile attributes \fIname\fR
274.TP
275\fBfile attributes \fIname\fR ?\fBoption\fR?
276.TP
277\fBfile attributes \fIname\fR ?\fBoption value option value...\fR?
278.RS
279This subcommand returns or sets platform specific values associated
280with a file. The first form returns a list of the platform specific
281flags and their values. The second form returns the value for the
282specific option. The third form sets one or more of the values. The
283values are as follows:
284.PP
285On Unix, \fB-group\fR gets or sets the group name for the file. A group id
286can be given to the command, but it returns a group name. \fB-owner\fR gets
287or sets the user name of the owner of the file. The command returns the
288owner name, but the numerical id can be passed when setting the
289owner. \fB-permissions\fR sets or retrieves the octal code that chmod(1)
290uses. This command does also has limited support for setting using the
291symbolic attributes for chmod(1), of the form [ugo]?[[+\-=][rwxst],[...]],
292where multiple symbolic attributes can be separated by commas (example:
293\fBu+s,go\-rw\fR add sticky bit for user, remove read and write
294permissions for group and other). A simplified \fBls\fR style string,
295of the form rwxrwxrwx (must be 9 characters), is also supported
296(example: \fBrwxr\-xr\-t\fR is equivalent to 01755).
297.PP
298On Windows, \fB-archive\fR gives the value or sets or clears the
299archive attribute of the file. \fB-hidden\fR gives the value or sets
300or clears the hidden attribute of the file. \fB-longname\fR will
301expand each path element to its long version. This attribute cannot be
302set. \fB-readonly\fR gives the value or sets or clears the readonly
303attribute of the file. \fB-shortname\fR gives a string where every
304path element is replaced with its short (8.3) version of the
305name. This attribute cannot be set. \fB-system\fR gives or sets or
306clears the value of the system attribute of the file.
307.PP
308On Macintosh, \fB-creator\fR gives or sets the Finder creator type of
309the file. \fB-hidden\fR gives or sets or clears the hidden attribute
310of the file. \fB-readonly\fR gives or sets or clears the readonly
311attribute of the file. Note that directories can only be locked if
312File Sharing is turned on. \fB-type\fR gives or sets the Finder file
313type for the file.
314.RE
315.VS
316.TP
317\fBfile channels ?\fIpattern\fR?
318.
319If \fIpattern\fR isn't specified, returns a list of names of all
320registered open channels in this interpreter. If \fIpattern\fR is
321specified, only those names matching \fIpattern\fR are returned. Matching
322is determined using the same rules as for \fBstring match\fR.
323.VE
324.TP
325\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR
326.TP
327\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR
328.RS
329The first form makes a copy of the file or directory \fIsource\fR under
330the pathname \fItarget\fR. If \fItarget\fR is an existing directory,
331then the second form is used. The second form makes a copy inside
332\fItargetDir\fR of each \fIsource\fR file listed. If a directory is
333specified as a \fIsource\fR, then the contents of the directory will be
334recursively copied into \fItargetDir\fR. Existing files will not be
335overwritten unless the \fB\-force\fR option is specified. When copying
336within a single filesystem, \fIfile copy\fR will copy soft links (i.e.
337the links themselves are copied, not the things they point to). Trying
338to overwrite a non-empty directory, overwrite a directory with a file,
339or overwrite a file with a directory will all result in errors even if
340\fI\-force\fR was specified. Arguments are processed in the order
341specified, halting at the first error, if any. A \fB\-\|\-\fR marks
342the end of switches; the argument following the \fB\-\|\-\fR will be
343treated as a \fIsource\fR even if it starts with a \fB\-\fR.
344.RE
345.TP
346\fBfile delete \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIpathname\fR ?\fIpathname\fR ... ?
347.
348Removes the file or directory specified by each \fIpathname\fR
349argument. Non-empty directories will be removed only if the
350\fB\-force\fR option is specified. When operating on symbolic links,
351the links themselves will be deleted, not the objects they point to.
352Trying to delete a non-existent file is not considered an error.
353Trying to delete a read-only file will cause the file to be deleted,
354even if the \fB\-force\fR flags is not specified. If the \fB\-force\fR
355option is specified on a directory, Tcl will attempt both to change
356permissions and move the current directory 'pwd' out of the given path
357if that is necessary to allow the deletion to proceed. Arguments are
358processed in the order specified, halting at the first error, if any.
359A \fB\-\|\-\fR marks the end of switches; the argument following the
360\fB\-\|\-\fR will be treated as a \fIpathname\fR even if it starts with
361a \fB\-\fR.
362.TP
363\fBfile dirname \fIname\fR
364Returns a name comprised of all of the path components in \fIname\fR
365excluding the last element. If \fIname\fR is a relative file name and
366only contains one path element, then returns ``\fB.\fR'' (or ``\fB:\fR''
367on the Macintosh). If \fIname\fR refers to a root directory, then the
368root directory is returned. For example,
369.RS
370.CS
371\fBfile dirname c:/\fR
372.CE
373returns \fBc:/\fR.
374.PP
375Note that tilde substitution will only be
376performed if it is necessary to complete the command. For example,
377.CS
378\fBfile dirname ~/src/foo.c\fR
379.CE
380returns \fB~/src\fR, whereas
381.CS
382\fBfile dirname ~\fR
383.CE
384returns \fB/home\fR (or something similar).
385.RE
386.TP
387\fBfile executable \fIname\fR
388.
389Returns \fB1\fR if file \fIname\fR is executable by the current user,
390\fB0\fR otherwise.
391.TP
392\fBfile exists \fIname\fR
393.
394Returns \fB1\fR if file \fIname\fR exists and the current user has
395search privileges for the directories leading to it, \fB0\fR otherwise.
396.TP
397\fBfile extension \fIname\fR
398.
399Returns all of the characters in \fIname\fR after and including the last
400dot in the last element of \fIname\fR. If there is no dot in the last
401element of \fIname\fR then returns the empty string.
402.TP
403\fBfile isdirectory \fIname\fR
404.
405Returns \fB1\fR if file \fIname\fR is a directory, \fB0\fR otherwise.
406.TP
407\fBfile isfile \fIname\fR
408.
409Returns \fB1\fR if file \fIname\fR is a regular file, \fB0\fR otherwise.
410.TP
411\fBfile join \fIname\fR ?\fIname ...\fR?
412.
413Takes one or more file names and combines them, using the correct path
414separator for the current platform. If a particular \fIname\fR is
415relative, then it will be joined to the previous file name argument.
416Otherwise, any earlier arguments will be discarded, and joining will
417proceed from the current argument. For example,
418.RS
419.CS
420\fBfile join a b /foo bar\fR
421.CE
422returns \fB/foo/bar\fR.
423.PP
424Note that any of the names can contain separators, and that the result
425is always canonical for the current platform: \fB/\fR for Unix and
426Windows, and \fB:\fR for Macintosh.
427.RE
428.TP
429\fBfile link ?\fI-linktype\fR? \fIlinkName\fR ?\fItarget\fR?
430.
431If only one argument is given, that argument is assumed to be
432\fIlinkName\fR, and this command returns the value of the link given by
433\fIlinkName\fR (i.e. the name of the file it points to). If
434\fIlinkName\fR isn't a link or its value cannot be read (as, for example,
435seems to be the case with hard links, which look just like ordinary
436files), then an error is returned.
437.
438If 2 arguments are given, then these are assumed to be \fIlinkName\fR
439and \fItarget\fR. If \fIlinkName\fR already exists, or if \fItarget\fR
440doesn't exist, an error will be returned. Otherwise, Tcl creates a new
441link called \fIlinkName\fR which points to the existing filesystem object
442at \fItarget\fR, where the type of the link is platform-specific (on Unix
443a symbolic link will be the default). This is useful for the case where
444the user wishes to create a link in a cross-platform way, and doesn't
445care what type of link is created.
446.
447If the user wishes to make a link of a specific type only, (and signal an
448error if for some reason that is not possible), then the optional
449\fI-linktype\fR argument should be given. Accepted values for
450\fI-linktype\fR are "-symbolic" and "-hard".
451.
452When creating links on filesystems that either do not support any links,
453or do not support the specific type requested, an error message will be
454returned. In particular Windows 95, 98 and ME do not support any links
455at present, but most Unix platforms support both symbolic and hard links
456(the latter for files only), MacOS supports symbolic links and Windows
457NT/2000/XP (on NTFS drives) support symbolic directory links and hard
458file links.
459.TP
460\fBfile lstat \fIname varName\fR
461.
462Same as \fBstat\fR option (see below) except uses the \fIlstat\fR
463kernel call instead of \fIstat\fR. This means that if \fIname\fR
464refers to a symbolic link the information returned in \fIvarName\fR
465is for the link rather than the file it refers to. On systems that
466don't support symbolic links this option behaves exactly the same
467as the \fBstat\fR option.
468.TP
469\fBfile mkdir \fIdir\fR ?\fIdir\fR ...?
470.
471Creates each directory specified. For each pathname \fIdir\fR specified,
472this command will create all non-existing parent directories as
473well as \fIdir\fR itself. If an existing directory is specified, then
474no action is taken and no error is returned. Trying to overwrite an existing
475file with a directory will result in an error. Arguments are processed in
476the order specified, halting at the first error, if any.
477.TP
478\fBfile mtime \fIname\fR ?\fItime\fR?
479.
480Returns a decimal string giving the time at which file \fIname\fR was last
481modified. If \fItime\fR is specified, it is a modification time to set for
482the file (equivalent to Unix \fBtouch\fR). The time is measured in the
483standard POSIX fashion as seconds from a fixed starting time (often January
4841, 1970). If the file doesn't exist or its modified time cannot be queried
485or set then an error is generated.
486.TP
487\fBfile nativename \fIname\fR
488.
489Returns the platform-specific name of the file. This is useful if the
490filename is needed to pass to a platform-specific call, such as exec
491under Windows or AppleScript on the Macintosh.
492.TP
493\fBfile normalize \fIname\fR
494.
495.RS
496Returns a unique normalized path representation for the file-system
497object (file, directory, link, etc), whose string value can be used as a
498unique identifier for it. A normalized path is an absolute path which has
499all '../', './' removed. Also it is one which is in the ``standard''
500format for the native platform. On MacOS, Unix, this means the segments
501leading up to the path must be free of symbolic links/aliases (but the
502very last path component may be a symbolic link), and on Windows it also
503means we want the long form with that form's case-dependence (which
504gives us a unique, case-dependent path). The one exception concerning the
505last link in the path is necessary, because Tcl or the user may wish to
506operate on the actual symbolic link itself (for example 'file delete', 'file
507rename', 'file copy' are defined to operate on symbolic links, not on the
508things that they point to).
509.RE
510.TP
511\fBfile owned \fIname\fR
512.
513Returns \fB1\fR if file \fIname\fR is owned by the current user, \fB0\fR
514otherwise.
515.TP
516\fBfile pathtype \fIname\fR
517.
518Returns one of \fBabsolute\fR, \fBrelative\fR, \fBvolumerelative\fR. If
519\fIname\fR refers to a specific file on a specific volume, the path type
520will be \fBabsolute\fR. If \fIname\fR refers to a file relative to the
521current working directory, then the path type will be \fBrelative\fR. If
522\fIname\fR refers to a file relative to the current working directory on
523a specified volume, or to a specific file on the current working volume, then
524the file type is \fBvolumerelative\fR.
525.TP
526\fBfile readable \fIname\fR
527.
528Returns \fB1\fR if file \fIname\fR is readable by the current user,
529\fB0\fR otherwise.
530.TP
531\fBfile readlink \fIname\fR
532.
533Returns the value of the symbolic link given by \fIname\fR (i.e. the name
534of the file it points to). If \fIname\fR isn't a symbolic link or its
535value cannot be read, then an error is returned. On systems that don't
536support symbolic links this option is undefined.
537.TP
538\fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR
539.TP
540\fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR
541.RS
542The first form takes the file or directory specified by pathname
543\fIsource\fR and renames it to \fItarget\fR, moving the file if the
544pathname \fItarget\fR specifies a name in a different directory. If
545\fItarget\fR is an existing directory, then the second form is used.
546The second form moves each \fIsource\fR file or directory into the
547directory \fItargetDir\fR. Existing files will not be overwritten
548unless the \fB\-force\fR option is specified. When operating inside a
549single filesystem, Tcl will rename symbolic links rather than the
550things that they point to. Trying to overwrite a non-empty directory,
551overwrite a directory with a file, or a file with a directory will all
552result in errors. Arguments are processed in the order specified,
553halting at the first error, if any. A \fB\-\|\-\fR marks the end of
554switches; the argument following the \fB\-\|\-\fR will be treated as a
555\fIsource\fR even if it starts with a \fB\-\fR.
556.RE
557.TP
558\fBfile rootname \fIname\fR
559.
560Returns all of the characters in \fIname\fR up to but not including the
561last ``.'' character in the last component of name. If the last
562component of \fIname\fR doesn't contain a dot, then returns \fIname\fR.
563.TP
564\fBfile separator\fR ?\fIname\fR?
565.
566If no argument is given, returns the character which is used to separate
567path segments for native files on this platform. If a path is given,
568the filesystem responsible for that path is asked to return its
569separator character. If no file system accepts \fIname\fR, an error
570is generated.
571.TP
572\fBfile size \fIname\fR
573.
574Returns a decimal string giving the size of file \fIname\fR in bytes. If
575the file doesn't exist or its size cannot be queried then an error is
576generated.
577.TP
578\fBfile split \fIname\fR
579.
580Returns a list whose elements are the path components in \fIname\fR. The
581first element of the list will have the same path type as \fIname\fR.
582All other elements will be relative. Path separators will be discarded
583unless they are needed ensure that an element is unambiguously relative.
584For example, under Unix
585.RS
586.CS
587file split /foo/~bar/baz
588.CE
589returns \fB/\0\0foo\0\0./~bar\0\0baz\fR to ensure that later commands
590that use the third component do not attempt to perform tilde
591substitution.
592.RE
593.TP
594\fBfile stat \fIname varName\fR
595.
596Invokes the \fBstat\fR kernel call on \fIname\fR, and uses the variable
597given by \fIvarName\fR to hold information returned from the kernel call.
598\fIVarName\fR is treated as an array variable, and the following elements
599of that variable are set: \fBatime\fR, \fBctime\fR, \fBdev\fR, \fBgid\fR,
600\fBino\fR, \fBmode\fR, \fBmtime\fR, \fBnlink\fR, \fBsize\fR, \fBtype\fR,
601\fBuid\fR. Each element except \fBtype\fR is a decimal string with the
602value of the corresponding field from the \fBstat\fR return structure;
603see the manual entry for \fBstat\fR for details on the meanings of the
604values. The \fBtype\fR element gives the type of the file in the same
605form returned by the command \fBfile type\fR. This command returns an
606empty string.
607.TP
608\fBfile system \fIname\fR
609.
610Returns a list of two elements, the first of which is the name of the
611filesystem to use for the file, and the second an arbitrary string
612representing the filesystem-specific nature or type of the location
613within that filesystem. If a filesystem only supports one type of file,
614the second element may be null. For example the native files have a
615first element 'native', and a second element which is a platform-specific
616type name for the file's system (e.g. 'NTFS', 'FAT', etc), or possibly
617the empty string if no further information is available or if this
618is not implemented. A generic virtual file system might return the
619list 'vfs ftp' to represent a file on a remote ftp site mounted as a
620virtual filesystem through an extension called 'vfs'. If the file does
621not belong to any filesystem, an error is generated.
622.TP
623\fBfile tail \fIname\fR
624.
625Returns all of the characters in \fIname\fR after the last directory
626separator. If \fIname\fR contains no separators then returns
627\fIname\fR.
628.TP
629\fBfile type \fIname\fR
630.
631Returns a string giving the type of file \fIname\fR, which will be one of
632\fBfile\fR, \fBdirectory\fR, \fBcharacterSpecial\fR, \fBblockSpecial\fR,
633\fBfifo\fR, \fBlink\fR, or \fBsocket\fR.
634.TP
635\fBfile volumes\fR
636.
637Returns the absolute paths to the volumes mounted on the system, as a
638proper Tcl list. On the Macintosh, this will be a list of the mounted
639drives, both local and network. N.B. if two drives have the same name,
640they will both appear on the volume list, but there is currently no way,
641from Tcl, to access any but the first of these drives. On UNIX, the
642command will always return "/", since all filesystems are locally mounted.
643On Windows, it will return a list of the available local drives
644(e.g. {a:/ c:/}).
645.TP
646\fBfile writable \fIname\fR
647.
648Returns \fB1\fR if file \fIname\fR is writable by the current user,
649\fB0\fR otherwise.
650.SH "PORTABILITY ISSUES"
651.TP
652\fBUnix\fR\0\0\0\0\0\0\0
653.
654These commands always operate using the real user and group identifiers,
655not the effective ones.
656.SH EXAMPLES
657This procedure shows how to search for C files in a given directory
658that have a correspondingly-named object file in the current
659directory:
660.CS
661proc findMatchingCFiles {dir} {
662 set files {}
663 switch $::tcl_platform(platform) {
664 windows {
665 set ext .obj
666 }
667 unix {
668 set ext .o
669 }
670 }
671 foreach file [glob -nocomplain -directory $dir *.c] {
672 set objectFile [\fBfile tail\fR [\fBfile rootname\fR $file]]$ext
673 if {[\fBfile exists\fR $objectFile]} {
674 lappend files $file
675 }
676 }
677 return $files
678}
679.CE
680.PP
681Rename a file and leave a symbolic link pointing from the old location
682to the new place:
683.CS
684set oldName foobar.txt
685set newName foo/bar.txt
686# Make sure that where we're going to move to exists...
687if {![\fBfile isdirectory\fR [\fBfile dirname\fR $newName]]} {
688 \fBfile mkdir\fR [\fBfile dirname\fR $newName]
689}
690\fBfile rename\fR $oldName $newName
691\fBfile link\fR -symbolic $oldName $newName
692.CE
693
694.SH "SEE ALSO"
695filename(n), open(n), close(n), eof(n), gets(n), tell(n), seek(n),
696fblocked(n), flush(n)
697
698.SH KEYWORDS
699attributes, copy files, delete files, directory, file, move files, name, rename files, stat