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.
| Class Overview |
BSymLink();
BSymLink(const entry_ref* ref);
BSymLink(const BEntry
* entry);
BSymLink(const char* path);
BSymLink(const BDirectory
* dir,
const char* path);
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()
to
B_NO_INIT
. To initialize the object, call
SetTo()
.
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 the
BNode
class;
BSymLink
inherits them without change.
ssize_t MakeLinkedPath(const BDirectory
* dir,
BPath
* path) const;
ssize_t 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.
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
|
| They concatenated pathname is too long. |
ssize_t 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. |