BSymLink¶
Constructor and Destructor¶
BSymLink()
BSymLink::BSymLink()
BSymLink::BSymLink(const entry_ref *ref)
BSymLink::BSymLink(const BEntry *entry)
BSymLink::BSymLink(const char *path)
BSymLink::BSymLink(const BDirectory *dir, const char *path)
BSymLink::BSymLink(const BSymLink &link)
Creates a new BSymLink object, initializes it according to the
arguments, and sets InitCheck()
to return the status of
the initialization.
The default constructor does nothing and sets
InitCheck()
toB_NO_INIT
. To initialize the object, callSetTo()
.The copy constructor creates a new BSymLink that’s open on the same node as that of the argument.
For information on the other constructors, see the analogous
SetTo()
functions in theBNode
class; BSymLink inherits them without change.
~BSymLink()
virtual BSymLink::~BSymLink()
Closes the object’s file descriptor and destroys the object.
Member Functions¶
IsAbsolute()
bool BSymLink::IsAbsolute()
Returns true if the symlink contains an absolute pathname.
MakeLinkedPath()
ssize_t BSymLink::MakeLinkedPath(const BDirectory *dir, BPath *path) const
ssize_t BSymLink::MakeLinkedPath(const char *dirPath, BPath *path) const
This function creates an absolute pathname to the linked-to entry and
returns it as a BPath
object. For this to work you have to
tell the object which directory you want to reckon off of (in case the
symlink specifies a relative path). This should be the directory in which
the symlink itself lives.
Note
Remember—a BSymLink is a node, and nodes don’t know what directory they live in. That’s why you have to tell it here.
If the symlink contains an absolute path, then the dir or dirPath arguments are ignored. Nonetheless, they must be supplied.
The function returns the length of the pathname that’s set in
BPath
(or an error).
Return Code |
Description |
---|---|
|
The object is uninitialized. |
|
The object doesn’t refer to a symlink, or dir/dirPath is NULL. |
|
They concatenated pathname is too long. |
ReadLink()
ssize_t BSymLink::ReadLink(char *buf, size_t length)
Copies the contents of the symlink into buf. length is
the size of the buffer; to be perfectly safe, the buffer should be
B_PATH_NAME_LENGTH
characters long. The function returns
the number of bytes that were copied (or it returns an error).
The symlink’s contents is the pathname (relative or absolute) to the
linked-to entry. Note that since the pathname might be relative,
ReadLink() can’t give you a BPath
object. If you
want a BPath
to the linked-to entry, see
MakeLinkedPath()
.
Return Code |
Description |
---|---|
|
The object is uninitialized. |
|
The object doesn’t refer to a symlink. |