66 lines
8.7 KiB
HTML
66 lines
8.7 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Storage Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheStorageKit_Overview.html" title="The Storage Kit" /><link rel="prev" href="BStatable_Overview.html" title="BStatable" /><link rel="next" href="BVolume_Overview.html" title="BVolume" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BStatable_Overview.html" title="BStatable"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BVolume_Overview.html" title="BVolume"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Storage Kit</div></div><div id="headerB">Prev: <a href="BStatable_Overview.html">BStatable</a> Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a> Next: <a href="BVolume_Overview.html">BVolume</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSymLink_Overview"></a>BSymLink</h2></div></div></div><a id="id614775" class="indexterm"></a><p>
|
||
A "symbolic link" or symlink is a file that "points to" some other entry.
|
||
The pointed-to (or, better, "linked-to") entry can be a plain file,
|
||
directory, or another symlink (which links to yet another entry, and so
|
||
on). Furthermore, the entry can be abstract—you can create a
|
||
symlink to an entry that doesn't exist.
|
||
</p><p>
|
||
The data in a symlink is the pathname to the linked-to entry. The
|
||
pathname can be absolute or relative. If it's relative, the linked-to
|
||
entry is found by reckoning the pathname of off the directory in which
|
||
the symlink lives. Relative pathnames can contain "." and ".." components.
|
||
</p><p>
|
||
The thing to keep in mind, when dealing with symlinks, is that they link
|
||
to entries, not nodes. If you link a symlink to an (existing) entry named
|
||
<code class="filename">/boot/home/fido</code> and then the user moves fido to rover (or deletes
|
||
fido), the symlink is not updated. It will still link to
|
||
<code class="filename">/boot/home/fido</code>.
|
||
</p><p>
|
||
Furthermore, symlinks that contain relative pathnames have a further
|
||
"problem": Let's say you create a symlink in
|
||
<code class="filename">/boot/home</code> that links to
|
||
<code class="filename">fido</code>. If you move the symlink to some other directory, it will link to
|
||
the entry named <code class="filename">fido</code> in the new directory.
|
||
</p><p>
|
||
The <code class="classname">BSymLink</code> class creates objects that know how to read a symlink's
|
||
data. The class does not create new symlinks; to create a symlink, you
|
||
use <a class="link" href="BDirectory.html" title="BDirectory"><code class="classname">BDirectory</code></a>'s
|
||
<a class="link" href="BDirectory.html#BDirectory_CreateSymLink"><code class="methodname">CreateSymLink()</code></a> function.
|
||
</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p><code class="classname">BSymLink</code> objects are no smarter than the symlinks files themselves. For
|
||
example, <code class="classname">BSymLinks</code> can't resolve the fido/rover "problem".</p></div></div></div><p>
|
||
The only really useful <code class="classname">BSymLink</code> function is
|
||
<a class="link" href="BSymLink.html#BSymLink_ReadLink" title="ReadLink()"><code class="methodname">ReadLink()</code></a>. This function
|
||
returns the data that the symlink contains. The other functions are
|
||
convenient, but they're not essential.
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id614901"></a>Initialization and File Descriptors</h3></div></div></div><p>
|
||
When you initialize a <code class="classname">BSymLink</code> object, you pass in a pathname or
|
||
<span class="type">entry_ref</span> (or whatever) that refers to an existing symlink. The <code class="classname">BSymLink</code>
|
||
object then represents that symlink—it doesn't represent the (node
|
||
of the) linked-to entry. Furthermore, you can't ask a <code class="classname">BSymLink</code> to
|
||
"resolve itself"—it can't pass you back a
|
||
<a class="link" href="BEntry.html" title="BEntry"><code class="classname">BEntry</code></a> object that
|
||
represents the linked-to entry.
|
||
</p><p>
|
||
If you want the <a class="link" href="BEntry.html" title="BEntry"><code class="classname">BEntry</code></a>
|
||
of the linked-to entry, simply initialize a
|
||
<a class="link" href="BEntry.html" title="BEntry"><code class="classname">BEntry</code></a>
|
||
object with the ref (or whatever) to the symlink and tell it to traverse
|
||
(set the trailing argument to <code class="constant">true</code>).
|
||
</p><p>
|
||
For example, in the following code, <code class="varname">link</code> is a <code class="classname">BSymLink</code> to the symlink
|
||
<code class="filename">/boot/home/fidoLink</code> and <code class="varname">entry</code> is a
|
||
<a class="link" href="BEntry.html" title="BEntry"><code class="classname">BEntry</code></a> to the entry that the symlink
|
||
links-to:
|
||
</p><pre class="programlisting example cpp"><code class="classname">BSymLink</code> <code class="varname">link</code>("/boot/home/fidoLink");
|
||
<code class="classname">BEntry</code> <code class="varname">entry</code>("/boot/home/fidoLink", <code class="constant">true</code>);</pre><p>
|
||
Like all nodes, <code class="classname">BSymLink</code> allocates a file descriptor. Remember, this is a
|
||
file descriptor that's open on the symlink node itself, not the (node of
|
||
the) linked-to entry.
|
||
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BStatable_Overview.html">BStatable</a> Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a> Next: <a href="BVolume_Overview.html">BVolume</a> </div><div id="footerB"><div id="footerBL"><a href="BStatable_Overview.html" title="BStatable"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BVolume_Overview.html" title="BVolume"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|