Loading...
Searching...
No Matches
Public Member Functions | List of all members
BSymLink Class Reference

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

Inherits BNode.

Public Member Functions

 BSymLink ()
 Creates an uninitialized BSymLink object.
 
 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.
 
 BSymLink (const BEntry *entry)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied BEntry.
 
 BSymLink (const BSymLink &other)
 Creates a copy of the supplied BSymLink object.
 
 BSymLink (const char *path)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied path name.
 
 BSymLink (const entry_ref *ref)
 Creates a BSymLink object and initializes it to the symbolic link referred to by the supplied entry_ref.
 
virtual ~BSymLink ()
 Destroys the object and frees all allocated resources.
 
bool IsAbsolute ()
 Returns whether or not the object refers to 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 MakeLinkedPath (const char *dirPath, 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.
 
- Public Member Functions inherited from BNode
 BNode ()
 Creates an uninitialized BNode object.
 
 BNode (const BDirectory *dir, const char *path)
 Creates a BNode object and initializes it to the entry referred to by the specified path rooted in the specified directory.
 
 BNode (const BEntry *entry)
 Creates a BNode object and initializes it to the specified filesystem entry.
 
 BNode (const BNode &node)
 Creates a copy of the given BNode.
 
 BNode (const char *path)
 Creates a BNode object and initializes it to the entry referred to by the specified path.
 
 BNode (const entry_ref *ref)
 Creates a BNode object and initializes it to the specified entry_ref.
 
virtual ~BNode ()
 Frees all resources associated with the BNode.
 
int Dup ()
 Gets the POSIX file descriptor referred to by this node.
 
virtual status_t GetStat (struct stat *st) const
 Fills in the given stat structure with the stat() information for this object.
 
status_t InitCheck () const
 Checks whether the object has been properly initialized or not.
 
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 char *path)
 Initializes the object to the specified path.
 
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.
 
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.
 
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.
 
BNodeoperator= (const BNode &node)
 Initializes the object as a copy of other.
 
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.
 
- Public Member Functions inherited from BStatable
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 *permissions) 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 *stat) const =0
 Fills out the stat structure for the node.
 
status_t GetVolume (BVolume *volume) const
 Fills out vol with the the volume that the node lives on.
 
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.
 
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 permissions)
 Sets the node's permissions to perms.
 

Detailed Description

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

Since
BeOS R3

Constructor & Destructor Documentation

◆ BSymLink() [1/6]

BSymLink::BSymLink ( )

Creates an uninitialized BSymLink object.

Since
BeOS R3

◆ BSymLink() [2/6]

BSymLink::BSymLink ( const BSymLink other)

Creates a copy of the supplied BSymLink object.

Parameters
otherThe BSymLink object to be copied.
Since
BeOS R3

◆ BSymLink() [3/6]

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.
Since
BeOS R3

◆ BSymLink() [4/6]

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.
Since
BeOS R3

◆ BSymLink() [5/6]

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.
Since
BeOS R3

◆ BSymLink() [6/6]

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.
Since
BeOS R3

◆ ~BSymLink()

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.

Since
BeOS R3

Member Function Documentation

◆ IsAbsolute()

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.

Since
BeOS R3

◆ MakeLinkedPath() [1/2]

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.
Since
BeOS R3

◆ MakeLinkedPath() [2/2]

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.
Since
BeOS R3

◆ ReadLink()

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.

This function does not return the number of bytes written into the provided buffer. It returns the length of the symlink's contents, even if that contents does not fit within the provided buffer. If the buffer cannot contain the entire contents then it will be truncated to size.

Parameters
bufferThe buffer to read the symlink's contents into.
sizeThe size of buffer.
Returns
The length of the symlink's contents 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.
Since
BeOS R3