Merge branch 'master' into sam460ex

This commit is contained in:
François Revol
2013-02-09 16:25:21 +01:00
142 changed files with 1733 additions and 929 deletions
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Alert.h rev 42274
* /trunk/src/kits/interface/Alert.cpp rev 42274
* headers/os/interface/Alert.h rev 42274
* src/kits/interface/Alert.cpp rev 42274
*/
+2 -2
View File
@@ -7,8 +7,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Bitmap.h rev 42274
* /trunk/src/kits/interface/Bitmap.cpp rev 42274
* headers/os/interface/Bitmap.h rev 42274
* src/kits/interface/Bitmap.cpp rev 42274
*/
+2 -2
View File
@@ -8,8 +8,8 @@
* John Scipione <[email protected]>
*
* Corresponds to:
* /trunk/headers/os/interface/Box.h rev 42274
* /trunk/src/kits/interface/Box.cpp rev 42274
* headers/os/interface/Box.h rev 42274
* src/kits/interface/Box.cpp rev 42274
/*!
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Button.h rev 42794
* /trunk/src/kits/interface/Button.cpp rev 42794
* headers/os/interface/Button.h rev 42794
* src/kits/interface/Button.cpp rev 42794
/*!
+2 -2
View File
@@ -8,8 +8,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/CheckBox.h rev 42794
* /trunk/src/kits/interface/CheckBox.cpp rev 42794
* headers/os/interface/CheckBox.h rev 42794
* src/kits/interface/CheckBox.cpp rev 42794
*/
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/ColorControl.h rev 42794
* /trunk/src/kits/interface/ColorControl.cpp rev 42794
* headers/os/interface/ColorControl.h rev 42794
* src/kits/interface/ColorControl.cpp rev 42794
*/
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Control.h rev 42794
* /trunk/src/kits/interface/Control.cpp rev 42794
* headers/os/interface/Control.h rev 42794
* src/kits/interface/Control.cpp rev 42794
*/
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Dragger.h hrev45050
* /trunk/src/kits/interface/Dragger.cpp hrev45050
* headers/os/interface/Dragger.h hrev45050
* src/kits/interface/Dragger.cpp hrev45050
/*!
+2 -2
View File
@@ -6,8 +6,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Font.h hrev45178
* /trunk/src/kits/interface/Font.cpp hrev45178
* headers/os/interface/Font.h hrev45178
* src/kits/interface/Font.cpp hrev45178
*/
+2 -2
View File
@@ -7,8 +7,8 @@
* Ingo Weinhold, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/GroupLayoutBuilder.h rev 42274
* /trunk/src/kits/interface/GroupLayoutBuilder.cpp rev 42274
* headers/os/interface/GroupLayoutBuilder.h rev 42274
* src/kits/interface/GroupLayoutBuilder.cpp rev 42274
*/
+2 -2
View File
@@ -8,8 +8,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/interface/Screen.h rev 42759
* /trunk/src/kits/interface/Screen.cpp rev 42759
* headers/os/interface/Screen.h rev 42759
* src/kits/interface/Screen.cpp rev 42759
*/
+2 -2
View File
@@ -8,8 +8,8 @@
* Oliver Tappe, [email protected].
*
* Corresponds to:
* /trunk/headers/os/locale/Locale.h rev 43095
* /trunk/src/kits/locale/Locale.cpp rev 43095
* headers/os/locale/Locale.h rev 43095
* src/kits/locale/Locale.cpp rev 43095
*/
+2 -2
View File
@@ -6,8 +6,8 @@
* Adrien Destugues, [email protected]
*
* Corresponds to:
* /trunk/headers/os/storage/FindDirectory.h rev 42600
* /trunk/src/kits/storage/FindDirectory.cpp rev 42600
* headers/os/storage/FindDirectory.h rev 42600
* src/kits/storage/FindDirectory.cpp rev 42600
*/
+2 -2
View File
@@ -7,8 +7,8 @@
* John Scipione, [email protected]
*
* Corresponds to:
* /trunk/headers/os/storage/Mime.h hrev45224
* /trunk/src/kits/storage/Mime.cpp hrev45224
* headers/os/storage/Mime.h hrev45224
* src/kits/storage/Mime.cpp hrev45224
*/
+3 -3
View File
@@ -280,9 +280,9 @@
/*!
\fn status_t BMimeType::GetPreferredApp(char *signature, app_verb verb)
const
\brief Fetches the signature of the MIME type's preferred application from
\fn status_t BMimeType::GetPreferredApp(char *signature,
app_verb verb) const
\brief Fetches the signature of the preferred application from
the MIME database.
The preferred app is the application that's used to access a file when,
+2 -2
View File
@@ -8,8 +8,8 @@
* Ingo Weinhold, [email protected]
*
* Corresponds to:
* /trunk/headers/os/app/Node.h rev 42803
* /trunk/src/kits/app/Node.cpp rev 42803
* headers/os/storage/Node.h rev 42803
* src/kits/storage/Node.cpp rev 42803
*/
+431
View File
@@ -0,0 +1,431 @@
/*
* Copyright 2013 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, [email protected]
* John Scipione, [email protected]
* Ingo Weinhold, [email protected]
*
* Corresponds to:
* headers/os/storage/NodeInfo.h hrev45253
* src/kits/storage/NodeInfo.cpp hrev45253
*/
/*!
\file NodeInfo.h
\ingroup storage
\ingroup libbe
\brief Provides the BNodeInfo class.
*/
/*!
\class BNodeInfo
\ingroup storage
\ingroup libbe
\brief Provides access to file type meta data on a node.
BNodeInfo provides a nice wrapper to all sorts of useful meta data such as
the MIME-type, the file's icon and the application that will open
the file.
*/
/*!
\fn BNodeInfo::BNodeInfo()
\brief Creates an uninitialized BNodeInfo object.
After created a BNodeInfo with this, you should call SetTo().
\see SetTo(BNode *node)
*/
/*!
\fn BNodeInfo::BNodeInfo(BNode *node)
\brief Creates a BNodeInfo object and initializes it to the supplied
\a node.
\param node The \a node to gather information on.
*/
/*!
\fn BNodeInfo::~BNodeInfo()
\brief Frees the object and associated resources.
The internal BNode object is not deleted.
*/
/*!
\name Constructor helper methods
*/
//! @{
/*!
\fn status_t BNodeInfo::SetTo(BNode *node)
\brief Initializes the BNodeInfo to the supplied \a node.
The BNodeInfo object does not copy the supplied \a node object, it uses it
directly instead. You must not delete the supply \a node while the
BNodeInfo object exists. The BNodeInfo does not take over ownership of the
\a node and it doesn't delete it on destruction either.
\param node The \a node to gather information on.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE The node was not properly initialized.
*/
/*!
\fn status_t BNodeInfo::InitCheck() const
\brief Checks whether or not the object has been properly initialized.
\returns A status code.
\retval B_OK The object was properly initialized.
\retval B_BAD_VALUE The object was \b not properly initialized.
*/
//! @}
/*!
\name MIME-type methods
*/
//! @{
/*!
\fn status_t BNodeInfo::GetType(char *type) const
\brief Writes the MIME-type of the node into \a type.
The source of the type information is the \c BEOS:TYPE attribute of the
node. The \a type buffer should be pre-allocated before it is passed into
GetType(), it should be at least \c B_MIME_TYPE_LENGTH in length.
\param type A pointer to a pre-allocated char buffer of at least
\c B_MIME_TYPE_LENGTH length into which the MIME-type of the
node is written.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object is not properly initialized.
\retval B_BAD_VALUE \c NULL \a type or the type string stored in the
attribute is longer than \c B_MIME_TYPE_LENGTH.
\retval B_BAD_TYPE The stored type string attribute has the wrong type.
\retval B_ENTRY_NOT_FOUND No type is set on the node.
*/
/*!
\fn status_t BNodeInfo::SetType(const char *type)
\brief Sets the MIME-type of the node. If \a type is \c NULL the
\c BEOS:TYPE attribute is removed instead.
The \a type string is written into the \c BEOS:TYPE attribute of the node.
If \a type is \c NULL, the \c BEOS:TYPE attribute is removed instead. The
\a type parameter may not by longer than \c B_MIME_TYPE_LENGTH in length
including the terminating \c NUL character.
\param type The MIME-type to be assigned to the \a node. Must not be
longer than \c B_MIME_TYPE_LENGTH (including the terminating
\c NUL). May be \c NULL to remove the attribute.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
\retval B_BAD_VALUE \a type is longer than \c B_MIME_TYPE_LENGTH.
*/
//! @}
/*!
\name Icon methods
*/
//! @{
/*!
\fn status_t BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
\brief Gets the icon of the node.
The icon stored in the \c BEOS:L:STD_ICON attribute (large) or
\c BEOS:M:STD_ICON attribute (mini) is retrieved.
\param icon A pointer to a pre-allocated BBitmap object of the correct
dimension to store the requested icon: 16x16 for the mini or
32x32 for the large icon.
\param k The size of the icon to be retrieved: \c B_MINI_ICON for a 16x16
icon and \c B_LARGE_ICON for a 32x32 icon.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
\retval B_BAD_VALUE \c NULL \a icon, unsupported icon size \a k or bitmap
dimensions (\a icon) and icon size (\a k) do not match.
*/
/*!
\fn status_t BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
\brief Sets the icon of the node. If \a icon is \c NULL, the attribute is
removed instead.
The icon is stored in the \c BEOS:L:STD_ICON attribute (large) or
\c BEOS:M:STD_ICON attribute (mini). If \a icon is \c NULL the respective
attribute is removed instead.
\param icon A pointer to a BBitmap object containing the icon to be set.
May be \c NULL.
\param k The size of the icon to be set: \c B_MINI_ICON for the mini or
\c B_LARGE_ICON for the large icon.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object is not properly initialized.
\retval B_BAD_VALUE Unknown icon size \a k or bitmap dimensions (\a icon)
and icon size (\a k) do not match.
*/
/*!
\fn status_t BNodeInfo::GetIcon(uint8** data, size_t* size,
type_code* type) const
\brief Gets the icon of the node.
The icon stored in the \c BEOS:ICON attribute of the node is retrieved.
The caller is responsible to <tt>delete[]</tt> the data if the icon was
retrieved.
\param data A pointer in which a pointer to the icon data
will be returned.
\param size A pointer in which the size of the found icon data
will be returned.
\param type A pointer in which the type of the found icon data
will be returned.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
\retval B_BAD_VALUE \c NULL \a data, \c NULL \a size or \c NULL \a type.
\retval B_NO_MEMORY No memory to allocate the \a data buffer.
*/
/*!
\fn status_t BNodeInfo::SetIcon(const uint8* data, size_t size)
\brief Sets the node icon of the node. If \a data is \c NULL or \a size
is 0, the \c BEOS:ICON attribute is removed instead.
The icon is stored in the \c BEOS:ICON attribute of the node.
\param data A pointer to valid icon data. May be \c NULL.
\param size The size of the provided data buffer. May be 0.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
*/
/*!
\fn status_t BNodeInfo::GetTrackerIcon(BBitmap *icon,
icon_size iconSize) const
\brief Gets the icon displayed by Tracker for the icon.
This method tries really hard to find an icon for the node:
- If the node has no type this method returns the icon for
\c B_FILE_MIME_TYPE if it's a regular file or
\c B_DIRECTORY_MIME_TYPE if it's a directory, even if the node has its
own icon!
- Next it will ask GetIcon() for an icon.
- If this fails it will get the preferred application and ask the MIME
database if the application has an icon for the file type of the
node.
- Next it will ask the MIME database whether there is an icon for the file
type of the node.
- Then it will ask the MIME database for the preferred application for
the file type of the node and whether this application has a special
icon for the type.
- Finally it will return a generic icon for whatever type of file type
(file/dir/etc.) the node is from the MIME database.
The first action that provides an icon is used. In the case that none of
them yield an icon this method fails, this is very unlikely though.
\remarks You can set \a iconSize to get a scaled icon instead of using
a predefined icon_size constant, pass in an integer casted
to icon_size. For example to get a 64x64 icon pass in:
\code
(icon_size)64
\endcode
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
to store the requested icon (16x16 for the mini and 32x32 for the
large icon).
\param iconSize The size of the icon to be retrieved: \c B_MINI_ICON
for a 16x16 icon or \c B_LARGE_ICON for a 32x32 icon.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
\retval B_BAD_VALUE \c NULL \a icon, unsupported icon size \a iconSize
or bitmap dimensions (\a icon) and icon size (\a iconSize) do
not match.
*/
/*!
\fn status_t BNodeInfo::GetTrackerIcon(const entry_ref *ref,
BBitmap *icon, icon_size iconSize)
\brief Gets the icon displayed by Tracker for the node referred to by
\a ref.
This methods works similarly to the non-static version but \a ref
identifies the node. \a icon must be pre-allocated to the size requested
using \a iconSize before being passed to this method.
\param ref An entry_ref referring to the node for which the icon is
retrieved.
\param icon A pointer to a pre-allocated BBitmap object of the correct
dimension to store the requested icon (16x16 for the mini and 32x32
for the large icon).
\param iconSize The size of the icon to be retrieved: \c B_MINI_ICON
for a 16x16 icon or \c B_LARGE_ICON for a 32x32 icon.
\returns A status code.
\retval B_OK: Everything went fine.
\retval B_NO_INIT: The object is not properly initialized.
\retval B_BAD_VALUE: \c NULL ref or \a icon, unsupported icon size
\a iconSize or bitmap dimensions (\a icon) and icon size
(\a iconSize) do not match.
*/
//! @}
/*!
\name Preferred application methods
*/
//! @{
/*!
\fn status_t BNodeInfo::GetPreferredApp(char *signature,
app_verb verb) const
\brief Gets the preferred application of the node.
Writes the contents of the \c BEOS:PREF_APP attribute into the
\a signature buffer. The preferred application can be identified by its
signature. \a signature should be at least \c B_MIME_TYPE_LENGTH or
longer and pre-allocated before it is passed into this method.
\param signature A pointer to a pre-allocated character buffer of size
\c B_MIME_TYPE_LENGTH or larger into which the MIME-type of the
preferred application is written.
\param verb The type of access the preferred application is requested.
Currently \c B_OPEN is the only meaningful option.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object was not properly initialized.
\retval B_BAD_VALUE \c NULL \a signature or bad app_verb.
*/
/*!
\fn status_t BNodeInfo::SetPreferredApp(const char *signature,
app_verb verb)
\brief Sets the preferred application of the node. If \a signature is
\c NULL, the \c BEOS:PREF_APP attribute is removed instead.
The supplied string is written into the \c BEOS:PREF_APP attribute of the
node. If \a signature is \c NULL, the respective attribute is removed
instead. \a signature must not be longer than \c B_MIME_TYPE_LENGTH
(including the terminating \c NUL).
\param signature The signature of the preferred application to be set.
May be \c NULL.
\param verb The type of access set to the preferred application.
Currently only \c B_OPEN is meaningful.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_INIT The object is not properly initialized.
\retval B_BAD_VALUE \c NULL \a signature, \a signature is longer than
\c B_MIME_TYPE_LENGTH or bad app_verb.
*/
//! @}
/*!
\name Application hint methods
*/
//! @{
/*!
\fn status_t BNodeInfo::GetAppHint(entry_ref *ref) const
\brief Fills out \a ref with a pointer to a hint about the application
that will open this node.
The path contained in the \c BEOS:PPATH attribute of the node is converted
into an entry_ref and returned. \a ref should be pre-allocated before being
passed into this method.
\param ref A pointer to a pre-allocated entry_ref into which the app hint
is written.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_DATA Attribute size greater than \c B_PATH_NAME_LENGTH.
\retval B_BAD_TYPE The stored type string attribute has the wrong type.
\retval B_BAD_VALUE The \a ref object passed in was \c NULL.
\retval B_ERROR Unable to read \c BEOS:PPATH attribute.
\retval B_NO_INIT The object was not properly initialized.
*/
/*!
\fn status_t BNodeInfo::SetAppHint(const entry_ref *ref)
\brief Sets the application that will open the file type of the node. If
\a ref is \c NULL, the \c BEOS:PPATH attribute is removed instead.
\a ref is converted into a path and stored in the \c BEOS:PPATH attribute
of the node. If \a ref is NULL \c BEOS:PPATH is removed instead.
\param ref A pointer to an entry_ref referring to the application.
May be \c NULL.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE The \a ref object passed in was \c NULL.
\retval B_ENTRY_NOT_FOUND \c BEOS:PPATH attribute not found.
\retval B_ERROR Unable to write \c BEOS:PPATH attribute.
\retval B_NO_INIT The object was not properly initialized.
*/
//! @}
+406
View File
@@ -0,0 +1,406 @@
/*
* Copyright 2003-2013 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, [email protected]
* John Scipione, [email protected]
* Ingo Weinhold, [email protected]
* Clemens Zeidler, [email protected]
*
* Corresponds to:
* headers/os/storage/NodeMonitor.h hrev45253
* src/kits/storage/NodeMonitor.cpp hrev45253
*/
/*!
\file NodeMonitor.h
\ingroup storage
\ingroup libbe
\brief Provides functions and constants for monitoring changes to a node.
The are three main node monitoring functions are watch_volume(),
watch_node() and stop_watching().
- watch_volume() starts watching a volume and sends a message
when a requested event occurs.
- watch_node() starts or stops watching a node, or watches for volumes
to be mounted and unmounted, and sends a message when an event occurs.
- stop_watching() stops monitoring a node or volume and no longer sends
messages.
*/
/*!
\var B_STOP_WATCHING
Flag for watch_node(). Unsubscribe from watching a node.
*/
/*!
\var B_WATCH_NAME
Flag for watch_volume() and watch_node(). Subscribe to watching for
change to the name of a node.
*/
/*!
\var B_WATCH_STAT
Flag for watch_volume() and watch_node(). Subscribe to watching for
changes to the stat information of a node.
*/
/*!
\var B_WATCH_ATTR
Flag for watch_volume() and watch_node(). Subscribe to watching for
changes to the attributes of a node.
*/
/*!
\var B_WATCH_DIRECTORY
Flag for watch_node(). Subscribe to watching for changes to the contents
of a directory.
*/
/*!
\var B_WATCH_ALL
Flag for watch_node(). Subscribe to watching for changes to all
information of a node except \c B_WATCH_MOUNT.
*/
/*!
\var B_WATCH_MOUNT
Flag for watch_node(). Subscribe to watching for when a volume is mounted
or unmounted. You may prefer to use BVolumeRoster for volume watching
instead.
*/
/*!
\var B_WATCH_INTERIM_STAT
\internal Implementation detail. Not in Be Book.
To avoid a flood of messages for small and frequent write operations on an
open file the file system can limit the number of notifications and mark
them with the \c B_WATCH_INTERIM_STAT flag.
*/
/*!
\def B_ENTRY_CREATED
\c B_NODE_MONITOR notification message "opcode" is set when entry is
created.
*/
/*!
\def B_ENTRY_REMOVED
\c B_NODE_MONITOR notification message "opcode" is set when entry is
removed.
*/
/*!
\def B_ENTRY_MOVED
\c B_NODE_MONITOR notification message "opcode" is set when entry is
moved.
*/
/*!
\def B_STAT_CHANGED
\c B_NODE_MONITOR notification message "opcode" set when stat info
changes. More information can be found in the "fields" field.
*/
/*!
\def B_ATTR_CHANGED
\c B_NODE_MONITOR notification message "opcode" set when attribute
changes. More information can be found in the "cause" field.
*/
/*!
\def B_DEVICE_MOUNTED
\c B_NODE_MONITOR notification message "opcode" set when device is
mounted.
*/
/*!
\def B_DEVICE_UNMOUNTED
\c B_NODE_MONITOR notification message "opcode" set when device is
unmounted.
*/
/*!
\def B_ATTR_CREATED
\c B_ATTR_CHANGED notification message "cause" set when attribute is
created. (Haiku only)
*/
/*!
\def B_ATTR_REMOVED
\c B_ATTR_CHANGED notification message "cause" set when attribute is
removed. (Haiku only)
*/
/*!
\var B_STAT_MODE
\c B_STAT_CHANGED notification messages "fields" flag set when stat mode
changes.
*/
/*!
\var B_STAT_UID
\c B_STAT_CHANGED notification messages "fields" flag set when UID
changes.
*/
/*!
\var B_STAT_GID
\c B_STAT_CHANGED notification messages "fields" flag set when GID
changes.
*/
/*!
\var B_STAT_SIZE
\c B_STAT_CHANGED notification messages "fields" flag set when stat size
changes.
*/
/*!
\var B_STAT_ACCESS_TIME
\c B_STAT_CHANGED notification messages "fields" flag set when access time
changes.
*/
/*!
\var B_STAT_MODIFICATION_TIME
\c B_STAT_CHANGED notification messages "fields" flag set when
modification time changes.
*/
/*!
\var B_STAT_CREATION_TIME
\c B_STAT_CHANGED notification messages "fields" flag set when creation
time changes.
*/
/*!
\var B_STAT_CHANGE_TIME
\c B_STAT_CHANGED notification messages "fields" flag set when access,
modification or creation time changes.
*/
/*!
\var B_STAT_INTERIM_UPDATE
\internal Implementation detail. Not in Be Book.
\c B_STAT_CHANGED notification messages "fields" flag set when file is
written to.
*/
/*!
\fn status_t watch_volume(dev_t volume, uint32 flags, BMessenger target)
\brief Subscribes \a target to watch node changes on \a volume.
Depending of \a flags the action performed by this function varies:
- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
aspects of any node on the volume.
\a flags may include:
- \c B_WATCH_NAME
- \c B_WATCH_STAT
- \c B_WATCH_ATTR
\c B_WATCH_VOLUME flag is assumed.
\param volume dev_t referring to the volume to be watched.
\param flags Flags indicating the actions to be performed.
\param target Messenger referring to the target. Must be valid.
\return A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
\c B_WATCH_STAT, or \c B_WATCH_ATTR.
*/
/*!
\fn status_t watch_volume(dev_t volume, uint32 flags,
const BHandler *handler, const BLooper *looper)
\brief Subscribes \a handler or \a looper to watch node changes on
\a volume.
Depending of \a flags the action performed by this function varies:
- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
aspects of any node on the volume.
\a flags may include:
- \c B_WATCH_NAME
- \c B_WATCH_STAT
- \c B_WATCH_ATTR
\c B_WATCH_VOLUME flag is assumed.
\param volume dev_t referring to the volume to be watched.
\param flags Flags indicating the actions to be performed.
\param handler The target \a handler. May be \c NULL, if \a looper is not
\c NULL. Then the preferred handler of the looper is targeted.
\param looper The target \a looper. May be \c NULL, if \a handler is not
\c NULL. Then the handler's looper is the target looper.
\return A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
\c B_WATCH_STAT, or \c B_WATCH_ATTR.
*/
/*!
\fn status_t watch_node(const node_ref *node, uint32 flags,
BMessenger target)
\brief Subscribes or unsubscribes \a target to node and/or mount watching.
Depending of \a flags the action performed by this function varies:
- \a flags is 0: The target is unsubscribed from watching the node.
\a node must not be \c NULL in this case.
- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
watching.
- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
\c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
watching the specified aspects of the node. \a node must not be \c NULL
in this case.
\a flags may include:
- \c B_STOP_WATCHING
or one or more of the following:
- \c B_WATCH_NAME
- \c B_WATCH_STAT
- \c B_WATCH_ATTR
- \c B_WATCH_DIRECTORY
- \c B_WATCH_ALL
- \c B_WATCH_MOUNT
Note, that the latter two cases are not mutual exclusive, i.e. mount and
node watching can be requested with a single call.
\param node node_ref referring to the node to be watched. May be \c NULL,
if only mount watching is requested.
\param flags Flags indicating the actions to be performed.
\param target Messenger referring to the target. Must be valid.
\return \c B_OK if everything went fine, an error code otherwise.
*/
/*!
\fn status_t watch_node(const node_ref *node, uint32 flags,
const BHandler *handler, const BLooper *looper)
\brief Subscribes or unsubscribes \a handler or \a looper to node and/or
mount watching.
Depending of \a flags the action performed by this function varies:
- \a flags is 0: The target is unsubscribed from watching the node.
\a node must not be \c NULL in this case.
- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
watching.
- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
\c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
watching the specified aspects of the node. \a node must not be \c NULL
in this case.
\a flags may include:
- \c B_STOP_WATCHING
or one or more of the following:
- \c B_WATCH_NAME
- \c B_WATCH_STAT
- \c B_WATCH_ATTR
- \c B_WATCH_DIRECTORY
- \c B_WATCH_ALL
- \c B_WATCH_MOUNT
Note, that the latter two cases are not mutual exlusive, i.e. mount and
node watching can be requested with a single call.
\param node node_ref referring to the node to be watched. May be \c NULL,
if only mount watching is requested.
\param flags Flags indicating the actions to be performed.
\param handler The target handler. May be \c NULL, if \a looper is not
\c NULL. Then the preferred handler of the looper is targeted.
\param looper The target looper. May be \c NULL, if \a handler is not
\c NULL. Then the handler's looper is the target looper.
\return \c B_OK if everything went fine, an error code otherwise.
*/
/*!
\fn status_t stop_watching(BMessenger target)
\brief Unsubscribes \a target from node and mount monitoring.
\param target Messenger referring to the target. Must be valid.
\return \c B_OK if everything went fine, an error code otherwise.
*/
/*!
\fn status_t stop_watching(const BHandler *handler, const BLooper *looper)
\brief Unsubscribes \a target from node and mount monitoring.
\param handler The target handler. May be \c NULL, if \a looper is not
\c NULL. Then the preferred handler of the looper is targeted.
\param looper The target looper. May be \c NULL, if \a handler is not
\c NULL. Then the handler's looper is the target looper.
\return \c B_OK if everything went fine, an error code otherwise.
*/
+503
View File
@@ -0,0 +1,503 @@
/*
* Copyright 2002-2013 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tyler Dauwalder
* Axel Dörfler, [email protected]
* John Scipione, [email protected]
* Ingo Weinhold, [email protected]
*
* Corresponds to:
* headers/os/storage/Path.h hrev45260
* src/kits/storage/Path.cpp hrev45260
*/
/*!
\file Path.h
\ingroup storage
\ingroup libbe
Provides the BPath class.
*/
/*!
\class BPath
\ingroup storage
\ingroup libbe
\brief A class representing a file system path.
*/
/*!
\fn BPath::BPath()
\brief Creates an uninitialized BPath object.
\see SetTo()
*/
/*!
\fn BPath::BPath(const BPath& path)
\brief Creates a copy of the given BPath object.
\param path the object to be copied.
*/
/*!
\fn BPath::BPath(const entry_ref* ref)
\brief Creates a BPath object and initializes it to the filesystem entry
specified by the passed in entry_ref struct.
\param ref the entry_ref to initialize from.
*/
/*!
\fn BPath::BPath(const BEntry* entry)
\brief Creates a BPath object and initializes it to the filesystem entry
specified by the passed in BEntry object.
\param entry the BEntry object to initialize from.
*/
/*!
\fn BPath::BPath(const char* dir, const char* leaf, bool normalize)
\brief Creates a BPath object and initializes it to the specified path or
path and filename combination.
\param dir The base component of the pathname. May be absolute or relative.
If relative, it is based off the current working directory.
\param leaf The (optional) leaf component of the pathname. Must be
relative. The value of \a leaf is concatenated to the end of \a dir
(a "/" will be added as a separator, if necessary).
\param normalize boolean flag used to force normalization; normalization
may sometimes occur even if \c false. The following items require
normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
*/
/*!
\fn BPath::BPath(const BDirectory* dir, const char* leaf, bool normalize)
\brief Creates a BPath object and initializes it to the specified directory
and filename combination.
\param dir The directory that provides the base component of the pathname.
\param leaf The (optional) leaf component of the pathname. Must be
relative. The value of \a leaf is concatenated to the end of \a dir
(a "/" will be added as a separator, if necessary).
\param normalize boolean flag used to force normalization; normalization
may sometimes occur even if \c false. The following items require
normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
*/
/*!
\fn BPath::~BPath()
\brief Destroys the BPath object and frees any of its associated resources.
*/
/*!
\name Constructor helper methods
*/
//! @{
/*!
\fn status_t BPath::InitCheck() const
\brief Checks whether or not the object was properly initialized.
\return \c B_OK, if the BPath object was properly initialized, an error
code otherwise.
*/
/*!
\fn status_t BPath::SetTo(const entry_ref* ref)
\brief Reinitializes the object to the filesystem entry specified by the
passed in entry_ref struct.
\param ref The entry_ref to reinitialize the entry from.
\returns A status code.
\retval B_OK Initialization was successful.
\retval B_BAD_VALUE \c NULL \a ref.
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
*/
/*!
\fn status_t BPath::SetTo(const BEntry* entry)
\brief Reinitializes the object to the specified filesystem entry.
\param entry The BEntry to reinitialize the entry from.
\returns A status code.
\retval B_OK Initialization was successful.
\retval B_BAD_VALUE \c NULL \a ref.
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
*/
/*!
\fn status_t BPath::SetTo(const char* path, const char* leaf, bool normalize)
\brief Reinitializes the object to the passed in \a path or \a path and
\a leaf combination.
\remarks The following pseudocode is safe:
\code path.SetTo(path.Path(), "new leaf") \endcode
\param path The \a path name to use.
\param leaf The \a leaf name to use (may be \c NULL).
\param normalize Boolean flag used to force normalization; normalization
may sometimes occur even if \c false. The following items require
normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
\returns A status code.
\retval B_OK Initialization was successful.
\retval B_BAD_VALUE \c NULL \a ref.
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
*/
/*!
\fn status_t BPath::SetTo(const BDirectory* dir, const char* path,
bool normalize)
\brief Reinitializes the object to the passed in \a dir and relative
\a path combination.
\param dir The directory that provides the base component of the pathname.
\param path the relative \a path name (may be \c NULL).
\param normalize boolean flag used to force normalization; normalization
may sometimes occur even if \c false. The following items require
normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
\returns A status code.
\retval B_OK Initialization was successful.
\retval B_BAD_VALUE \c NULL \a ref.
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
*/
/*!
\fn void BPath::Unset()
\brief Returns the object to an uninitialized state.
Frees any resources it allocated and marks the object as uninitialized.
*/
//! @}
/*!
\name Path manipulation methods
*/
//! @{
/*!
\fn status_t BPath::Append(const char* path, bool normalize)
\brief Appends the passed in relative path to the end of the current path.
This method fails if the path is absolute or the BPath object is
uninitialized.
\param path Relative pathname to append to current path (may be \c NULL).
\param normalize Boolean flag used to force normalization; normalization
may sometimes occur even if \c false. The following items require
normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
\returns A status code.
\retval B_OK Initialization was successful.
\retval B_BAD_VALUE \c NULL \a ref.
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
*/
//! @}
/*!
\name Path information methods
*/
//! @{
/*!
\fn const char* BPath::Path() const
\brief Gets the entire path of the object.
\returns The path name of the object, or \c NULL if it is not properly
initialized.
*/
/*!
\fn const char* BPath::Leaf() const
\brief Gets the leaf portion of the path.
The leaf portion of the path is defined to be the string after the last
\c '/'. For the root path (\c "/") it is an empty string (\c "").
\returns The leaf portion of the path or \c NULL if it is not properly
initialized.
*/
/*!
\fn status_t BPath::GetParent(BPath* path) const
\brief Initializes \a path with the parent directory of the BPath object.
No normalization is performed on the path.
\param path The BPath object to be initialized to the parent directory.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE \c NULL \a path.
\retval B_ENTRY_NOT_FOUND The BPath object represents the root path and
thus has no parent.
*/
/*!
\fn bool BPath::IsAbsolute() const
\brief Gets whether or not the path is absolute or relative.
\warning This method returns \c false if the object is initialized.
\returns \c true if the path is absolute, \c false if relative or if the
object is uninitialized.
*/
//! @}
/*!
\name Operator overload methods
*/
//! @{
/*!
\fn bool BPath::operator==(const BPath& item) const
\brief Performs a simple (string-wise) comparison of paths for equality.
\warning No normalization takes place, two uninitialized BPath objects are
considered equal.
\param item the BPath object to compare.
\return \c true, if the paths are equal, \c false otherwise.
*/
/*!
\fn bool BPath::operator==(const char* path) const
\brief Performs a simple (string-wise) comparison of paths for equality.
\warning No normalization takes place.
\param path The path to compare.
\return \c true, if the path names are equal, \c false otherwise.
*/
/*!
\fn bool BPath::operator!=(const BPath& item) const
\brief Performs a simple (string-wise) comparison of paths for inequality.
\warning No normalization takes place, two uninitialized BPath objects are
considered equal.
\param item the BPath object to compare.
\return \c true, if the path names are \b not equal, \c false otherwise.
*/
/*!
\fn bool BPath::operator!=(const char* path) const
\brief Performs a simple (string-wise) comparison of paths for inequality.
\warning No normalization takes place.
\param path The path to compare.
\return \c true, if the path names are \b not equal, \c false otherwise.
*/
/*!
\fn BPath& BPath::operator=(const BPath& item)
\brief Initializes the object as a copy of \a item.
\param item The BPath object to copy
\return A pointer to the newly initialized BPath object.
*/
/*!
\fn BPath& BPath::operator=(const char* path)
\brief Initializes the object with the passed in \a path.
Has the same effect as \code SetTo(path) \endcode
\param path the path to be assign to this object.
\return A pointer to the newly initialized BPath object.
*/
//! @}
/*!
\name BFlattenable override methods
*/
//! @{
/*!
\fn bool BPath::IsFixedSize() const
\brief Overrides BFlattenable::IsFixedSize(). Always returns \c false.
\return \c false
*/
/*!
\fn type_code BPath::TypeCode() const
\brief Overrides BFlattenable::TypeCode() Always returns \c B_REF_TYPE.
\return \c B_REF_TYPE
*/
/*!
\fn ssize_t BPath::FlattenedSize() const
\brief Overrides BFlattenable::FlattenedSize() Gets the size of the
flattened entry_ref struct that represents the path in bytes.
\return The size of the flattened entry_ref struct that represents the
path in bytes.
*/
/*!
\fn status_t BPath::Flatten(void* buffer, ssize_t size) const
\brief Overrides BFlattenable::Flatten(). Converts the path of the object
to an entry_ref and writes it into <em>buffer</em>.
\param buffer The buffer that the data is to be stored in.
\param size Size of <em>buffer</em>.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE \c NULL buffer or the buffer is of insufficient size.
*/
/*!
\fn bool BPath::AllowsTypeCode(type_code code) const
\brief Overrides BFlattenable::AllowsTypeCode(). Checks if type code is
equal to \c B_REF_TYPE.
\param code The type code to test.
\return \c true if code is \c B_REF_TYPE, \c false otherwise.
*/
/*!
\fn status_t BPath::Unflatten(type_code code, const void* buffer,
ssize_t size)
\brief Overrides BFlattenable::Unflatten(). Initializes the object with
the flattened entry_ref data from the passed in buffer.
The type code must be set to \c B_REF_TYPE.
\param code The type code of the flattened data, must be \c B_REF_TYPE.
\param buf A pointer to the flattened data.
\param size The size of \a buffer in bytes.
\returns A status code.
\retval B_OK Everything went fine.
\retval B_BAD_VALUE \a buffer is \c NULL or doesn't contain an entry_ref.
*/
//! @}
/// private methods, won't show up in docs
/*!
status_t BPath::_SetPath(const char* path)
\brief Sets the supplied path.
The path is copied. If \a path is \c NULL path of the object is set to
\c NULL as well. The object's old path is deleted.
\param path the path to be set
\returns A status code.
\retval B_OK Everything went fine.
\retval B_NO_MEMORY Insufficient memory.
*/
/*!
bool BPath::_MustNormalize(const char* path, status_t* _error)
\brief Checks a path to see if normalization is required.
The following items require normalization:
- Relative pathnames (after concatenation; e.g. "boot/ltj")
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
- Redundant slashes ("/boot//ltj")
- A trailing slash ("/boot/ltj/")
\param _error A pointer to an error variable that will be set if the input
is not a valid path.
\return \c true if \a path requires normalization, \c false otherwise.
*/