Filename

Filename
Screenshot of a Windows command shell showing filenames in a directory

The filename is metadata about a file; a string used to uniquely identify a file stored on the file system. Different file systems impose different restrictions on length and allowed characters on filenames.

A filename includes one or more of these components:

  • directory (or path) – directory tree (e.g., /usr/bin, \TEMP, [USR.LIB.SRC], etc.)
  • file – base name of the file
  • type (format or extension) – indicates the content type of the file (e.g., .txt, .exe, .COM, etc.)
  • version – revision or generation number of the file

To refer to a file on a remote computer filesystem ( host, server) some utilities use the remote computer name or address to prefix the filename.

Contents

References: absolute vs relative

An absolute reference includes all directory levels. In some systems, a filename reference that does not include the complete directory path it defaults to the current working directory. This is a relative reference. One advantage of using a relative reference in program configuration files or scripts is that different instances of the script or program can use different files.

Unix-like file systems allow a file to have more than one name; in traditional Unix-style file systems, the names are hard links to the file's inode or equivalent. Windows supports hard links on NTFS file systems, but provides no command line tool for creating them until Windows Vista.[1] Hard links are different from Windows shortcuts, Mac OS aliases, or symbolic links.

Length Restrictions

Some filesystems restrict the length of filenames to 11, 14, 31, 44[2] or 255 characters

Filename extensions

Many file systems, including FAT, NTFS, and VMS systems, allow a filename extension that consists of one or more characters following the last period in the filename, dividing the filename into two parts: the basename[3] (the primary filename) and an extension used by some applications to indicate the file type. Multiple output files created by an application use the same basename and various extensions. For example a compiler might use the extension FOR for the source input file, OBJ for the object output and LST for the listing. Although there are some common extensions they are arbitrary and a different application might use REL and RPT. On filesystems that do not segregate the extension, files will often have a longer extension such as html.

Uniqueness

Within a single directory, filenames must be unique. Since the filename syntax also applies for directories, it is not possible to create a file and directory entries with the same name in a single directory. Multiple files in different directories may have the same name.

Case: upper, lower, preservation

Some filesystems, such as FAT, store filenames as upper-case regardless of the case used to create them. For example "MyName" and "myname" would be stored as "MYNAME". A directory could not contain a file with the name "MyName" and another file with the name "myname". Any variation of case can be used to refer to the file (ex: "MYname"). These file systems are called "case-insensitive".

Some filesystems prohibit lower case letters.

Some file systems store filenames as specified when the files is created meaning files MyName and myname would be valid names for different files concurrently in the same directory. Those file systems are called "case-sensitive". Some of these filesystems include a parameter specified when the filesystem which allows references to files regardless of the case. For example a file named "FirstFile" can be referenced as "firstFile", "firstfile", etc.

Not all file systems in Unix-like systems are case-sensitive; by default, HFS+ in Mac OS X is case-insensitive, and SMB servers usually provide case-insensitive behavior (even when the underlying file system is case-sensitive, for example Samba on most Unix-like systems), SMB client file systems provide case-insensitive behavior. File system case sensitivity is a considerable challenge for software such as Samba and Wine, which must interoperate efficiently with both systems that treat uppercase and lowercase files as different and systems that treat them the same.[4]

Reserved characters and words

Many file system utilities prohibit control characters from appearing in filenames. In Unix-like file systems the null character, as that is the end-of-string indicator[5] and the path separator / are prohibited.

Some file system utilities prohibit some particular characters from appearing in filenames:

Character Name Reason
/ slash used as a path name component separator in Unix-like, Windows, and Amiga systems. (The MS-DOS command.com shell would consume it as a switch character, but Windows itself always accepts it as a separator.[6][vague])
\ backslash Also used as a path name component separator in MS-DOS, OS/2 and Windows (where there are few differences between slash and backslash); allowed in Unix filenames, see Note 1
? question mark used as a wildcard in Unix, Windows and AmigaOS; marks a single character. Allowed in Unix filenames, see Note 1
% percent used as a wildcard in RT-11; marks a single character.
* asterisk
or star
used as a wildcard in Unix, MS-DOS, RT-11, VMS and Windows. Marks any sequence of characters (Unix, Windows, later versions of MS-DOS) or any sequence of characters in either the basename or extension (thus "*.*" in early versions of MS-DOS means "all files". Allowed in Unix filenames, see note 1
: colon used to determine the mount point / drive on Windows; used to determine the virtual device or physical device such as a drive on AmigaOS, RT-11 and VMS; used as a pathname separator in classic Mac OS. Doubled after a name on VMS, indicates the DECnet nodename (equivalent to a NetBIOS (Windows networking) hostname preceded by "\\".)
| vertical bar
or pipe
designates software pipelining in Unix and Windows; allowed in Unix filenames, see Note 1
" quote used to mark beginning and end of filenames containing spaces in Windows, see Note 1
< less than used to redirect input, allowed in Unix filenames, see Note 1
> greater than used to redirect output, allowed in Unix filenames, see Note 1
. period
or dot
allowed but the last occurrence will be interpreted to be the extension separator in VMS, MS-DOS and Windows. In other OSes, usually considered as part of the filename, and more than one period (full stop) may be allowed.

Note 1: While they are allowed in Unix file and folder names, most Unix shells require certain characters such as spaces, <, >, |, \, and sometimes :, (, ), &, ;, #, as well as wildcards such as ? and *, to be quoted or escaped:

five\ and\ six\<seven (example of escaping)
'five and six<seven' or "five and six<seven" (examples of quoting)

In Windows utilities the space and the period are not allowed as the final character of a filename.[citation needed] The period is allowed as the first character, but certain Windows applications, such as Windows Explorer, forbid creating or renaming such files (despite this convention being used in Unix-like systems to describe hidden files and directories). Among workarounds are using different explorer applications or saving a file with the desired filename from within an application .[7]

Some file systems on a given operating system (especially file systems originally implemented on other operating systems), and particular applications on that operating system, may apply further restrictions and interpretations. See comparison of file systems for more details on restrictions.

In Unix-like systems, MS-DOS, and Windows, the filenames "." and ".." have special meanings (current and parent directory respectively).

In addition, in Windows and DOS utilities, some words might also be reserved and can not be used as filenames.[7] For example, DOS Device file:

CON, PRN, AUX, CLOCK$, NUL
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. 

Systems that have these restrictions cause incompatibilities with some other filesystems. For example, Windows will fail to handle, or raise error reports for, these legal UNIX filenames: aux.c, q"uote"s.txt, or NUL.txt.

NTFS filenames that are used internally include:

$Mft, $MftMirr, $LogFile, $Volume, $AttrDef, $Bitmap, $Boot, $BadClus, $Secure,
$Upcase, $Extend, $Quota, $ObjId and $Reparse

Comparison of filename limitations

System Alphabetic Case Sensitivity Allowed Character Set Reserved Characters Reserved Words Maximum Length Comments
MS-DOS FAT case-insensitive case-destruction any 8-bit set x00-x1F SPACE DEL " * / : < > ? \ | Devicesnames like: AUX COM1 … COM9 CON LPT1 … LPT9 NUL PRN 11 Maximum 8 character base name limit and 3 character extension; see 8.3 filename
Win95 VFAT case-insensitive any 8-bit set |\?*<":>+[]/ control characters 255
FAT32 case-insensitive Unicode, using UTF-16 encoding |\?*<":>+[]/ control characters 255
NTFS optional (case-preservation) Unicode, using UTF-16 encoding / null (i.e., 0x00) Only in Root Directory:  $AttrDef $BadClus $Bitmap $Boot $LogFile $MFT $MFTMirr pagefile.sys $Secure $UpCase $Volume $Extend $Extend\$ObjId $Extend\$Quota $Extend\$Reparse ($Extend is a directory) 255 forbids the use of characters in range 1-31 (0x01-0x1F) and characters " * : < > ? \ / |. NTFS allows each path component (directory or filename) to be 255 characters long.

Windows forbids the use of the MS-DOS device names AUX, CLOCK$, COM1, …, COM9, CON, LPT1, …, LPT9, NUL and PRN, as well as these names with any extension (for example, AUX.txt), except when using Long UNC paths (ex. \\.\C:\nul.txt or \\?\D:\aux\con). (CLOCK$ may be used if an extension is provided.) The Win32 API strips trailing space and period (full-stop) characters from filenames, except when UNC paths are used. These restrictions only apply to Windows; Linux NTFS allows the use of the " * : < > ? \ | characters.

OS/2 HPFS case-insensitive case-preservation any 8-bit set |\?*<":>/ 254
Mac OS HFS case-insensitive case-preservation any 8-bit set  : 255 old versions of Finder are limited to 31 characters
Mac OS HFS+ optional (case-preservation) any 8-bit set  : on disk, in classic Mac OS, and at the Carbon layer in Mac OS X; / at the Unix layer in Mac OS X 255 Mac OS 8.1 - Mac OS X
most UNIX file systems case-sensitive case-preservation any 8-bit set / null 255 a leading . indicates that ls and file managers will not show the file by default
zOS other than $ # @ - x'C0' 44 first character must be alphabetic or national ($, #, @)

"Qualified" contains . after every 8 characters or fewer.[8]

early UNIX (AT&T) case-sensitive case-preservation any 8-bit set / 14 a leading . indicates a "hidden" file
POSIX "Fully portable filenames"[9] case-sensitive case-preservation A–Z a–z 0–9 . _ - / null Filenames to avoid include: a.out, core, .profile, .history, .cshrc 14 hyphen must not be first character
ISO 9660 case-insensitive A–Z 0–9 _ . "close to 180"(Level 2) or 200(Level 3) Used on CDs; 8 directory levels max (for Level 1, not level 2,3)
AmigaOS case-insensitive case-preservation any 8-bit set  : / " 107 dos.library
Amiga OFS case-insensitive case-preservation any 8-bit set  : / " 30 Original File System 1985
Amiga FFS case-insensitive case-preservation any 8-bit set  : / " 30 Fast File System 1988
Amiga PFS case-insensitive case-preservation any 8-bit set  : / " 255 Professional File System 1993
Amiga SFS case-insensitive case-preservation any 8-bit set  : / " 32,000 Smart File System 1998
Amiga FFS2 case-insensitive case-preservation any 8-bit set  : / " 107 Fast File System 2 2002
BeOS BFS case-sensitive Unicode, using UTF-8 encoding / 255
DEC PDP-11 RT-11 case-insensitive RADIX-50 6 + 3 Flat filesystem with no subdirs. A full "file specification" includes device, filename and extension (file type) in the format: dev:filnam.ext.
DEC VAX VMS case-insensitive A–Z 0–9 $ - _ 32 per component; earlier 9 per component; latterly, 255 for a filename and 32 for an extension. a full "file specification" includes nodename, diskname, directory/ies, filename, extension and version in the format: OURNODE::MYDISK:[THISDIR.THATDIR]FILENAME.EXTENSION;2 Directories can only go 8 levels deep.
Commodore 64 case-sensitive case-preservation any 8-bit set  :, = $ 16 length depends on the drive, usually 16

See also

References

  1. ^ "NTFS Hard Links, Directory Junctions, and Windows Shortcuts". Flex hex. Inv Softworks. http://www.flexhex.com/docs/articles/hard-links.phtml. Retrieved 12 March 2011. 
  2. ^ "DSN". http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.halu001/dd_name_support.htm. 
  3. ^ http://kernel.org/doc/man-pages/online/pages/man3/basename.3.html
  4. ^ "CaseInsensitiveFilenames - The Official Wine Wiki". Wiki.winehq.org. 2009-11-08. http://wiki.winehq.org/CaseInsensitiveFilenames. Retrieved 2010-08-20. 
  5. ^ "The Open Group Base Specifications Issue 6". http://pubs.opengroup.org/onlinepubs/007904875/basedefs/xbd_chap03.html#tag_03_169. 
  6. ^ "When did Windows start accepting forward slash as a path separator? - Python answers". Thescripts.com. July 18, 2005. http://www.thescripts.com/forum/thread23123.html. Retrieved 2010-08-20. 
  7. ^ a b Naming a file msdn.microsoft.com (MSDN), filename restrictions on Windows
  8. ^ http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.ieab600/iea2b690211.htm
  9. ^ Lewine, Donald. POSIX Programmer's Guide: Writing Portable UNIX Programs 1991 O'Reilly & Associates, Inc. Sebastopol, CA pp63-64

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • filename — file‧name [ˈfaɪlneɪm] noun [countable] COMPUTING the name that you give to a computer file and which you use when you want to open it, remove it, put it on disk etc: • Enter the filename, or press F1 for a list of available filenames. * * *… …   Financial and business terms

  • filename — UK [ˈfaɪlˌneɪm] / US noun [countable] Word forms filename : singular filename plural filenames computing the name that someone gives to a particular computer file …   English dictionary

  • filename —    The name of a file on a disk used so that both you and the operating system can find the file again. Every file in a directory must have a unique name, but files in different directories can share the same name.    In MS DOS, file and… …   Dictionary of networking

  • filename — noun (computer science) the name given to a computer file in order to distinguish it from other files; may contain an extension that indicates the type of file • Syn: ↑file name, ↑computer filename, ↑computer file name • Topics: ↑computer science …   Useful english dictionary

  • Filename extension — A filename extension is a suffix (separated from the basefilename by a dot) to the name of a computer file applied to indicate the encoding (file format) of its contents or usage. Some filesystems limit the length of the extension (such as the… …   Wikipedia

  • Filename mangling — dablink|This article discusses the mangling of filenames for operating system compatibility.For the concept of name mangling within compilers, see name mangling.The process of name mangling, in computing, involves a re writing of the file name… …   Wikipedia

  • filename extension — noun a string of characters beginning with a period and followed by one or more letters; the optional second part of a PC computer filename most applications provide extensions for the files they create most BASIC files use the filename extension …   Useful english dictionary

  • filename extension —    In the MS DOS file allocation table (FAT) file system, an optional three character suffix added to the end of a filename and separated from the name by a period …   Dictionary of networking

  • filename — /fuyl naym /, n. an identifying name given to an electronically stored computer file, conforming to limitations imposed by the operating system, as in length or restricted choice of characters. * * * …   Universalium

  • filename — noun The name assigned to a collection of records (i.e. lines) within a filesystem …   Wiktionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”