1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<h4 class="subsection">Truenames</h4> <p>The <em>truename</em> of a file is the name that you get by following symbolic links at all levels until none remain, then simplifying away ‘<samp>.</samp>’ and ‘<samp>..</samp>’ appearing as name components. This results in a sort of canonical name for the file. A file does not always have a unique truename; the number of distinct truenames a file has is equal to the number of hard links to the file. However, truenames are useful because they eliminate symbolic links as a cause of name variation. </p> <dl> <dt id="file-truename">Function: <strong>file-truename</strong> <em>filename</em>
</dt> <dd>
<p>This function returns the truename of the file <var>filename</var>. If the argument is not an absolute file name, this function first expands it against <code>default-directory</code>. </p> <p>This function does not expand environment variables. Only <code>substitute-in-file-name</code> does that. See <a href="file-name-expansion#Definition-of-substitute_002din_002dfile_002dname">Definition of substitute-in-file-name</a>. </p> <p>If you may need to follow symbolic links preceding ‘<samp>..</samp>’ appearing as a name component, call <code>file-truename</code> without prior direct or indirect calls to <code>expand-file-name</code>. Otherwise, the file name component immediately preceding ‘<samp>..</samp>’ will be simplified away before <code>file-truename</code> is called. To eliminate the need for a call to <code>expand-file-name</code>, <code>file-truename</code> handles ‘<samp>~</samp>’ in the same way that <code>expand-file-name</code> does. </p> <p>If the target of a symbolic links has remote file name syntax, <code>file-truename</code> returns it quoted. See <a href="file-name-expansion">Functions that Expand Filenames</a>. </p>
</dd>
</dl> <dl> <dt id="file-chase-links">Function: <strong>file-chase-links</strong> <em>filename &optional limit</em>
</dt> <dd>
<p>This function follows symbolic links, starting with <var>filename</var>, until it finds a file name which is not the name of a symbolic link. Then it returns that file name. This function does <em>not</em> follow symbolic links at the level of parent directories. </p> <p>If you specify a number for <var>limit</var>, then after chasing through that many links, the function just returns what it has even if that is still a symbolic link. </p>
</dd>
</dl> <p>To illustrate the difference between <code>file-chase-links</code> and <code>file-truename</code>, suppose that <samp>/usr/foo</samp> is a symbolic link to the directory <samp>/home/foo</samp>, and <samp>/home/foo/hello</samp> is an ordinary file (or at least, not a symbolic link) or nonexistent. Then we would have: </p> <div class="example"> <pre class="example">(file-chase-links "/usr/foo/hello")
;; <span class="roman">This does not follow the links in the parent directories.</span>
⇒ "/usr/foo/hello"
(file-truename "/usr/foo/hello")
;; <span class="roman">Assuming that <samp>/home</samp> is not a symbolic link.</span>
⇒ "/home/foo/hello"
</pre>
</div> <dl> <dt id="file-equal-p">Function: <strong>file-equal-p</strong> <em>file1 file2</em>
</dt> <dd><p>This function returns <code>t</code> if the files <var>file1</var> and <var>file2</var> name the same file. This is similar to comparing their truenames, except that remote file names are also handled in an appropriate manner. If <var>file1</var> or <var>file2</var> does not exist, the return value is unspecified. </p></dd>
</dl> <dl> <dt id="file-name-case-insensitive-p">Function: <strong>file-name-case-insensitive-p</strong> <em>filename</em>
</dt> <dd>
<p>Sometimes file names or their parts need to be compared as strings, in which case it’s important to know whether the underlying filesystem is case-insensitive. This function returns <code>t</code> if file <var>filename</var> is on a case-insensitive filesystem. It always returns <code>t</code> on MS-DOS and MS-Windows. On Cygwin and macOS, filesystems may or may not be case-insensitive, and the function tries to determine case-sensitivity by a runtime test. If the test is inconclusive, the function returns <code>t</code> on Cygwin and <code>nil</code> on macOS. </p> <p>Currently this function always returns <code>nil</code> on platforms other than MS-DOS, MS-Windows, Cygwin, and macOS. It does not detect case-insensitivity of mounted filesystems, such as Samba shares or NFS-mounted Windows volumes. On remote hosts, it assumes <code>t</code> for the ‘<samp>smb</samp>’ method. For all other connection methods, runtime tests are performed. </p>
</dd>
</dl> <dl> <dt id="file-in-directory-p">Function: <strong>file-in-directory-p</strong> <em>file dir</em>
</dt> <dd><p>This function returns <code>t</code> if <var>file</var> is a file in directory <var>dir</var>, or in a subdirectory of <var>dir</var>. It also returns <code>t</code> if <var>file</var> and <var>dir</var> are the same directory. It compares the truenames of the two directories. If <var>dir</var> does not name an existing directory, the return value is <code>nil</code>. </p></dd>
</dl> <dl> <dt id="vc-responsible-backend">Function: <strong>vc-responsible-backend</strong> <em>file</em>
</dt> <dd>
<p>This function determines the responsible VC backend of the given <var>file</var>. For example, if <samp>emacs.c</samp> is a file tracked by Git, <code><span class="nolinebreak">(vc-responsible-backend</span> "emacs.c")</code> returns ‘<samp>Git</samp>’. Note that if <var>file</var> is a symbolic link, <code>vc-responsible-backend</code> will not resolve it—the backend of the symbolic link file itself is reported. To get the backend VC of the file to which <var>file</var> refers, wrap <var>file</var> with a symbolic link resolving function such as <code>file-chase-links</code>: </p> <div class="example"> <pre class="example">(vc-responsible-backend (file-chase-links "emacs.c"))
</pre>
</div> </dd>
</dl><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Truenames.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Truenames.html</a>
</p>
</div>
|