2 * Copyright 2002-2013 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 * John Scipione, jscipione@gmail.com
8 * Ingo Weinhold, bonefish@users.sf.net
11 * headers/os/storage/Statable.h hrev47402
12 * src/kits/storage/Statable.cpp hrev47402
20 \brief Provides the BStatable abstract class.
28 \brief Pure abstract class that provides a wrapper interface to the POSIX®
31 BStatable provides common functionality for the BEntry and BNode classes.
32 You can use this class to:
33 - Get the stat struct of a node with the GetStat() method.
34 - Identify a node as a file, directory, or symbolic link with the
35 IsFile(), IsDirectory(), and IsSymLink() methods.
36 - Get and set the UID (GetOwner() and SetOwner()), GID (GetGroup() and
37 SetGroup()), and permissions (GetPermissions() and SetPermissions()) of
39 - Get the size of a node's data (not counting attributes) with the
41 - Get and set a node's modification time (GetModificationTime() and
42 SetModificationTime()), creation time (GetCreationTime() and
43 SetCreationTime()), and access time (GetAccessTime() and
45 - Get a pointer to the BVolume object that a node lives on via the
47 - Get a node_ref of a node to pass into watch_node() via the GetNodeRef()
55 \fn status_t BStatable::GetStat(struct stat* stat) const
56 \brief Fills out the stat structure for the node.
58 This method may be used to access the stat structure of a node directly.
60 \param stat The stat structure to be filled in.
62 \returns A status code.
63 \retval B_OK Everything went fine.
64 \retval B_NO_MEMORY Could not allocate enough memory.
65 \retval B_BAD_VALUE The node does not exist.
66 \retval B_NOT_ALLOWED Node or volume was read only.
73 \fn bool BStatable::IsFile() const
74 \brief Returns whether or not the node is a file.
76 \return \c true, if the node is properly initialized and is a file,
84 \fn bool BStatable::IsDirectory() const
85 \brief Returns whether or not the node is a directory.
87 \return \c true, if the node is properly initialized and is a directory,
95 \fn bool BStatable::IsSymLink() const
96 \brief Returns whether or not the node is a symbolic link.
98 \return \c true, if the node is properly initialized and is a symlink,
106 \fn status_t BStatable::GetNodeRef(node_ref* ref) const
107 \brief Fills out \a ref with the \c node_ref of the node.
109 \param ref the node_ref to be set.
111 \see GetStat() for return codes.
118 \fn status_t BStatable::GetOwner(uid_t* owner) const
119 \brief Fills out the node's UID into \a owner.
121 \param owner A pointer to a \c uid_t to be set.
124 \see GetStat() for return codes.
131 \fn status_t BStatable::SetOwner(uid_t owner)
132 \brief Sets the node's UID to \a owner.
134 \param owner The UID to set the node to.
136 \see GetStat() for return codes.
143 \fn status_t BStatable::GetGroup(gid_t* group) const
144 \brief Fills out the node's GID into \a group.
146 \param group a pointer to a \c gid_t variable to be set.
149 \see GetStat() for return codes.
156 \fn status_t BStatable::SetGroup(gid_t group)
157 \brief Sets the node's GID to \a group.
159 \param group The GID to set the node to.
161 \see GetStat() for return codes.
168 \fn status_t BStatable::GetPermissions(mode_t* permissions) const
169 \brief Fills out \a perms with the permissions of the node.
171 \param permissions The permissions to get from the node.
173 \see SetPermissions()
174 \see GetStat() for return codes.
181 \fn status_t BStatable::SetPermissions(mode_t permissions)
182 \brief Sets the node's permissions to \a perms.
184 \param permissions The permissions to set the node to.
186 \see GetStat() for return codes.
193 \fn status_t BStatable::GetSize(off_t* size) const
194 \brief Fills out the size of the node's data (not counting attributes)
197 \param size A pointer to a \c off_t variable to be set.
199 \see GetStat() for return codes.
206 \fn status_t BStatable::GetModificationTime(time_t* mtime) const
207 \brief Fills out \a mtime with the last modification time of the node.
209 \param mtime A pointer to a \c time_t variable to be set.
211 \see SetModificationTime()
212 \see GetStat() for return codes.
219 \fn status_t BStatable::SetModificationTime(time_t mtime)
220 \brief Sets the node's last modification time to \a mtime.
222 \param mtime The modification time to set the node to.
224 \see GetStat() for return codes.
231 \fn status_t BStatable::GetCreationTime(time_t* ctime) const
232 \brief Fills out \a ctime with the creation time of the node.
234 \param ctime A pointer to a \c time_t variable to be set.
236 \see SetCreationTime()
237 \see GetStat() for return codes.
244 \fn status_t BStatable::SetCreationTime(time_t ctime)
245 \brief Sets the node's creation time to \a ctime.
247 \param ctime The creation time to set the node to.
249 \see GetStat() for return codes.
256 \fn status_t BStatable::GetAccessTime(time_t* atime) const
257 \brief Fills out \a atime with the access time of the node.
259 \see GetModificationTime()
261 \see GetStat() for return codes.
268 \fn status_t BStatable::SetAccessTime(time_t atime)
269 \brief Sets the node's access time to \a atime.
271 \see GetModificationTime()
272 \see GetStat() for return codes.
279 \fn status_t BStatable::GetVolume(BVolume* volume) const
280 \brief Fills out \a vol with the the volume that the node lives on.
282 \param volume A pointer to a BVolume object to be set.
285 \see GetStat() for return codes.