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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [file.n] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
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.1.1.1 2002-01-16 10:25:24 markom Exp $
9
'\"
10
.so man.macros
11
.TH file n 7.6 Tcl "Tcl Built-In Commands"
12
.BS
13
'\" Note:  do not modify the .SH NAME line immediately below!
14
.SH NAME
15
file \- Manipulate file names and attributes
16
.SH SYNOPSIS
17
\fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR?
18
.BE
19
 
20
.SH DESCRIPTION
21
.PP
22
This command provides several operations on a file's name or attributes.
23
\fIName\fR is the name of a file; if it starts with a tilde, then tilde
24
substitution is done before executing the command (see the manual entry for
25
\fBfilename\fR for details).  \fIOption\fR indicates what to do with the
26
file name.  Any unique abbreviation for \fIoption\fR is acceptable.  The
27
valid options are:
28
.TP
29
\fBfile atime \fIname\fR
30
.
31
Returns a decimal string giving the time at which file \fIname\fR
32
was last accessed.  The time is measured in the standard POSIX
33
fashion as seconds from a fixed starting time (often January 1, 1970).
34
If the file doesn't exist or its access time cannot be queried then an
35
error is generated.
36
.VS
37
.TP
38
\fBfile attributes \fIname\fR
39
.br
40
\fBfile attributes \fIname\fR ?\fBoption\fR?
41
.br
42
\fBfile attributes \fIname\fR ?\fBoption value option value...\fR?
43
.RS
44
This subcommand returns or sets platform specific values associated
45
with a file. The first form returns a list of the platform specific
46
flags and their values. The second form returns the value for the
47
specific option. The third form sets one or more of the values. The
48
values are as follows:
49
.PP
50
On Unix, \fB-group\fR gets or sets the group name for the file. A group id can
51
be given to the command, but it returns a group name. \fB-owner\fR
52
gets or sets the user name of the owner of the file. The command
53
returns the owner name, but the numerical id can be passed when
54
setting the owner. \fB-permissions\fR sets or retrieves the octal code
55
that chmod(1) uses. This command does not support the symbolic
56
attributes for chmod(1) at this time.
57
.PP
58
On Windows, \fB-archive\fR gives the value or sets or clears the
59
archive attribute of the file. \fB-hidden\fR gives the value or sets
60
or clears the hidden attribute of the file. \fB-longname\fR will
61
expand each path element to its long version. This attribute cannot be
62
set. \fB-readonly\fR gives the value or sets or clears the readonly
63
attribute of the file. \fB-shortname\fR gives a string where every
64
path element is replaced with its short (8.3) version of the
65
name. This attribute cannot be set. \fB-system\fR gives or sets or
66
clears the value of the system attribute of the file.
67
.PP
68
On Macintosh, \fB-creator\fR gives or sets the Finder creator type of
69
the file. \fB-hidden\fR gives or sets or clears the hidden attribute
70
of the file. \fB-readonly\fR gives or sets or clears the readonly
71
attribute of the file. Note that directories can only be locked if
72
File Sharing is turned on. \fB-type\fR gives or sets the Finder file
73
type for the file.
74
.RE
75
.VE
76
.PP
77
\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR
78
.br
79
\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR
80
.RS
81
The first form makes a copy of the file or directory \fIsource\fR under
82
the pathname \fItarget\fR.  If \fItarget\fR is an existing directory,
83
then the second form is used.  The second form makes a copy inside
84
\fItargetDir\fR of each \fIsource\fR file listed.  If a directory is
85
specified as a \fIsource\fR, then the contents of the directory will be
86
recursively copied into \fItargetDir\fR.  Existing files will not be
87
overwritten unless the \fB\-force\fR option is specified.  Trying to
88
overwrite a non-empty directory, overwrite a directory with a file, or a
89
file with a directory will all result in errors even if \fI\-force\fR was
90
specified.  Arguments are processed in the order specified, halting at the
91
first error, if any.  A \fB\-\|\-\fR marks the end of switches; the argument
92
following the \fB\-\|\-\fR will be treated as a \fIsource\fR even if it
93
starts with a \fB\-\fR.
94
.RE
95
.TP
96
\fBfile delete \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIpathname\fR ?\fIpathname\fR ... ?
97
.
98
Removes the file or directory specified by each \fIpathname\fR argument.
99
Non-empty directories will be removed only if the \fB\-force\fR option is
100
specified.  Trying to delete a non-existant file is not considered an
101
error.  Trying to delete a read-only file will cause the file to be deleted,
102
even if the \fB\-force\fR flags is not specified.  Arguments are processed
103
in the order specified, halting at the first error, if any.  A \fB\-\|\-\fR
104
marks the end of switches; the argument following the \fB\-\|\-\fR will be
105
treated as a \fIpathname\fR even if it starts with a \fB\-\fR.
106
.TP
107
\fBfile dirname \fIname\fR
108
Returns a name comprised of all of the path components in \fIname\fR
109
excluding the last element.  If \fIname\fR is a relative file name and
110
only contains one path element, then returns ``\fB.\fR'' (or ``\fB:\fR''
111
on the Macintosh).  If \fIname\fR refers to a root directory, then the
112
root directory is returned.  For example,
113
.RS
114
.CS
115
\fBfile dirname c:/\fR
116
.CE
117
returns \fBc:/\fR.
118
.PP
119
Note that tilde substitution will only be
120
performed if it is necessary to complete the command. For example,
121
.CS
122
\fBfile dirname ~/src/foo.c\fR
123
.CE
124
returns \fB~/src\fR, whereas
125
.CS
126
\fBfile dirname ~\fR
127
.CE
128
returns \fB/home\fR (or something similar).
129
.RE
130
.TP
131
\fBfile executable \fIname\fR
132
.
133
Returns \fB1\fR if file \fIname\fR is executable by the current user,
134
\fB0\fR otherwise.
135
.TP
136
\fBfile exists \fIname\fR
137
.
138
Returns \fB1\fR if file \fIname\fR exists and the current user has
139
search privileges for the directories leading to it, \fB0\fR otherwise.
140
.TP
141
\fBfile extension \fIname\fR
142
.
143
Returns all of the characters in \fIname\fR after and including the last
144
dot in the last element of \fIname\fR.  If there is no dot in the last
145
element of \fIname\fR then returns the empty string.
146
.TP
147
\fBfile isdirectory \fIname\fR
148
.
149
Returns \fB1\fR if file \fIname\fR is a directory, \fB0\fR otherwise.
150
.TP
151
\fBfile isfile \fIname\fR
152
.
153
Returns \fB1\fR if file \fIname\fR is a regular file, \fB0\fR otherwise.
154
.TP
155
\fBfile join \fIname\fR ?\fIname ...\fR?
156
.
157
Takes one or more file names and combines them, using the correct path
158
separator for the current platform.  If a particular \fIname\fR is
159
relative, then it will be joined to the previous file name argument.
160
Otherwise, any earlier arguments will be discarded, and joining will
161
proceed from the current argument.  For example,
162
.RS
163
.CS
164
\fBfile join a b /foo bar\fR
165
.CE
166
returns \fB/foo/bar\fR.
167
.PP
168
Note that any of the names can contain separators, and that the result
169
is always canonical for the current platform: \fB/\fR for Unix and
170
Windows, and \fB:\fR for Macintosh.
171
.RE
172
.TP
173
\fBfile lstat \fIname varName\fR
174
.
175
Same as \fBstat\fR option (see below) except uses the \fIlstat\fR
176
kernel call instead of \fIstat\fR.  This means that if \fIname\fR
177
refers to a symbolic link the information returned in \fIvarName\fR
178
is for the link rather than the file it refers to.  On systems that
179
don't support symbolic links this option behaves exactly the same
180
as the \fBstat\fR option.
181
.TP
182
\fBfile mkdir \fIdir\fR ?\fIdir\fR ...?
183
.
184
Creates each directory specified.  For each pathname \fIdir\fR specified,
185
this command will create all non-existing parent directories as
186
well as \fIdir\fR itself.  If an existing directory is specified, then
187
no action is taken and no error is returned.  Trying to overwrite an existing
188
file with a directory will result in an error.  Arguments are processed in
189
the order specified, halting at the first error, if any.
190
.TP
191
\fBfile mtime \fIname\fR
192
.
193
Returns a decimal string giving the time at which file \fIname\fR was
194
last modified.  The time is measured in the standard POSIX fashion as
195
seconds from a fixed starting time (often January 1, 1970).  If the file
196
doesn't exist or its modified time cannot be queried then an error is
197
generated.
198
.VS
199
.TP
200
\fBfile nativename \fIname\fR
201
.
202
Returns the platform-specific name of the file. This is useful if the
203
filename is needed to pass to a platform-specific call, such as exec
204
under Windows or AppleScript on the Macintosh.
205
.VE
206
.TP
207
\fBfile owned \fIname\fR
208
.
209
Returns \fB1\fR if file \fIname\fR is owned by the current user, \fB0\fR
210
otherwise.
211
.TP
212
\fBfile pathtype \fIname\fR
213
.
214
Returns one of \fBabsolute\fR, \fBrelative\fR, \fBvolumerelative\fR.  If
215
\fIname\fR refers to a specific file on a specific volume, the path type
216
will be \fBabsolute\fR.  If \fIname\fR refers to a file relative to the
217
current working directory, then the path type will be \fBrelative\fR.  If
218
\fIname\fR refers to a file relative to the current working directory on
219
a specified volume, or to a specific file on the current working volume, then
220
the file type is \fBvolumerelative\fR.
221
.TP
222
\fBfile readable \fIname\fR
223
.
224
Returns \fB1\fR if file \fIname\fR is readable by the current user,
225
\fB0\fR otherwise.
226
.TP
227
\fBfile readlink \fIname\fR
228
.
229
Returns the value of the symbolic link given by \fIname\fR (i.e. the name
230
of the file it points to).  If \fIname\fR isn't a symbolic link or its
231
value cannot be read, then an error is returned.  On systems that don't
232
support symbolic links this option is undefined.
233
.PP
234
\fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR
235
.br
236
\fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR
237
.RS
238
The first form takes the file or directory specified by pathname
239
\fIsource\fR and renames it to \fItarget\fR, moving the file if the
240
pathname \fItarget\fR specifies a name in a different directory.  If
241
\fItarget\fR is an existing directory, then the second form is used.  The
242
second form moves each \fIsource\fR file or directory into the directory
243
\fItargetDir\fR.  Existing files will not be overwritten unless the
244
\fB\-force\fR option is specified.  Trying to overwrite a non-empty
245
directory, overwrite a directory with a file, or a file with a directory
246
will all result in errors.  Arguments are processed in the order specified,
247
halting at the first error, if any.  A \fB\-\|\-\fR marks the end of
248
switches; the argument following the \fB\-\|\-\fR will be treated as a
249
\fIsource\fR even if it starts with a \fB\-\fR.
250
.RE
251
.TP
252
\fBfile rootname \fIname\fR
253
.
254
Returns all of the characters in \fIname\fR up to but not including the
255
last ``.'' character in the last component of name.  If the last
256
component of \fIname\fR doesn't contain a dot, then returns \fIname\fR.
257
.TP
258
\fBfile size \fIname\fR
259
.
260
Returns a decimal string giving the size of file \fIname\fR in bytes.  If
261
the file doesn't exist or its size cannot be queried then an error is
262
generated.
263
.TP
264
\fBfile split \fIname\fR
265
.
266
Returns a list whose elements are the path components in \fIname\fR.  The
267
first element of the list will have the same path type as \fIname\fR.
268
All other elements will be relative.  Path separators will be discarded
269
unless they are needed ensure that an element is unambiguously relative.
270
For example, under Unix
271
.RS
272
.CS
273
\fBfile split /foo/~bar/baz\fR
274
.CE
275
returns \fB/\0\0foo\0\0./~bar\0\0baz\fR to ensure that later commands
276
that use the third component do not attempt to perform tilde
277
substitution.
278
.RE
279
.TP
280
\fBfile stat  \fIname varName\fR
281
.
282
Invokes the \fBstat\fR kernel call on \fIname\fR, and uses the variable
283
given by \fIvarName\fR to hold information returned from the kernel call.
284
\fIVarName\fR is treated as an array variable, and the following elements
285
of that variable are set: \fBatime\fR, \fBctime\fR, \fBdev\fR, \fBgid\fR,
286
\fBino\fR, \fBmode\fR, \fBmtime\fR, \fBnlink\fR, \fBsize\fR, \fBtype\fR,
287
\fBuid\fR.  Each element except \fBtype\fR is a decimal string with the
288
value of the corresponding field from the \fBstat\fR return structure;
289
see the manual entry for \fBstat\fR for details on the meanings of the
290
values.  The \fBtype\fR element gives the type of the file in the same
291
form returned by the command \fBfile type\fR.  This command returns an
292
empty string.
293
.TP
294
\fBfile tail \fIname\fR
295
.
296
Returns all of the characters in \fIname\fR after the last directory
297
separator.  If \fIname\fR contains no separators then returns
298
\fIname\fR.
299
.TP
300
\fBfile type \fIname\fR
301
.
302
Returns a string giving the type of file \fIname\fR, which will be one of
303
\fBfile\fR, \fBdirectory\fR, \fBcharacterSpecial\fR, \fBblockSpecial\fR,
304
\fBfifo\fR, \fBlink\fR, or \fBsocket\fR.
305
.TP
306
\fBfile volume\fR
307
.
308
Returns the absolute paths to the volumes mounted on the system, as a proper
309
Tcl list.  On the Macintosh, this will be a list of the mounted drives,
310
both local and network.  N.B. if two drives have the same name, they will
311
both appear on the volume list, but there is currently no way, from Tcl, to
312
access any but the first of these drives.  On UNIX, the command will always return
313
"/", since all filesystems are locally mounted.  On Windows, it will return
314
a list of the available local drives (e.g. {a:/ c:/}).
315
.TP
316
\fBfile writable \fIname\fR
317
.
318
Returns \fB1\fR if file \fIname\fR is writable by the current user,
319
\fB0\fR otherwise.
320
.SH "PORTABILITY ISSUES"
321
.TP
322
\fBUnix\fR\0\0\0\0\0\0\0
323
.
324
These commands always operate using the real user and group identifiers,
325
not the effective ones.
326
 
327
.SH "SEE ALSO"
328
filename
329
 
330
.SH KEYWORDS
331
attributes, copy files, delete files, directory, file, move files, name, rename files, stat

powered by: WebSVN 2.1.0

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