file
1. file.1.man
Manpage of FILE
FILE
Section: Copyrighted but distributable (1)Updated: November 1997
Index Return to Main Contents
NAAM
file - bepaal bestand soortSYNOPSIS
bestand [ -bcnsvzL ] [ -f naambestand ] [ -m magischbestand ] bestand ...BESCHRIJVING
Deze handleiding beschrijft versie 3.27 van de file opdracht. File test elk argument in een poging het te klassificeren. Er zijn drie testen, afgewerkt in deze volgorde: bestandsysteem testen, magische nummer testen en taal testen. De eerste test die slaagt zorgt dat de bestandsoort wordt afgedrukt.De soort die afgedrukt wordt zal gewoonlijk één van de woorden text (het bestand bevat alleen ASCII karakters en is waarschijnlijk veilig om te lezen op een ASCII terminal), executable (het bestand bevat het resultaat van het compileren van een programma in een vorm die begrijpelijk is voor een of andere UNIX kernel), of data betekenend al het andere (data is gewoonlijk `binair' of niet-afdrukbaar). Uitzonderingen zijn algemeen bekende bestandsvormen (core bestanden, tar archieven) waarvan bekend is dat ze binaire data bevatten. Bij toevoegen van locale definities aan /etc/magic, behoudt deze sleutelwoorden. Mensen vertrouwen op het feit dat bij alle leesbare bestanden in een directorie het woord ``text'' afgedrukt wordt. Doe niet zoals Berkeley deed - veranderen van ``shell commands text'' in ``shell script''.
De bestandsysteem tests zijn gebaseerd op het onderzoeken van de eindwaarde van een stat(2) systeem aanroep. Het programma test om te zien of een bestand leeg is, of dat het een soort speciaal bestand is. Elke bekende bestand soort die toepasselijk is op het systeem waar u op draait (sockets, symbolische koppelingen, benoemde pijpen (FIFOs) op systemen die dat implementeren) worden opgemerkt als ze zijn gedifinieerd in het systeem header bestand sys/stat.h.
De magische nummer tests worden gebruikt om te testen op bestanden met gegevens in bepaalde vaste vormen. Het meest in het oog springende voorbeeld hiervan is een binair uitvoerbaar bestand (gecompileerd programma) a.out bestand, wiens vorm gedefinieerd is in a.out.h en mogelijk exec.h in de standaard `include' directorie. Deze bestanden hebben een `magisch nummer' opgeslagen op een vaste plaats vlakbij het begin van het bestand, dat het UNIX besturingssysteem verteld dat het bestand een binair executeerbare is en welke van verschillende soorten daarvan. Het `magisch nummer' concept wordt ook als uitbreiding hierop toegepast op data bestanden. Elk bestand met een onveranderlijke identificeerder op een kleine vaste afstand van het begin van het bestand kan gewoonlijk beschreven worden op deze manier. De informatie in deze bestanden wordt standaard gelezen van het magische bestanden bestand /etc/magic en /usr/share/misc/magic.
Als een argument een ASCII bestand blijkt te zijn dan probeert file om de taal te raden. De taal tests zoeken naar bepaalde strings (cf names.h) die ergens in de eerste paar blokken van het bestand kunnen voorkomen. Bijvoorbeeld het sleutelwoord .br betekend hoogstwaarschijnlijk dat het bestand een troff(1) invoer bestand is, net zoals het sleutelwoord struct een C programma aangeeft. Deze tests zijn minder betrouwbaar dan de eerdere twee groepen, dus worden ze als laatste uitgevoerd. De taal routines testen ook wat andere dingen (zoals tar(1) archieven) en bepalen of een onbekend bestand `ascii text' of `data' genoemd moet worden).
OPTIES
- -b, --brief
- {--kort} Zet geen bestandsnamen vóór uitvoerregels.
- -c, --checking-printout
- {--test-afdrukken} Zorgt dat een afdruk gegeven wordt van de verwerkte vorm van het magische bestand. Dit wordt gewoonlijk gebruikt in samenwerking met -m om een nieuw magisch bestand te debuggen voordat het geïnstalleerd wordt.
- -f, --files-from NAMENBESTAND
- {--bestanden-van} Lees de namen van de te onderzoeken bestanden van NAMENBESTAND (één per regel) vóór de argumenten lijst. NAMENBESTAND Of tenminste één bestandnaam argument moet aanwezig zijn; om de standaard invoer te testen, gebruik ``-'' als een bestandnaam argument.
- -m, --magic-file LIJST
- {--magisch-bestand} Geef een alternatieve lijst van bestandsnamen op die magische nummers bevat. Dit kan een enkel bestand zijn, of een dubbelepunten gescheiden lijst van bestanden.
- -n, --no-buffer
- {--geen-buffer} Dwing doorspoelen van standaarduitvoer na het onderzoeken van een bestand. Dit is alleen zinvol als een lijst bestanden wordt onderzocht. Het is bedoeld om door programma's gebruikt te worden wanneer ze de bestands-soort uitvoer van een pijp willen.
- -z, --uncompress
- {--decomprimeer} Probeer in gecomprimeerde bestanden te kijken.
- -L, --dereference
- {--verwijzing} Deze optie zorgt dat symbolische koppelingen worden gevolgd, net als dezelfde optie voor ls(1).
- -s, --special-files
- {--speciale-bestanden} Gewoonlijk probeert file alleen bestanden te lezen om het soort te bepalen voor bestanden die stat(2) als gewone bestanden raporteerd. Dit voorkomt problemen omdat lezen van speciale bestanden vreemde concequenties kan hebben. Opgeven van de -s optie zorgt dat file ook de argumentbestanden leest die blok- of karakter-speciale bestanden zijn. Dit is zinvol om het bestandsysteemsoort van de gegevens in rauwe schijf partities te bepalen, die blok-speciale bestanden zijn. Deze optie zorgt dat file de bestandsgrootte zoals gegeven door stat(2) negeert omdat dat op sommige systemen nul raporteert voor rauwe schijf partities.
- --help
- {--hulp} Geef een hulp bericht en eindig.
- --version
- {--versie} Geef versie inlichtingen en eindig.
BESTANDEN
- /usr/share/misc/magic
- Standaard lijst magische nummers.
- /etc/magic
- Locale toevoegingen aan magische wijsheid.
OMGEVING
De omgevingsvariabele MAGIC kan gebruikt worden om het standaard magische nummers bestand te zetten.ZIE OOK
magic(5) - beschrijving van magische bestandsvormen.strings(1), od(1), hexdump(1) - gereedschappen voor het onderzoeken van niet-tekstbestanden.
VOLDOET AAN
Men denkt dat dit programma de System V Interface Definitie van FILE(CMD) overstijgt, voor zover dat te bepalen is uit de vage taal daarin. Zijn gedrag is voor het grootste gedeelte overeenkomstig met het System V programma met dezelfde naam. Deze versie kent echter meer magie, dus zal het vaak andere (hoewel preciesere) uitvoer produceren in veel gevallen.
Het enige echte verschil tussen deze versie en System V is dat deze versie
witruimte als een begrenzer behandeld, zodat spaties in patroon-strings
geëscape't moeten worden.
Bijvoorbeeld:
>10 string language impress (imPRESS data)
in een bestaand magisch bestand zal veranderd moeten worden in
>10 string language\ impress (imPRESS data)
In aanvulling hierop (in deze versie), als een patroonstring een backslash
bevat moet het geëscape't worden. Bijvoorbeeld:
0 string \begindata Andrew Toolkit document
in een bestaand magisch bestand zal veranderd moeten worden in
0 string \\begindata Andrew Toolkit document
SunOS uitgave 3.2 en later van Sun Microsystems heeft een
file(1)
opdracht afgeleidt van die van System V, maar met enige uitbreidingen.
Mijn versie verschilt weinig van die van Sun.
Het heeft de `&' operator uitbreiding, gebruikt als in bijvoorbeeld:
>16 long&0x7fffffff >0 not stripped
MAGIE DIRECTORIE
De magische bestand-ingangen zijn verzameld van verschillende bronnen, vooral USENET, en aangereikt door verschillende auteurs. Christos Zoulas (adres onder) ontvangt aanvullingen of bijgewerkte magische bestand-ingangen. Een consolidatie van magische bestand-ingangen zal periodiek verspreidt worden.De volgorde van ingangen in het magische bestand is belangrijk. Afhankelijk van welk systeem u gebruikt kan de volgorde waarin ze bij elkaar gezet zijn verkeerd zijn.
VOORBEELDEN
$ file bestand.c bestand /dev/hda
bestand.c: C program text
bestand: ELF 32-bit LSB executable, Intel 80386, version 1,
dynamically linked, not stripped
/dev/hda: block special
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
/dev/hda: x86 boot sector
/dev/hda1: Linux/i386 ext2 filesystem
/dev/hda2: x86 boot sector
/dev/hda3: x86 boot sector, extended partition table
/dev/hda4: Linux/i386 ext2 filesystem
/dev/hda5: Linux/i386 swap file
/dev/hda6: Linux/i386 swap file
/dev/hda7: Linux/i386 swap file
/dev/hda8: Linux/i386 swap file
/dev/hda9: empty
/dev/hda10: empty
GESCHIEDENIS
Er was een file opdracht in elke UNIX sinds tenminste "Research Version 6" (handleiding dateerd van Januarie 1975). De System V versie introduceerde één belangrijke grote verandering: de externe lijst met magische nummer soorten. Dit remde het programma een beetje af maar maakte het veel flexibeler.Dit op System V versie gebaseerde programma werd geschreven door Ian Darwin zonder naar iemands anders broncode te kijken.
John Gilmore bewerkte de code uitgebreidt en maakte het beter dan de eerste versie. Geoff Collyer vond verschillende onhandigheden en leverde enkele magische bestand-ingangen. Het programma heeft zich sindsdien continue ontwikkeld.
AUTEUR
Geschreven door Ian F. Darwin, UUCP adres {utzoo | ihnp4}!darwin!ian, Internet adres ian@sq.com, post adres: P.O. Box 603, Station F, Toronto, Ontario, CANADA M4Y 2L8.Veranderd door Rob McMahon, cudcv@warwick.ac.uk, 1989, om de `&' operator uit te breiden van eenvoudig `x&y != 0' tot `x&y op z'.
Aangepast door Guy Harris, guy@netapp.com, 1993, om
-
de ``oude-stijl'' `&' operator terug te veranderen naar hoe het was, omdat 1) Rob McMahon's verandering eerdere stijl van gebruik brak, 2) de SunOS ``new-style'' `&' operator die deze versie van file ondersteund, ook `x&y op z' aankan, en 3) Rob's verandering was in elk geval niet gedocumenteerd;
zet erbij meerdere niveau's van `>';
zet erbij ``beshort'', ``leshort'', enz. sleutelwoorden om naar getallen in het bestand te kijken in een bepaalde byte volgorde, inplaats van in de natuurlijke byte volgorde van het proces dat file draait.
Veranderingen door Ian Darwin en verschillende auteurs waaronder Christos Zoulas (christos@astron.com), 1990-1999.
WETTELIJK BERICHT
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993.This software is not subject to and may not be made subject to any license of the American Telephone and Telegraph Company, Sun Microsystems Inc., Digital Equipment Inc., Lotus Development Inc., the Regents of the University of California, The X Consortium or MIT, or The Free Software Foundation.
This software is not subject to any export provision of the United States Department of Commerce, and may be exported to any country or planet.
Permission is granted to anyone to use this software for any purpose on any computer system, and to alter it and redistribute it freely, subject to the following restrictions:
1. The author is not responsible for the consequences of use of this software, no matter how awful, even if they arise from flaws in it.
2. The origin of this software must not be misrepresented, either by explicit claim or by omission. Since few users ever read sources, credits must appear in the documentation.
3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Since few users ever read sources, credits must appear in the documentation.
4. This notice may not be removed or altered.
A few support files (getopt, strtok) distributed with this package are by Henry Spencer and are subject to the same terms as above.
A few simple support files (strtol, strchr) distributed with this package are in the public domain; they are so marked.
The files tar.h and is_tar.c were written by John Gilmore from his public-domain tar program, and are not covered by the above restrictions.
BUGS
There must be a better way to automate the construction of the Magic file from all the glop in Magdir. What is it? Better yet, the magic file should be compiled into binary (say, ndbm(3) or, better yet, fixed-length ASCII strings for use in heterogenous network environments) for faster startup. Then the program would run as fast as the Version 7 program of the same name, with the flexibility of the System V version.File uses several algorithms that favor speed over accuracy, thus it can be misled about the contents of ASCII files.
The support for ASCII files (primarily for programming languages) is simplistic, inefficient and requires recompilation to update.
There should be an ``else'' clause to follow a series of continuation lines.
The magic file and keywords should have regular expression support. Their use of ASCII TAB as a field delimiter is ugly and makes it hard to edit the files, but is entrenched.
It might be advisable to allow upper-case letters in keywords for e.g., troff(1) commands vs man page macros. Regular expression support would make this easy.
The program doesn't grok FORTRAN. It should be able to figure FORTRAN by seeing some keywords which appear indented at the start of line. Regular expression support would make this easy.
The list of keywords in ascmagic probably belongs in the Magic file. This could be done by using some keyword like `*' for the offset value.
Another optimisation would be to sort the magic file so that we can just run down all the tests for the first byte, first word, first long, etc, once we have fetched it. Complain about conflicts in the magic file entries. Make a rule that the magic entries sort based on file offset rather than position within the magic file?
The program should provide a way to give an estimate of ``how good'' a guess is. We end up removing guesses (e.g. ``From '' as first 5 chars of file) because they are not as good as other guesses (e.g. ``Newsgroups:'' versus "Return-Path:"). Still, if the others don't pan out, it should be possible to use the first guess.
This program is slower than some vendors' file commands.
This manual page, and particularly this section, is too long.
BESCHIKBAARHEID
U kunt de laatste versie van de originele auteur verkrijgen via anonymous FTP op ftp.astron.com in de directorie /pub/file/file-X.YY.tar.gzDeze Debian versie voegt lange opties toe en corrigeert enkele bugs. Het kan verkregen worden van elke site met een Debian distro (ftp.debian.org en mirrors).
VERTALING
Alles wat tussen `{'..`}' staat is aanvullende vertaling, en hoort niet bij de originele handleiding. Deze handleiding van file 3.28 werd vertaald door JHBoersema. Email naar <manpages-nl@nl.linux.org>.$Id: file.1,v 1.4 2001/12/21 15:31:46 joostvb Exp $
Index
- NAAM
- SYNOPSIS
- BESCHRIJVING
- OPTIES
- BESTANDEN
- OMGEVING
- ZIE OOK
- VOLDOET AAN
- MAGIE DIRECTORIE
- VOORBEELDEN
- GESCHIEDENIS
- AUTEUR
- WETTELIJK BERICHT
- BUGS
- BESCHIKBAARHEID
- VERTALING
This document was created by man2html using the manual pages.
Time: 00:24:16 GMT, November 20, 2008
2. file.9.man
Manpage of file
file
Section: Tcl Built-In Commands (n)Updated: 8.3
Index Return to Main Contents
NAME
file - Manipulate file names and attributesSYNOPSIS
file option name ?arg arg ...?DESCRIPTION
This command provides several operations on a file's name or attributes. Name is the name of a file; if it starts with a tilde, then tilde substitution is done before executing the command (see the manual entry for filename for details). Option indicates what to do with the file name. Any unique abbreviation for option is acceptable. The valid options are:
- file atime name ?time?
- Returns a decimal string giving the time at which file name was last accessed. If time is specified, it is an access time to set for the file. The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its access time cannot be queried or set then an error is generated. On Windows, FAT file systems do not support access time.
- file attributes name
- file attributes name ?option?
- file attributes name ?option value option value...?
-
-
This subcommand returns or sets platform specific values associated
with a file. The first form returns a list of the platform specific
flags and their values. The second form returns the value for the
specific option. The third form sets one or more of the values. The
values are as follows:
On Unix, -group gets or sets the group name for the file. A group id can be given to the command, but it returns a group name. -owner gets or sets the user name of the owner of the file. The command returns the owner name, but the numerical id can be passed when setting the owner. -permissions sets or retrieves the octal code that chmod(1) uses. This command does also has limited support for setting using the symbolic attributes for chmod(1), of the form [ugo]?[[+-=][rwxst],[...]], where multiple symbolic attributes can be separated by commas (example: u+s,go-rw add sticky bit for user, remove read and write permissions for group and other). A simplified ls style string, of the form rwxrwxrwx (must be 9 characters), is also supported (example: rwxr-xr-t is equivalent to 01755).
On Windows, -archive gives the value or sets or clears the archive attribute of the file. -hidden gives the value or sets or clears the hidden attribute of the file. -longname will expand each path element to its long version. This attribute cannot be set. -readonly gives the value or sets or clears the readonly attribute of the file. -shortname gives a string where every path element is replaced with its short (8.3) version of the name. This attribute cannot be set. -system gives or sets or clears the value of the system attribute of the file.
On Macintosh, -creator gives or sets the Finder creator type of the file. -hidden gives or sets or clears the hidden attribute of the file. -readonly gives or sets or clears the readonly attribute of the file. Note that directories can only be locked if File Sharing is turned on. -type gives or sets the Finder file type for the file.
-
This subcommand returns or sets platform specific values associated
with a file. The first form returns a list of the platform specific
flags and their values. The second form returns the value for the
specific option. The third form sets one or more of the values. The
values are as follows:
- file channels ?pattern?
- If pattern isn't specified, returns a list of names of all registered open channels in this interpreter. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match.
- file copy ?-force? ?--? source target
- file copy ?-force? ?--? source ?source ...? targetDir
-
- The first form makes a copy of the file or directory source under the pathname target. If target is an existing directory, then the second form is used. The second form makes a copy inside targetDir of each source file listed. If a directory is specified as a source, then the contents of the directory will be recursively copied into targetDir. Existing files will not be overwritten unless the -force option is specified. When copying within a single filesystem, file copy will copy soft links (i.e. the links themselves are copied, not the things they point to). Trying to overwrite a non-empty directory, overwrite a directory with a file, or overwrite a file with a directory will all result in errors even if -force was specified. Arguments are processed in the order specified, halting at the first error, if any. A -- marks the end of switches; the argument following the -- will be treated as a source even if it starts with a -.
- file delete ?-force? ?--? pathname ?pathname ... ?
- Removes the file or directory specified by each pathname argument. Non-empty directories will be removed only if the -force option is specified. When operating on symbolic links, the links themselves will be deleted, not the objects they point to. Trying to delete a non-existent file is not considered an error. Trying to delete a read-only file will cause the file to be deleted, even if the -force flags is not specified. If the -force option is specified on a directory, Tcl will attempt both to change permissions and move the current directory 'pwd' out of the given path if that is necessary to allow the deletion to proceed. Arguments are processed in the order specified, halting at the first error, if any. A -- marks the end of switches; the argument following the -- will be treated as a pathname even if it starts with a -.
- file dirname name
-
Returns a name comprised of all of the path components in name
excluding the last element. If name is a relative file name and
only contains one path element, then returns ``.'' (or ``:''
on the Macintosh). If name refers to a root directory, then the
root directory is returned. For example,
-
-
file dirname c:/
Note that tilde substitution will only be performed if it is necessary to complete the command. For example,
-
file dirname ~/src/foo.c
-
file dirname ~
-
-
- file executable name
- Returns 1 if file name is executable by the current user, 0 otherwise.
- file exists name
- Returns 1 if file name exists and the current user has search privileges for the directories leading to it, 0 otherwise.
- file extension name
- Returns all of the characters in name after and including the last dot in the last element of name. If there is no dot in the last element of name then returns the empty string.
- file isdirectory name
- Returns 1 if file name is a directory, 0 otherwise.
- file isfile name
- Returns 1 if file name is a regular file, 0 otherwise.
- file join name ?name ...?
-
Takes one or more file names and combines them, using the correct path
separator for the current platform. If a particular name is
relative, then it will be joined to the previous file name argument.
Otherwise, any earlier arguments will be discarded, and joining will
proceed from the current argument. For example,
-
-
file join a b /foo bar
Note that any of the names can contain separators, and that the result is always canonical for the current platform: / for Unix and Windows, and : for Macintosh.
-
-
- file link ?-linktype? linkName ?target?
- If only one argument is given, that argument is assumed to be linkName, and this command returns the value of the link given by linkName (i.e. the name of the file it points to). If linkName isn't a link or its value cannot be read (as, for example, seems to be the case with hard links, which look just like ordinary files), then an error is returned. If 2 arguments are given, then these are assumed to be linkName and target. If linkName already exists, or if target doesn't exist, an error will be returned. Otherwise, Tcl creates a new link called linkName which points to the existing filesystem object at target, where the type of the link is platform-specific (on Unix a symbolic link will be the default). This is useful for the case where the user wishes to create a link in a cross-platform way, and doesn't care what type of link is created. If the user wishes to make a link of a specific type only, (and signal an error if for some reason that is not possible), then the optional -linktype argument should be given. Accepted values for -linktype are "-symbolic" and "-hard". When creating links on filesystems that either do not support any links, or do not support the specific type requested, an error message will be returned. In particular Windows 95, 98 and ME do not support any links at present, but most Unix platforms support both symbolic and hard links (the latter for files only), MacOS supports symbolic links and Windows NT/2000/XP (on NTFS drives) support symbolic directory links and hard file links.
- file lstat name varName
- Same as stat option (see below) except uses the lstat kernel call instead of stat. This means that if name refers to a symbolic link the information returned in varName is for the link rather than the file it refers to. On systems that don't support symbolic links this option behaves exactly the same as the stat option.
- file mkdir dir ?dir ...?
- Creates each directory specified. For each pathname dir specified, this command will create all non-existing parent directories as well as dir itself. If an existing directory is specified, then no action is taken and no error is returned. Trying to overwrite an existing file with a directory will result in an error. Arguments are processed in the order specified, halting at the first error, if any.
- file mtime name ?time?
- Returns a decimal string giving the time at which file name was last modified. If time is specified, it is a modification time to set for the file (equivalent to Unix touch). The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its modified time cannot be queried or set then an error is generated.
- file nativename name
- Returns the platform-specific name of the file. This is useful if the filename is needed to pass to a platform-specific call, such as exec under Windows or AppleScript on the Macintosh.
- file normalize name
-
- Returns a unique normalized path representation for the file-system object (file, directory, link, etc), whose string value can be used as a unique identifier for it. A normalized path is an absolute path which has all '../', './' removed. Also it is one which is in the ``standard'' format for the native platform. On MacOS, Unix, this means the segments leading up to the path must be free of symbolic links/aliases (but the very last path component may be a symbolic link), and on Windows it also means we want the long form with that form's case-dependence (which gives us a unique, case-dependent path). The one exception concerning the last link in the path is necessary, because Tcl or the user may wish to operate on the actual symbolic link itself (for example 'file delete', 'file rename', 'file copy' are defined to operate on symbolic links, not on the things that they point to).
- file owned name
- Returns 1 if file name is owned by the current user, 0 otherwise.
- file pathtype name
- Returns one of absolute, relative, volumerelative. If name refers to a specific file on a specific volume, the path type will be absolute. If name refers to a file relative to the current working directory, then the path type will be relative. If name refers to a file relative to the current working directory on a specified volume, or to a specific file on the current working volume, then the path type is volumerelative.
- file readable name
- Returns 1 if file name is readable by the current user, 0 otherwise.
- file readlink name
- Returns the value of the symbolic link given by name (i.e. the name of the file it points to). If name isn't a symbolic link or its value cannot be read, then an error is returned. On systems that don't support symbolic links this option is undefined.
- file rename ?-force? ?--? source target
- file rename ?-force? ?--? source ?source ...? targetDir
-
- The first form takes the file or directory specified by pathname source and renames it to target, moving the file if the pathname target specifies a name in a different directory. If target is an existing directory, then the second form is used. The second form moves each source file or directory into the directory targetDir. Existing files will not be overwritten unless the -force option is specified. When operating inside a single filesystem, Tcl will rename symbolic links rather than the things that they point to. Trying to overwrite a non-empty directory, overwrite a directory with a file, or a file with a directory will all result in errors. Arguments are processed in the order specified, halting at the first error, if any. A -- marks the end of switches; the argument following the -- will be treated as a source even if it starts with a -.
- file rootname name
- Returns all of the characters in name up to but not including the last ``.'' character in the last component of name. If the last component of name doesn't contain a dot, then returns name.
- file separator ?name?
- If no argument is given, returns the character which is used to separate path segments for native files on this platform. If a path is given, the filesystem responsible for that path is asked to return its separator character. If no file system accepts name, an error is generated.
- file size name
- Returns a decimal string giving the size of file name in bytes. If the file doesn't exist or its size cannot be queried then an error is generated.
- file split name
-
Returns a list whose elements are the path components in name. The
first element of the list will have the same path type as name.
All other elements will be relative. Path separators will be discarded
unless they are needed ensure that an element is unambiguously relative.
For example, under Unix
-
-
file split /foo/~bar/baz
-
-
- file stat name varName
- Invokes the stat kernel call on name, and uses the variable given by varName to hold information returned from the kernel call. VarName is treated as an array variable, and the following elements of that variable are set: atime, ctime, dev, gid, ino, mode, mtime, nlink, size, type, uid. Each element except type is a decimal string with the value of the corresponding field from the stat return structure; see the manual entry for stat for details on the meanings of the values. The type element gives the type of the file in the same form returned by the command file type. This command returns an empty string.
- file system name
- Returns a list of two elements, the first of which is the name of the filesystem to use for the file, and the second an arbitrary string representing the filesystem-specific nature or type of the location within that filesystem. If a filesystem only supports one type of file, the second element may be null. For example the native files have a first element 'native', and a second element which is a platform-specific type name for the file's system (e.g. 'NTFS', 'FAT', etc), or possibly the empty string if no further information is available or if this is not implemented. A generic virtual file system might return the list 'vfs ftp' to represent a file on a remote ftp site mounted as a virtual filesystem through an extension called 'vfs'. If the file does not belong to any filesystem, an error is generated.
- file tail name
- Returns all of the characters in name after the last directory separator. If name contains no separators then returns name.
- file type name
- Returns a string giving the type of file name, which will be one of file, directory, characterSpecial, blockSpecial, fifo, link, or socket.
- file volumes
- Returns the absolute paths to the volumes mounted on the system, as a proper Tcl list. On the Macintosh, this will be a list of the mounted drives, both local and network. N.B. if two drives have the same name, they will both appear on the volume list, but there is currently no way, from Tcl, to access any but the first of these drives. On UNIX, the command will always return "/", since all filesystems are locally mounted. On Windows, it will return a list of the available local drives (e.g. {a:/ c:/}).
- file writable name
- Returns 1 if file name is writable by the current user, 0 otherwise.
PORTABILITY ISSUES
- Unix
- These commands always operate using the real user and group identifiers, not the effective ones.
EXAMPLES
This procedure shows how to search for C files in a given directory that have a correspondingly-named object file in the current directory:-
proc findMatchingCFiles {dir} { set files {} switch $::tcl_platform(platform) { windows { set ext .obj } unix { set ext .o } } foreach file [glob -nocomplain -directory $dir *.c] { set objectFile [file tail [file rootname $file]]$ext if {[file exists $objectFile]} { lappend files $file } } return $files }
Rename a file and leave a symbolic link pointing from the old location to the new place:
-
set oldName foobar.txt set newName foo/bar.txt # Make sure that where we're going to move to exists... if {![file isdirectory [file dirname $newName]]} { file mkdir [file dirname $newName] } file rename $oldName $newName file link -symbolic $oldName $newName
SEE ALSO
filename(n), open(n), close(n), eof(n), gets(n), tell(n), seek(n), fblocked(n), flush(n)KEYWORDS
attributes, copy files, delete files, directory, file, move files, name, rename files, stat
Index
This document was created by man2html using the manual pages.
Time: 00:24:16 GMT, November 20, 2008





