Public Member Functions
BSymLink Class Reference

Provides an interface for creating, manipulating, and accessing the contents of symbolic links. More...

Inheritance diagram for BSymLink:
BNode BStatable

List of all members.

Public Member Functions

 BSymLink ()
 Creates an uninitialized BSymLink object.
 BSymLink (const BSymLink &link)
 Creates a copy of the supplied BSymLink object.
 BSymLink (const entry_ref *ref)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied entry_ref.
 BSymLink (const BEntry *entry)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied BEntry.
 BSymLink (const char *path)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied path name.
 BSymLink (const BDirectory *dir, const char *path)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied path name relative to the specified BDirectory.
virtual ~BSymLink ()
 Destroys the object and frees all allocated resources.
int Dup ()
 Gets the POSIX file descriptor referred to by this node.
status_t GetAccessTime (time_t *atime) const
 Fills out atime with the access time of the node.
status_t GetCreationTime (time_t *ctime) const
 Fills out ctime with the creation time of the node.
status_t GetGroup (gid_t *group) const
 Fills out the node's GID into group.
status_t GetModificationTime (time_t *mtime) const
 Fills out mtime with the last modification time of the node.
status_t GetNodeRef (node_ref *ref) const
 Fills out ref with the node_ref of the node.
status_t GetOwner (uid_t *owner) const
 Fills out the node's UID into owner.
status_t GetPermissions (mode_t *perms) const
 Fills out perms with the permissions of the node.
status_t GetSize (off_t *size) const
 Fills out the size of the node's data (not counting attributes) into size.
virtual status_t GetStat (struct stat *st) const
 Fills in the given stat structure with the stat() information for this object.
status_t GetVolume (BVolume *vol) const
 Fills out vol with the the volume that the node lives on.
status_t InitCheck () const
 Checks whether the object has been properly initialized or not.
bool IsAbsolute ()
 Returns whether or not the object refers to an absolute path.
bool IsDirectory () const
 Returns whether or not the node is a directory.
bool IsFile () const
 Returns whether or not the node is a file.
bool IsSymLink () const
 Returns whether or not the node is a symbolic link.
ssize_t MakeLinkedPath (const char *dirPath, BPath *path)
 Combines a directory path and the contents of this symbolic link to form an absolute path.
ssize_t MakeLinkedPath (const BDirectory *dir, BPath *path)
 Combines a directory path and the contents of this symbolic link to form an absolute path.
ssize_t ReadLink (char *buf, size_t size)
 Reads the contents of the symbolic link into buffer.
status_t SetAccessTime (time_t atime)
 Sets the node's access time to atime.
status_t SetCreationTime (time_t ctime)
 Sets the node's creation time to ctime.
status_t SetGroup (gid_t group)
 Sets the node's GID to group.
status_t SetModificationTime (time_t mtime)
 Sets the node's last modification time to mtime.
status_t SetOwner (uid_t owner)
 Sets the node's UID to owner.
status_t SetPermissions (mode_t perms)
 Sets the node's permissions to perms.
Assignment Methods
status_t SetTo (const entry_ref *ref)
 Initializes the object to the specified entry_ref.
status_t SetTo (const BEntry *entry)
 Initializes the object to the specified filesystem entry.
status_t SetTo (const BDirectory *dir, const char *path)
 Initializes the object to the entry referred by the specified path relative to the the specified directory.
void Unset ()
 Returns the object to an uninitialized state.
Locking Methods
status_t Lock ()
 Attains an exclusive lock on the data referred to by this node so that it may not be modified by any other objects or methods.
status_t Unlock ()
 Unlocks the date referred to by this node.
status_t Sync ()
 Immediately performs any pending disk actions on the node.
Attribute Methods
ssize_t WriteAttr (const char *name, type_code type, off_t offset, const void *buffer, size_t length)
 Writes data from a buffer to an attribute.
ssize_t ReadAttr (const char *name, type_code type, off_t offset, void *buffer, size_t length) const
 Reads data from an attribute into buffer.
status_t RemoveAttr (const char *name)
 Deletes the attribute given by name.
status_t RenameAttr (const char *oldName, const char *newName)
 Moves the attribute given by oldname to newname.
status_t GetAttrInfo (const char *name, struct attr_info *info) const
 Fills in the pre-allocated attr_info struct pointed to by info with information about the attribute specified by name.
status_t GetNextAttrName (char *buffer)
 Copies the name of the attribute into buffer and then advances the pointer to the next attribute.
status_t RewindAttrs ()
 Resets the object's attribute pointer to the first attribute in the list.
status_t WriteAttrString (const char *name, const BString *data)
 Writes the specified string to the specified attribute, clobbering any previous data.
status_t ReadAttrString (const char *name, BString *result) const
 Reads the data of the specified attribute into the pre-allocated result.
Comparison Methods
bool operator== (const BNode &node) const
 Tests whether this and the supplied BNode object are equal.
bool operator!= (const BNode &node) const
 Tests whether this and the supplied BNode object are not equal.

Detailed Description

Provides an interface for creating, manipulating, and accessing the contents of symbolic links.


Constructor & Destructor Documentation

BSymLink::BSymLink ( const BSymLink link)

Creates a copy of the supplied BSymLink object.

Parameters:
linkThe BSymLink object to be copied.
BSymLink::BSymLink ( const entry_ref ref)

Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied entry_ref.

Parameters:
refthe entry_ref referring to the symbolic link.
BSymLink::BSymLink ( const BEntry entry)

Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied BEntry.

Parameters:
entryThe BEntry referring to the symbolic link.
BSymLink::BSymLink ( const char *  path)

Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied path name.

Parameters:
pathThe path of the symbolic link.
BSymLink::BSymLink ( const BDirectory dir,
const char *  path 
)

Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied path name relative to the specified BDirectory.

Parameters:
dirThe base BDirectory.
pathThe path of the symbolic link relative to dir.
BSymLink::~BSymLink ( ) [virtual]

Destroys the object and frees all allocated resources.

If the BSymLink was properly initialized, the file descriptor of the symbolic link is also closed.


Member Function Documentation

int BNode::Dup ( ) [inherited]

Gets the POSIX file descriptor referred to by this node.

Remember to call close() on the file descriptor when you're through with it.

Returns:
a valid file descriptor, or -1 if something went wrong.
status_t BStatable::GetAccessTime ( time_t *  atime) const [inherited]

Fills out atime with the access time of the node.

See also:
GetModificationTime()
GetStat() for return codes.
status_t BNode::GetAttrInfo ( const char *  name,
struct attr_info *  info 
) const [inherited]

Fills in the pre-allocated attr_info struct pointed to by info with information about the attribute specified by name.

Parameters:
namethe name of the attribute
infothe attr_info structure to be filled in
Return values:
B_OKEverything went fine.
B_BAD_VALUEname is NULL.
B_FILE_ERRORThe object is not initialized.
B_ENTRY_NOT_FOUNDThe node has no attribute name.
status_t BStatable::GetCreationTime ( time_t *  ctime) const [inherited]

Fills out ctime with the creation time of the node.

Parameters:
ctimeA pointer to a time_t variable to be set.
See also:
GetStat() for return codes.
status_t BStatable::GetGroup ( gid_t *  group) const [inherited]

Fills out the node's GID into group.

Parameters:
groupa pointer to a gid_t variable to be set.
See also:
GetStat() for return codes.
status_t BStatable::GetModificationTime ( time_t *  mtime) const [inherited]

Fills out mtime with the last modification time of the node.

Parameters:
mtimeA pointer to a time_t variable to be set.
See also:
GetStat() for return codes.
status_t BNode::GetNextAttrName ( char *  buffer) [inherited]

Copies the name of the attribute into buffer and then advances the pointer to the next attribute.

The name of the node is first copied into buffer, which should be at least B_ATTR_NAME_LENGTH characters long. The copied node name is NUL terminated. Once the name is copied the attribute list pointer is advanced to the next attribute in the list. When GetNextAttrName() reaches the end of the list it returns B_ENTRY_NOT_FOUND.

Parameters:
bufferA buffer to copy the name of the attribute into.
Return values:
B_OKThe Attribute name was copied and there are more attribute names to copy.
B_BAD_VALUEpassed in buffer is NULL.
B_FILE_ERRORThe object is not initialized.
B_ENTRY_NOT_FOUNDThere are no more attributes, the last attribute name has already been copied.
status_t BStatable::GetNodeRef ( node_ref ref) const [inherited]

Fills out ref with the node_ref of the node.

Parameters:
refthe node_ref to be set.
See also:
GetStat() for return codes.
status_t BStatable::GetOwner ( uid_t *  owner) const [inherited]

Fills out the node's UID into owner.

Parameters:
ownerA pointer to a uid_t to be set.
See also:
GetStat() for return codes.
status_t BStatable::GetPermissions ( mode_t *  perms) const [inherited]

Fills out perms with the permissions of the node.

Parameters:
permsA pointer to a mode_t variable to be set.
See also:
GetStat() for return codes.
status_t BStatable::GetSize ( off_t *  size) const [inherited]

Fills out the size of the node's data (not counting attributes) into size.

Parameters:
sizeA pointer to a off_t variable to be set.
See also:
GetStat() for return codes.

Reimplemented in BFile.

status_t BNode::GetStat ( struct stat *  st) const [virtual, inherited]

Fills in the given stat structure with the stat() information for this object.

Parameters:
sta pointer to a stat structure to be filled in.
Return values:
B_OKEverything went fine.
B_BAD_VALUE,:NULL st.

Implements BStatable.

status_t BStatable::GetVolume ( BVolume vol) const [inherited]

Fills out vol with the the volume that the node lives on.

Parameters:
volA pointer to a BVolume object to be set.
See also:
BVolume
GetStat() for return codes.
status_t BNode::InitCheck ( ) const [inherited]

Checks whether the object has been properly initialized or not.

Returns:
B_OK if the object has been properly initialized, or an error code otherwise.
bool BSymLink::IsAbsolute ( )

Returns whether or not the object refers to an absolute path.

/return true if the object is properly initialized and the symbolic link refers to an absolute path, false otherwise.

bool BStatable::IsDirectory ( ) const [inherited]

Returns whether or not the node is a directory.

Returns:
true, if the node is properly initialized and is a directory, false otherwise.
bool BStatable::IsFile ( ) const [inherited]

Returns whether or not the node is a file.

Returns:
true, if the node is properly initialized and is a file, false otherwise.
bool BStatable::IsSymLink ( ) const [inherited]

Returns whether or not the node is a symbolic link.

Returns:
true, if the node is properly initialized and is a symlink, false otherwise.
status_t BNode::Lock ( ) [inherited]

Attains an exclusive lock on the data referred to by this node so that it may not be modified by any other objects or methods.

Return values:
B_OKEverything went fine.
B_FILE_ERRORThe object is not initialized.
B_BUSYThe node is already locked.
ssize_t BSymLink::MakeLinkedPath ( const char *  dirPath,
BPath path 
)

Combines a directory path and the contents of this symbolic link to form an absolute path.

Parameters:
dirPathThe base directory path to combine with the symbolic link.
pathThe BPath object to be set to the resulting absolute path.
Returns:
The length of the resulting path name or an error code.
Return values:
B_BAD_VALUEdirPath or path was NULL or the object didn't refer to a symbolic link.
B_FILE_ERRORThe object was not initialized.
B_NAME_TOO_LONGThe resulting path name was too long to fit.
ssize_t BSymLink::MakeLinkedPath ( const BDirectory dir,
BPath path 
)

Combines a directory path and the contents of this symbolic link to form an absolute path.

Parameters:
dirThe base BDirectory object to combine with the symbolic link.
paththe BPath object to be set to the resulting absolute path.
Returns:
The length of the resulting path name or an error code.
Return values:
B_BAD_VALUEdir or path was NULL or the object didn't refer to a symbolic link.
B_FILE_ERRORThe object was not initialized.
B_NAME_TOO_LONGThe resulting path name was too long to fit.
bool BNode::operator!= ( const BNode node) const [inherited]

Tests whether this and the supplied BNode object are not equal.

Two BNode objects are said to be equal if they're set to the same node, or if they're both B_NO_INIT.

Parameters:
nodethe BNode to be compared with
Returns:
false, if the BNode objects are equal, true otherwise.
bool BNode::operator== ( const BNode node) const [inherited]

Tests whether this and the supplied BNode object are equal.

Two BNode objects are said to be equal if they're set to the same node, or if they're both B_NO_INIT.

Parameters:
nodethe BNode to be compared with.
Returns:
true, if the BNode objects are equal, false otherwise.
ssize_t BNode::ReadAttr ( const char *  attr,
type_code  type,
off_t  offset,
void *  buffer,
size_t  len 
) const [inherited]

Reads data from an attribute into buffer.

Reads len bytes of data from the attribute given by name into buffer. type and offset are currently ignored.

Parameters:
attrthe name of the attribute.
typethe type of the attribute (currently ignored).
offsetthe index from which to read the data (currently ignored).
bufferthe buffer for the data to be read.
lenthe number of bytes to be read.
Returns:
the number of bytes actually read
Return values:
B_BAD_VALUEattr or buffer is NULL.
B_FILE_ERRORThe object is not initialized.
B_ENTRY_NOT_FOUNDThe node has no attribute attr.
status_t BNode::ReadAttrString ( const char *  name,
BString result 
) const [inherited]

Reads the data of the specified attribute into the pre-allocated result.

Parameters:
namethe name of the attribute.
resultthe BString to be set to the value of the attribute.
Return values:
B_OKEverything went fine.
B_BAD_VALUEname or result is NULL.
B_FILE_ERRORThe object is not initialized.
B_ENTRY_NOT_FOUNDThe node has no attribute attr.
ssize_t BSymLink::ReadLink ( char *  buffer,
size_t  size 
)

Reads the contents of the symbolic link into buffer.

The string written to the buffer is guaranteed to be NULL terminated.

Parameters:
bufferThe buffer to read the symlink's contents into.
sizeThe size of buffer.
Returns:
The number of bytes written into the buffer or an error code.
Return values:
B_BAD_VALUEbuf was NULL or the object didn't refer to a symbolic link.
B_FILE_ERRORThe object was not initialized.
status_t BNode::RemoveAttr ( const char *  name) [inherited]

Deletes the attribute given by name.

Parameters:
namethe name of the attribute to remove.
Return values:
B_OKEverything went fine.
B_BAD_VALUEname is NULL.
B_FILE_ERRORThe object is not initialized or the node it refers to read only.
B_ENTRY_NOT_FOUNDThe node has no attribute name.
B_NOT_ALLOWEDThe node resides on a read only volume.
status_t BNode::RenameAttr ( const char *  oldname,
const char *  newname 
) [inherited]

Moves the attribute given by oldname to newname.

If newname already exists, the data is clobbered.

Parameters:
oldnamethe name of the attribute to be renamed.
newnamethe new name for the attribute.
Return values:
B_OKEverything went fine.
B_BAD_VALUEoldname or newname is NULL.
B_FILE_ERRORThe object is not initialized or the node it refers to is read only.
B_ENTRY_NOT_FOUNDThe node has no attribute oldname.
B_NOT_ALLOWEDThe node resides on a read only volume.
status_t BNode::RewindAttrs ( ) [inherited]

Resets the object's attribute pointer to the first attribute in the list.

Return values:
B_OKEverything went fine.
B_FILE_ERRORSome other error occurred.
status_t BStatable::SetAccessTime ( time_t  atime) [inherited]

Sets the node's access time to atime.

See also:
GetModificationTime()
GetStat() for return codes.
status_t BStatable::SetCreationTime ( time_t  ctime) [inherited]

Sets the node's creation time to ctime.

Parameters:
ctimeThe creation time to set the node to.
See also:
GetStat() for return codes.
status_t BStatable::SetGroup ( gid_t  group) [inherited]

Sets the node's GID to group.

Parameters:
groupThe GID to set the node to.
See also:
GetStat() for return codes.
status_t BStatable::SetModificationTime ( time_t  mtime) [inherited]

Sets the node's last modification time to mtime.

Parameters:
mtimeThe modification time to set the node to.
See also:
GetStat() for return codes.
status_t BStatable::SetOwner ( uid_t  owner) [inherited]

Sets the node's UID to owner.

Parameters:
ownerThe UID to set the node to.
See also:
GetStat() for return codes.
status_t BStatable::SetPermissions ( mode_t  perms) [inherited]

Sets the node's permissions to perms.

Parameters:
permsThe permissions to set the node to.
See also:
GetStat() for return codes.
status_t BNode::SetTo ( const entry_ref ref) [inherited]

Initializes the object to the specified entry_ref.

Parameters:
refthe entry_ref referring to the entry.
Return values:
B_OK,:Everything went fine.
B_BAD_VALUE,:NULL ref.
B_ENTRY_NOT_FOUND,:The entry could not be found.
B_BUSY,:The entry is locked.

Reimplemented in BDirectory.

status_t BNode::SetTo ( const BEntry entry) [inherited]

Initializes the object to the specified filesystem entry.

Parameters:
entrythe BEntry representing the entry.
Return values:
B_OKEverything went fine.
B_BAD_VALUENULL entry.
B_ENTRY_NOT_FOUNDThe entry could not be found.
B_BUSYThe entry is locked.

Reimplemented in BDirectory.

status_t BNode::SetTo ( const BDirectory dir,
const char *  path 
) [inherited]

Initializes the object to the entry referred by the specified path relative to the the specified directory.

Parameters:
dirthe base BDirectory.
paththe entry's path name relative to dir
Return values:
B_OKEverything went fine.
B_BAD_VALUENULL entry.
B_ENTRY_NOT_FOUNDThe entry could not be found.
B_BUSYThe entry is locked.

Reimplemented in BDirectory.

status_t BNode::Sync ( ) [inherited]

Immediately performs any pending disk actions on the node.

Return values:
B_OKEverything went fine.
B_FILE_ERRORSomething went wrong.
status_t BNode::Unlock ( ) [inherited]

Unlocks the date referred to by this node.

Return values:
B_OKEverything went fine.
B_FILE_ERRORThe object is not initialized.
B_BAD_VALUEThe node is not locked.
ssize_t BNode::WriteAttr ( const char *  attr,
type_code  type,
off_t  offset,
const void *  buffer,
size_t  len 
) [inherited]

Writes data from a buffer to an attribute.

Write len bytes of data from buffer to the attribute specified by name after erasing any data that existed previously. The type specified by type is remembered, and may be queried with GetAttrInfo(). The value of offset is currently ignored.

Parameters:
attrthe name of the attribute.
typethe type of the attribute.
offsetthe index at which to write the data (currently ignored).
bufferthe buffer containing the data to be written.
lenthe number of bytes to be written.
Returns:
the number of bytes actually written.
Return values:
B_BAD_VALUEattr or buffer is NULL.
B_FILE_ERRORThe object is not initialized or the node it refers to is read only.
B_NOT_ALLOWEDThe node resides on a read only volume.
B_DEVICE_FULLInsufficient disk space.
B_NO_MEMORYInsufficient memory to complete the operation.
status_t BNode::WriteAttrString ( const char *  name,
const BString data 
) [inherited]

Writes the specified string to the specified attribute, clobbering any previous data.

Parameters:
namethe name of the attribute.
datathe BString to be written to the attribute.
Return values:
B_OKEverything went fine.
B_BAD_VALUENULL name or data
B_FILE_ERRORThe object is not initialized or the node it refers to is read only.
B_NOT_ALLOWEDThe node resides on a read only volume.
B_DEVICE_FULLInsufficient disk space.
B_NO_MEMORYInsufficient memory to complete the operation.

The Haiku Book pre-R1 - BSymLink Class Reference
Generated on Sat May 25 2013 by Doxygen 1.7.5.1