2011-10-30 02:02:52 +04:00
|
|
|
/*
|
2014-06-19 03:10:45 +04:00
|
|
|
* Copyright 2002-2014 Haiku, Inc. All rights reserved.
|
2011-10-30 02:02:52 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
* Ingo Weinhold, bonefish@users.sf.net
|
2013-02-07 06:05:00 +04:00
|
|
|
*
|
2011-10-30 02:02:52 +04:00
|
|
|
* Corresponds to:
|
2014-06-19 03:10:45 +04:00
|
|
|
* headers/os/storage/Node.h hrev47402
|
|
|
|
* src/kits/storage/Node.cpp hrev47402
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file Node.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup storage
|
|
|
|
\ingroup libbe
|
2014-06-19 03:10:45 +04:00
|
|
|
\brief Provides the BNode class and node_ref struct.
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\struct node_ref
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup storage
|
|
|
|
\ingroup libbe
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Reference structure to a particular vnode on a device.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn node_ref::node_ref()
|
|
|
|
\brief Creates an uninitialized node_ref object.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn node_ref::node_ref(const node_ref& other)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a copy of the given node_ref object.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other the node_ref to be copied.
|
|
|
|
|
|
|
|
\since BeOS R3
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\name Operators
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
2011-10-30 02:02:52 +04:00
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn bool node_ref::operator==(const node_ref& other) const
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Tests whether this node_ref and the supplied one are equal.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other The node_ref to be compared against.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
|
|
|
\return \c true, if the objects are equal, \c false otherwise.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn bool node_ref::operator!=(const node_ref& other) const
|
|
|
|
\brief Tests whether this node_ref and the supplied one are NOT equal.
|
|
|
|
|
|
|
|
\param other The node_ref to be compared against.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c true, if the objects are \b NOT equal, \c false otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn bool node_ref::operator<(const node_ref& other) const
|
|
|
|
\brief Tests whether this node_ref is less than the supplied one.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other The node_ref to be compared against.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c true, if this node_ref is less than \a other,
|
|
|
|
\c false otherwise.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn node_ref& node_ref::operator=(const node_ref& other)
|
|
|
|
\brief Makes this node ref a copy of the supplied one.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other The node_ref to be copied.
|
|
|
|
|
|
|
|
\return A reference to this object.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
2011-10-30 02:02:52 +04:00
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\var node_ref::device
|
|
|
|
\brief The device number on which the node is located.
|
2013-02-07 06:05:00 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\var node_ref::node
|
|
|
|
\brief The node's inode number.
|
2013-02-07 06:05:00 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\class BNode
|
|
|
|
\ingroup storage
|
|
|
|
\ingroup libbe
|
|
|
|
\brief A BNode represents a chunk of data in the filesystem.
|
|
|
|
|
|
|
|
The BNode class provides an interface for manipulating the data and
|
|
|
|
attributes belonging to filesystem entries. The BNode is unaware of the
|
|
|
|
name that refers to it in the filesystem (i.e. its entry), instead, a
|
|
|
|
BNode is concerned solely with the entry's data and attributes.
|
2013-02-07 06:05:00 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BNode::BNode()
|
|
|
|
\brief Creates an uninitialized BNode object.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\see SetTo()
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode::BNode(const entry_ref* ref)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a BNode object and initializes it to the specified
|
2014-06-19 03:10:45 +04:00
|
|
|
entry_ref.
|
|
|
|
|
|
|
|
\param ref The entry_ref referring to the node.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode::BNode(const BEntry* entry)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a BNode object and initializes it to the specified
|
2014-06-19 03:10:45 +04:00
|
|
|
filesystem entry.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param entry The BEntry referring to the node.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode::BNode(const char* path)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a BNode object and initializes it to the entry referred
|
2014-06-19 03:10:45 +04:00
|
|
|
to by the specified path.
|
|
|
|
|
|
|
|
\param path The \a path referring to the node.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode::BNode(const BDirectory* dir, const char* path)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a BNode object and initializes it to the entry referred
|
2014-06-19 03:10:45 +04:00
|
|
|
to by the specified path rooted in the specified directory.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param dir The base BDirectory.
|
|
|
|
\param path The \a path name relative to \a dir.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode::BNode(const BNode& other)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Creates a copy of the given BNode.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other The BNode to be copied.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BNode::~BNode()
|
|
|
|
\brief Frees all resources associated with the BNode.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::GetStat(struct stat* stat) const
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Fills in the given stat structure with the <tt>stat()</tt>
|
2014-06-19 03:10:45 +04:00
|
|
|
information for this object.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param stat A pointer to a stat structure to be filled in.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE: \c NULL \a stat.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int BNode::Dup()
|
|
|
|
\brief Gets the POSIX file descriptor referred to by this node.
|
|
|
|
|
|
|
|
Remember to call close() on the file descriptor when you're through
|
|
|
|
with it.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\returns A valid file descriptor, or -1 if something went wrong.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\name Constructor Helpers
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::InitCheck() const
|
|
|
|
\brief Checks whether the object has been properly initialized or not.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\returns \c B_OK if the object has been properly initialized, or
|
|
|
|
\c B_NO_INIT otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::SetTo(const entry_ref* ref)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Initializes the object to the specified entry_ref.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param ref The entry_ref referring to the entry.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK: Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE: \a ref was \c NULL.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_ENTRY_NOT_FOUND: The entry could not be found.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BUSY: The entry was locked.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::SetTo(const BEntry* entry)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Initializes the object to the specified filesystem \a entry.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param entry The BEntry representing the entry.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a entry was \c NULL.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The \a entry could not be found.
|
|
|
|
\retval B_BUSY The \a entry was locked.
|
|
|
|
|
|
|
|
\since BeOS R3
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BNode::SetTo(const char* path)
|
|
|
|
\brief Initializes the object to the specified \a path.
|
|
|
|
|
|
|
|
\param path The entry's path name; \a path can be relative or absolute,
|
|
|
|
and can contain "." and ".." elements. If path is relative, it uses
|
|
|
|
the current working directory as the base directory.
|
|
|
|
|
|
|
|
\return \c B_OK on success or an error code otherwise.
|
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_BAD_VALUE \a path was \c NULL.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_ENTRY_NOT_FOUND The entry could not be found.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BUSY The entry of was locked.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::SetTo(const BDirectory* dir, const char* path)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Initializes the object to the entry referred by the
|
2014-06-19 03:10:45 +04:00
|
|
|
specified \a path relative to the the specified directory.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param dir The base BDirectory.
|
|
|
|
\param path The path name relative to \a dir.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a dir was \c NULL.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_ENTRY_NOT_FOUND The entry could not be found.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BUSY The entry was locked.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BNode::Unset()
|
|
|
|
\brief Returns the object to an uninitialized state.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\name Locking Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BNode::Lock()
|
|
|
|
\brief Attains an exclusive lock on the data referred to by this node
|
2014-06-19 03:10:45 +04:00
|
|
|
so that it may not be modified by any other objects or methods.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_FILE_ERROR The object is not initialized.
|
|
|
|
\retval B_BUSY The node is already locked.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BNode::Unlock()
|
|
|
|
\brief Unlocks the date referred to by this node.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_FILE_ERROR The object is not initialized.
|
|
|
|
\retval B_BAD_VALUE The node is not locked.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BNode::Sync()
|
|
|
|
\brief Immediately performs any pending disk actions on the node.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_FILE_ERROR Something went wrong.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\name Attribute Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn ssize_t BNode::WriteAttr(const char* attr, type_code type,
|
|
|
|
off_t offset, const void* buffer, size_t length)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Writes data from a buffer to an attribute.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
Write \a length bytes of data from \a buffer to the attribute specified
|
2011-10-30 02:02:52 +04:00
|
|
|
by \a name after erasing any data that existed previously. The type
|
|
|
|
specified by \a type \em is remembered, and may be queried with
|
|
|
|
GetAttrInfo(). The value of \a offset is currently ignored.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param attr The name of the attribute.
|
|
|
|
\param type The type of the attribute.
|
|
|
|
\param offset The index at which to write the data (currently ignored).
|
|
|
|
\param buffer The buffer containing the data to be written.
|
|
|
|
\param length The number of bytes to be written.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return The number of bytes actually written.
|
|
|
|
\retval B_BAD_VALUE \a attr or \a buffer was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized or the node it refers
|
|
|
|
to was read only.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_NOT_ALLOWED The node resides on a read only volume.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_DEVICE_FULL There was insufficient disk space to complete the
|
|
|
|
operation.
|
|
|
|
\retval B_NO_MEMORY There was insufficient memory to complete the
|
|
|
|
operation.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn ssize_t BNode::ReadAttr(const char* attr, type_code type,
|
|
|
|
off_t offset, void* buffer, size_t length) const
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Reads data from an attribute into \a buffer.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
Reads \a length bytes of data from the attribute given by \a name into
|
2011-10-30 02:02:52 +04:00
|
|
|
\a buffer. \a type and \a offset are currently ignored.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param attr The name of the attribute.
|
|
|
|
\param type The type of the attribute (currently ignored).
|
|
|
|
\param offset The index from which to read the data (currently ignored).
|
|
|
|
\param buffer The buffer for the data to be read.
|
|
|
|
\param length The number of bytes to be read.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return The number of bytes actually read.
|
|
|
|
\retval B_BAD_VALUE \a attr or \a buffer was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The node had no attribute \a attr.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::RemoveAttr(const char* name)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Deletes the attribute given by \a name.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param name The name of the attribute to remove.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a name was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized or the node it
|
|
|
|
referred to was read-only.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The node had no attribute \a name.
|
|
|
|
\retval B_NOT_ALLOWED The node resided on a read-only volume.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::RenameAttr(const char* oldName, const char* newName)
|
|
|
|
\brief Moves the attribute given by \a oldName to \a newName.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
If \a newName already exists, the data is clobbered.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param oldName The name of the attribute to be renamed.
|
|
|
|
\param newName The new name for the attribute.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a oldName or \a newName was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized or the node it
|
|
|
|
referred to was read only.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The node had no attribute \a oldName.
|
|
|
|
\retval B_NOT_ALLOWED The node resided on a read-only volume.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::GetAttrInfo(const char* name,
|
|
|
|
struct attr_info* info) const
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Fills in the pre-allocated attr_info struct pointed to by \a info
|
2014-06-19 03:10:45 +04:00
|
|
|
with information about the attribute specified by \a name.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param name The name of the attribute.
|
|
|
|
\param info The attr_info structure to be filled in.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a name was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The node had no attribute \a name.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::GetNextAttrName(char* buffer)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Copies the name of the attribute into \c buffer and then advances
|
2014-06-19 03:10:45 +04:00
|
|
|
the pointer to the next attribute.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
|
|
|
The name of the node is first copied into \a buffer, which should be at
|
|
|
|
least \c B_ATTR_NAME_LENGTH characters long. The copied node name is
|
2014-06-19 03:10:45 +04:00
|
|
|
\0 terminated. Once the name is copied the attribute list pointer
|
2011-10-30 02:02:52 +04:00
|
|
|
is advanced to the next attribute in the list. When GetNextAttrName()
|
|
|
|
reaches the end of the list it returns \c B_ENTRY_NOT_FOUND.
|
|
|
|
|
|
|
|
\param buffer A buffer to copy the name of the attribute into.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK The Attribute name was copied and there are more attribute
|
2014-06-19 03:10:45 +04:00
|
|
|
names to copy.
|
|
|
|
\retval B_BAD_VALUE passed in \a buffer was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_ENTRY_NOT_FOUND There were no more attributes, the last attribute
|
|
|
|
name had already been copied.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BNode::RewindAttrs()
|
|
|
|
\brief Resets the object's attribute pointer to the first attribute in the
|
2014-06-19 03:10:45 +04:00
|
|
|
list.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_FILE_ERROR Some other error occurred.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::WriteAttrString(const char* name, const BString* data)
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Writes the specified string to the specified attribute, clobbering
|
2014-06-19 03:10:45 +04:00
|
|
|
any previous data.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
|
|
|
\param name the name of the attribute.
|
|
|
|
\param data the BString to be written to the attribute.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a name or \a data was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized or the node it
|
|
|
|
referred to was read-only.
|
|
|
|
\retval B_NOT_ALLOWED The node resided on a read-only volume.
|
|
|
|
\retval B_DEVICE_FULL There was insufficient disk space to complete the
|
|
|
|
operation.
|
|
|
|
\retval B_NO_MEMORY There was insufficient memory to complete the
|
|
|
|
operation.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn status_t BNode::ReadAttrString(const char* name, BString* result) const
|
2011-10-30 02:02:52 +04:00
|
|
|
\brief Reads the data of the specified attribute into the pre-allocated
|
2014-06-19 03:10:45 +04:00
|
|
|
\a result.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
|
|
|
\param name the name of the attribute.
|
|
|
|
\param result the BString to be set to the value of the attribute.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c B_OK on success or an error code otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
\retval B_OK Everything went fine.
|
2014-06-19 03:10:45 +04:00
|
|
|
\retval B_BAD_VALUE \a name or \a result was \c NULL.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_ENTRY_NOT_FOUND The node had no attribute \a attr.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since Haiku R1
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\name Operators
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BNode& BNode::operator=(const BNode& other)
|
|
|
|
\brief Initializes the object as a copy of \a other.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other the BNode to be copied.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\returns A reference to this BNode object.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn bool BNode::operator==(const BNode &node) const
|
|
|
|
\brief Tests whether this and the supplied BNode object are equal.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
Two BNode objects are said to be equal if they're set to the same node,
|
|
|
|
or if they're both unintialized
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param node The BNode to be compared against.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c true, if the BNode objects are equal, \c false otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn bool BNode::operator!=(const BNode &node) const
|
|
|
|
\brief Tests whether this and the supplied BNode object are not equal.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
Two BNode objects are said to be equal if they're set to the same node,
|
|
|
|
or if they're both unintialized.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param node The BNode to be compared with
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\return \c false, if the BNode objects are equal, \c true otherwise.
|
2011-10-30 02:02:52 +04:00
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2011-10-30 02:02:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @}
|