Mercurial > hg > xemacs-beta
comparison man/lispref/files.texi @ 290:c9fe270a4101 r21-0b43
Import from CVS: tag r21-0b43
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:36:47 +0200 |
parents | 7df0dd720c89 |
children | 6240c7796c7a |
comparison
equal
deleted
inserted
replaced
289:6e6992ccc4b6 | 290:c9fe270a4101 |
---|---|
1631 | 1631 |
1632 Some programs need to write temporary files. Here is the usual way to | 1632 Some programs need to write temporary files. Here is the usual way to |
1633 construct a name for such a file: | 1633 construct a name for such a file: |
1634 | 1634 |
1635 @example | 1635 @example |
1636 (make-temp-name (concat "/tmp/" @var{name-of-application})) | 1636 (make-temp-name (expand-file-name @var{name-of-application} (temp-directory))) |
1637 @end example | 1637 @end example |
1638 | 1638 |
1639 @noindent | 1639 @noindent |
1640 Here we use the directory @file{/tmp/} because that is the standard | 1640 Here we use @code{(temp-directory)} to specify a directory for temporary |
1641 place on Unix for temporary files. The job of @code{make-temp-name} is | 1641 files---under Unix, it will normally evaluate to @file{"/tmp/"}. The |
1642 to prevent two different users or two different processes from trying to | 1642 job of @code{make-temp-name} is to prevent two different users or two |
1643 use the same name. | 1643 different processes from trying to use the same name. |
1644 | 1644 |
1645 @defun make-temp-name string | 1645 @defun temp-directory |
1646 This function generates a string that can be used as a unique name. The | 1646 This function returns the name of the directory to use for temporary |
1647 name starts with @var{string}, and ends with a number that is different | 1647 files. Under Unix, this will be the value of @code{TMPDIR}, defaulting |
1648 in each XEmacs process. | 1648 to @file{/tmp}. On Windows, this will be obtained from the @code{TEMP} |
1649 or @code{TMP} environment variables, defaulting to @file{/}. | |
1650 | |
1651 Note that the @code{temp-directory} function does not exist under FSF | |
1652 Emacs. | |
1653 @end defun | |
1654 | |
1655 @defun make-temp-name prefix | |
1656 This function generates a temporary file name starting with | |
1657 @var{prefix}. The Emacs process number forms part of the result, so | |
1658 there is no danger of generating a name being used by another process. | |
1649 | 1659 |
1650 @example | 1660 @example |
1651 @group | 1661 @group |
1652 (make-temp-name "/tmp/foo") | 1662 (make-temp-name "/tmp/foo") |
1653 @result{} "/tmp/foo021304" | 1663 @result{} "/tmp/fooGaAQjC" |
1654 @end group | 1664 @end group |
1655 @end example | 1665 @end example |
1656 | 1666 |
1657 To prevent conflicts among different libraries running in the same | 1667 In addition, this function makes an attempt to choose a name that does |
1658 XEmacs, each Lisp program that uses @code{make-temp-name} should have its | 1668 not specify an existing file. To make this work, @var{prefix} should be |
1659 own @var{string}. The number added to the end of the name distinguishes | 1669 an absolute file name. |
1660 between the same application running in different XEmacs processes. | 1670 |
1671 To avoid confusion, each Lisp application should preferably use a unique | |
1672 @var{prefix} to @code{make-temp-name}. | |
1661 @end defun | 1673 @end defun |
1662 | 1674 |
1663 @node File Name Completion | 1675 @node File Name Completion |
1664 @subsection File Name Completion | 1676 @subsection File Name Completion |
1665 @cindex file name completion subroutines | 1677 @cindex file name completion subroutines |