comparison lispref/files.texi @ 28635:cda2b6ed6aec

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Tue, 18 Apr 2000 21:27:18 +0000
parents c46c2efa3731
children bf112ad58dc7
comparison
equal deleted inserted replaced
28634:a2cce25e6c7f 28635:cda2b6ed6aec
1376 1376
1377 The functions in this section do not actually access files, so they 1377 The functions in this section do not actually access files, so they
1378 can operate on file names that do not refer to an existing file or 1378 can operate on file names that do not refer to an existing file or
1379 directory. 1379 directory.
1380 1380
1381 On VMS, all these functions understand both VMS file-name syntax and 1381 On MS-DOS and MS-Windows, these functions (like the function that
1382 Unix syntax. This is so that all the standard Lisp libraries can 1382 actually operate on files) accept MS-DOS or MS-Windows file-name syntax,
1383 specify file names in Unix syntax and work properly on VMS without 1383 where backslashes separate the components, as well as Unix syntax; but
1384 change. On MS-DOS and MS-Windows, these functions understand MS-DOS or 1384 they always return Unix syntax. On VMS, these functions (and the ones
1385 MS-Windows file-name syntax as well as Unix syntax. 1385 that operate on files) understand both VMS file-name syntax and Unix
1386 syntax. This enables Lisp programs to specify file names in Unix syntax
1387 and work properly on all systems without change.
1386 1388
1387 @menu 1389 @menu
1388 * File Name Components:: The directory part of a file name, and the rest. 1390 * File Name Components:: The directory part of a file name, and the rest.
1389 * Directory Names:: A directory's name as a directory 1391 * Directory Names:: A directory's name as a directory
1390 is different from its name as a file. 1392 is different from its name as a file.
1408 parts: the @dfn{directory name} part, and the @dfn{nondirectory} part 1410 parts: the @dfn{directory name} part, and the @dfn{nondirectory} part
1409 (or @dfn{file name within the directory}). Either part may be empty. 1411 (or @dfn{file name within the directory}). Either part may be empty.
1410 Concatenating these two parts reproduces the original file name. 1412 Concatenating these two parts reproduces the original file name.
1411 1413
1412 On most systems, the directory part is everything up to and including 1414 On most systems, the directory part is everything up to and including
1413 the last slash (or backslash, on MS-DOS or MS-Windows); the nondirectory 1415 the last slash (backslash is also allowed in input on MS-DOS or
1414 part is the rest. The rules in VMS syntax are complicated. 1416 MS-Windows); the nondirectory part is the rest. The rules in VMS syntax
1417 are complicated.
1415 1418
1416 For some purposes, the nondirectory part is further subdivided into 1419 For some purposes, the nondirectory part is further subdivided into
1417 the name proper and the @dfn{version number}. On most systems, only 1420 the name proper and the @dfn{version number}. On most systems, only
1418 backup files have version numbers in their names. On VMS, every file 1421 backup files have version numbers in their names. On VMS, every file
1419 has a version number, but most of the time the file name actually used 1422 has a version number, but most of the time the file name actually used
1503 (file-name-sans-extension "big.hack/foo") 1506 (file-name-sans-extension "big.hack/foo")
1504 @result{} "big.hack/foo" 1507 @result{} "big.hack/foo"
1505 @end example 1508 @end example
1506 @end defun 1509 @end defun
1507 1510
1508 @defvar directory-sep-char 1511 @ignore
1509 @tindex directory-sep-char 1512 Andrew Innes says that this
1510 This variable holds the character that the system normally uses to 1513
1511 separate file name components. The value is @code{?/} on GNU and Unix 1514 @c @defvar directory-sep-char
1512 systems, and @code{?\\} on MS-DOS and MS-Windows. Note that file names 1515 @c @tindex directory-sep-char
1513 using slashes as separators work properly in Emacs on all of these 1516 This variable holds the character that Emacs normally uses to separate
1514 systems; you are not obliged to use backslashes on Microsoft systems. 1517 file name components. The default value is @code{?/}, but on MS-Windows
1518 you can set it to @code{?\\}; then the functions that transform file names
1519 use backslashes in their output.
1520
1521 File names using backslashes work as input to Lisp primitives even on
1522 MS-DOS and MS-Windows, even if @code{directory-sep-char} has its default
1523 value of @code{?/}.
1515 @end defvar 1524 @end defvar
1525 @end ignore
1516 1526
1517 @node Directory Names 1527 @node Directory Names
1518 @comment node-name, next, previous, up 1528 @comment node-name, next, previous, up
1519 @subsection Directory Names 1529 @subsection Directory Names
1520 @cindex directory name 1530 @cindex directory name
1522 1532
1523 A @dfn{directory name} is the name of a directory. A directory is a 1533 A @dfn{directory name} is the name of a directory. A directory is a
1524 kind of file, and it has a file name, which is related to the directory 1534 kind of file, and it has a file name, which is related to the directory
1525 name but not identical to it. (This is not quite the same as the usual 1535 name but not identical to it. (This is not quite the same as the usual
1526 Unix terminology.) These two different names for the same entity are 1536 Unix terminology.) These two different names for the same entity are
1527 related by a syntactic transformation. On most systems, this is simple: a 1537 related by a syntactic transformation. On most systems, this is simple:
1528 directory name ends in a slash, whereas the directory's name as a file 1538 a directory name ends in a slash (or backslash), whereas the directory's
1529 lacks that slash. On VMS, the relationship is more complicated. 1539 name as a file lacks that slash. On VMS, the relationship is more
1540 complicated.
1530 1541
1531 The difference between a directory name and its name as a file is 1542 The difference between a directory name and its name as a file is
1532 subtle but crucial. When an Emacs variable or function argument is 1543 subtle but crucial. When an Emacs variable or function argument is
1533 described as being a directory name, a file name of a directory is not 1544 described as being a directory name, a file name of a directory is not
1534 acceptable. 1545 acceptable.
1553 @end defun 1564 @end defun
1554 1565
1555 @defun directory-file-name dirname 1566 @defun directory-file-name dirname
1556 This function returns a string representing @var{dirname} in a form that 1567 This function returns a string representing @var{dirname} in a form that
1557 the operating system will interpret as the name of a file. On most 1568 the operating system will interpret as the name of a file. On most
1558 systems, this means removing the final slash from the string. On VMS, 1569 systems, this means removing the final slash (or backslash) from the
1559 the function converts a string of the form @file{[X.Y]} to 1570 string. On VMS, the function converts a string of the form @file{[X.Y]}
1560 @file{[X]Y.DIR.1}. 1571 to @file{[X]Y.DIR.1}.
1561 1572
1562 @example 1573 @example
1563 @group 1574 @group
1564 (directory-file-name "~lewis/") 1575 (directory-file-name "~lewis/")
1565 @result{} "~lewis" 1576 @result{} "~lewis"
1894 @var{directory}. The order of the completions is the order of the files 1905 @var{directory}. The order of the completions is the order of the files
1895 in the directory, which is unpredictable and conveys no useful 1906 in the directory, which is unpredictable and conveys no useful
1896 information. 1907 information.
1897 1908
1898 The argument @var{partial-filename} must be a file name containing no 1909 The argument @var{partial-filename} must be a file name containing no
1899 directory part and no slash. The current buffer's default directory is 1910 directory part and no slash (or backslash on some systems). The current
1900 prepended to @var{directory}, if @var{directory} is not absolute. 1911 buffer's default directory is prepended to @var{directory}, if
1912 @var{directory} is not absolute.
1901 1913
1902 In the following example, suppose that @file{~rms/lewis} is the current 1914 In the following example, suppose that @file{~rms/lewis} is the current
1903 default directory, and has five files whose names begin with @samp{f}: 1915 default directory, and has five files whose names begin with @samp{f}:
1904 @file{foo}, @file{file~}, @file{file.c}, @file{file.c.~1~}, and 1916 @file{foo}, @file{file~}, @file{file.c}, @file{file.c.~1~}, and
1905 @file{file.c.~2~}.@refill 1917 @file{file.c.~2~}.@refill