Public Member Functions | List of all members
BVolume Class Reference

Provides an interface for querying information about a volume. More...

Public Member Functions

 BVolume ()
 Creates an uninitialized BVolume object. More...
 
 BVolume (dev_t device)
 Creates a BVolume and initializes it to the volume specified by the supplied device ID. More...
 
 BVolume (const BVolume &volume)
 Creates a copy of the supplied BVolume object. More...
 
virtual ~BVolume ()
 Destroys the object and frees all associated resources. More...
 
Constructor Helpers
status_t InitCheck () const
 Returns the initialization status. More...
 
status_t SetTo (dev_t device)
 Initializes the object to refer to the volume specified by the supplied device ID. More...
 
void Unset ()
 Brings the BVolume object to an uninitialized state. More...
 
Volume Information
dev_t Device () const
 Returns the device ID of the volume the object refers to. More...
 
status_t GetRootDirectory (BDirectory *directory) const
 Writes the root directory of the volume referred to by this object into directory. More...
 
off_t Capacity () const
 Returns the total storage capacity of the volume. More...
 
off_t FreeBytes () const
 Returns the amount of unused space on the volume (in bytes). More...
 
off_t BlockSize () const
 Returns the size of one block (in bytes). The meaning of this depends on the underlying file system. More...
 
Volume Name
status_t GetName (char *name) const
 Writes the volume's name into the provided buffer. More...
 
status_t SetName (const char *name)
 Sets the volume's name to name. More...
 
Volume Icon
status_t GetIcon (BBitmap *icon, icon_size which) const
 Writes the volume's icon into the supplied BBitmap. More...
 
status_t GetIcon (uint8 **_data, size_t *_size, type_code *_type) const
 Writes the volume's icon data into the supplied uint8 array. More...
 
Volume Capabilities
bool IsRemovable () const
 Returns whether or not the volume is removable. More...
 
bool IsReadOnly () const
 Returns whether or not the volume is read-only. More...
 
bool IsPersistent () const
 Returns whether or not the volume is persistent. More...
 
bool IsShared () const
 Returns whether or not the volume is shared. More...
 
bool KnowsMime () const
 Returns whether or not the volume supports MIME-types. More...
 
bool KnowsAttr () const
 Returns whether or not the volume supports attributes. More...
 
bool KnowsQuery () const
 Returns whether or not the volume supports queries. More...
 
Operators
bool operator== (const BVolume &volume) const
 Returns whether or not the supplied BVolume object is equal to this object. More...
 
bool operator!= (const BVolume &volume) const
 Returns whether or not the supplied BVolume object is NOT equal to this object. More...
 
BVolumeoperator= (const BVolume &volume)
 Assigns the supplied BVolume object to this volume, this object is made to be an exact clone of the supplied one. More...
 

Detailed Description

Provides an interface for querying information about a volume.

The class is a simple wrapper for a dev_t and the function fs_stat_dev(). The sole exception is the SetName() method which sets the name of the volume.

Since
BeOS R3

Constructor & Destructor Documentation

◆ BVolume() [1/3]

BVolume::BVolume ( )

Creates an uninitialized BVolume object.

InitCheck() will return B_NO_INIT.

See also
SetTo()
Since
BeOS R3

◆ BVolume() [2/3]

BVolume::BVolume ( dev_t  device)

Creates a BVolume and initializes it to the volume specified by the supplied device ID.

InitCheck() should be called afterwards to check if initialization was successful.

Parameters
deviceThe device ID of the volume.
Since
BeOS R3

◆ BVolume() [3/3]

BVolume::BVolume ( const BVolume volume)

Creates a copy of the supplied BVolume object.

Afterwards the object refers to the same device the supplied object does. If the latter is not properly initialized, this result isn't either.

Parameters
volumeThe volume object to be copied.
Since
BeOS R3

◆ ~BVolume()

BVolume::~BVolume ( )
virtual

Destroys the object and frees all associated resources.

Since
BeOS R3

Member Function Documentation

◆ BlockSize()

off_t BVolume::BlockSize ( ) const

Returns the size of one block (in bytes). The meaning of this depends on the underlying file system.

Returns
The block size in bytes, B_NO_INIT if the volume is not initialized or other errors forwarded from the file system.
Since
Haiku R1

◆ Capacity()

off_t BVolume::Capacity ( ) const

Returns the total storage capacity of the volume.

Returns
The volume's total storage capacity (in bytes), or B_BAD_VALUE if the object is not properly initialized.
See also
FreeBytes()
Since
BeOS R3

◆ Device()

dev_t BVolume::Device ( ) const

Returns the device ID of the volume the object refers to.

Returns
Returns the device ID of the volume the object refers to or -1 if the object was not properly initialized.
Since
BeOS R3

◆ FreeBytes()

off_t BVolume::FreeBytes ( ) const

Returns the amount of unused space on the volume (in bytes).

Returns
The amount of unused space on the volume (in bytes), or B_BAD_VALUE if the object is not properly initialized.
Since
BeOS R3

◆ GetIcon() [1/2]

status_t BVolume::GetIcon ( BBitmap icon,
icon_size  which 
) const

Writes the volume's icon into the supplied BBitmap.

Parameters
iconA 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).
whichThe icon size to be retrieved: B_MINI_ICON for the mini or B_LARGE_ICON for the large icon.
Since
BeOS R4

◆ GetIcon() [2/2]

status_t BVolume::GetIcon ( uint8 **  _data,
size_t *  _size,
type_code _type 
) const

Writes the volume's icon data into the supplied uint8 array.

Parameters
_dataA pointer to a pointer to a pre-allocated uint8 array of the correct size to store the requested icon.
_sizeThe size of the retrieved icon (in bytes).
_typeThe type code of the retrieve icon.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITObject was not properly initialized.
See also
fs_stat_dev() for more return codes.
get_device_icon() for more return codes.
Since
Haiku R1

◆ GetName()

status_t BVolume::GetName ( char *  name) const

Writes the volume's name into the provided buffer.

Parameters
nameA pointer to a pre-allocated character buffer of size B_FILE_NAME_LENGTH or larger into which the name of the volume is written.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEname was NULL or the object was not properly initialized.
See also
SetName()
Since
BeOS R3

◆ GetRootDirectory()

status_t BVolume::GetRootDirectory ( BDirectory directory) const

Writes the root directory of the volume referred to by this object into directory.

Parameters
directoryA pointer to a pre-allocated BDirectory to be initialized to the volume's root directory.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEdirectory was NULL or the object was not properly initialized.
Since
BeOS R3

◆ InitCheck()

status_t BVolume::InitCheck ( void  ) const

Returns the initialization status.

Returns
B_OK if the object was properly initialized, or an error code otherwise.
Since
BeOS R3

◆ IsPersistent()

bool BVolume::IsPersistent ( void  ) const

Returns whether or not the volume is persistent.

Returns
true, if the volume was properly initialized and is persistent, false otherwise.
Since
BeOS R3

◆ IsReadOnly()

bool BVolume::IsReadOnly ( void  ) const

Returns whether or not the volume is read-only.

Returns
true, if the volume was properly initialized and is read-only, false otherwise.
Since
BeOS R3

◆ IsRemovable()

bool BVolume::IsRemovable ( ) const

Returns whether or not the volume is removable.

Returns
true, if the volume was properly initialized and is removable, false otherwise.
Since
BeOS R3

◆ IsShared()

bool BVolume::IsShared ( void  ) const

Returns whether or not the volume is shared.

return true, if the volume was properly initialized and is shared, false otherwise.

Since
BeOS R3

◆ KnowsAttr()

bool BVolume::KnowsAttr ( void  ) const

Returns whether or not the volume supports attributes.

Returns
true, if the volume was properly initialized and supports attributes, false otherwise.
Since
BeOS R3

◆ KnowsMime()

bool BVolume::KnowsMime ( void  ) const

Returns whether or not the volume supports MIME-types.

Returns
true, if the volume was properly initialized and supports MIME-types, false otherwise.
Since
BeOS R3

◆ KnowsQuery()

bool BVolume::KnowsQuery ( void  ) const

Returns whether or not the volume supports queries.

Returns
true, if the volume was properly initialized and supports queries, false otherwise.
Since
BeOS R3

◆ operator!=()

bool BVolume::operator!= ( const BVolume volume) const

Returns whether or not the supplied BVolume object is NOT equal to this object.

Two volume objects are said to be unequal if one is initialized and the other is not or if they are both initialized and refer to the different volumes.

Parameters
volumeThe volume to be tested for inequality.
Returns
true, if the objects and unequal, false otherwise.
Since
BeOS R3

◆ operator=()

BVolume & BVolume::operator= ( const BVolume volume)

Assigns the supplied BVolume object to this volume, this object is made to be an exact clone of the supplied one.

Parameters
volumeThe volume to be assigned.
Returns
A reference to this object.
Since
BeOS R3

◆ operator==()

bool BVolume::operator== ( const BVolume volume) const

Returns whether or not the supplied BVolume object is equal to this object.

Two volume objects are said to be equal if they are both uninitialized, or they are both initialized and refer to the same volume.

Parameters
volumeThe volume to be tested for equality.
Returns
true, if the objects are equal, false otherwise.
Since
BeOS R3

◆ SetName()

status_t BVolume::SetName ( const char *  name)

Sets the volume's name to name.

Note
The R5 implementation checks if an entry with the volume's old name exists in the root directory and renames that entry, if it is indeed the mount point of the volume (or a link referring to it). In all other cases, nothing is done (even if the mount point is named like the volume, but lives in a different directory). We follow suit for the time being.
Warning
If the volume name is set to "boot" this method tries to rename it to /boot, but is prevented by the kernel.
Parameters
nameThe new name of the volume, must not be longer than B_FILE_NAME_LENGTH (including the terminating NULL).
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEname was NULL or the object was not properly initialized.
Since
Haiku R1

◆ SetTo()

status_t BVolume::SetTo ( dev_t  device)

Initializes the object to refer to the volume specified by the supplied device ID.

Parameters
deviceThe device ID of the volume to set.
Returns
B_OK if the object was properly initialized, or an error code otherwise.
Since
BeOS R3

◆ Unset()

void BVolume::Unset ( )

Brings the BVolume object to an uninitialized state.

InitCheck() will return B_NO_INIT.

Since
BeOS R3