hide random home http://www.be.com/documentation/be_book/storage/Volume.html (Amiga Plus Extra No. 5/97, 05/1997)


The Storage Kit: BVolume

Derived from: (none)

Declared in: be/nustorage/Volume.h

Library: libbe.so


Overview

The BVolume class lets you ask questions about specific "volumes," where a volume is any independent file system. Most applications are usually only interested in "persistent" volumes, such as hard disks, floppies, or CD-ROMs, but you can also create BVolumes to virtual file systems, such as /pipe. Here's what a BVolume knows:

The volume's name, device ID, and "root directory."

Its storage capacity, and the currently available storage.

If the volume is on a media that's removable.

If the volume's storage is persistent (as opposed to the ephemeral storage you get with virtual file systems).

If the volume is accessed through the network.

If the file system uses MIME as file types, if it responds to queries, and if it knows about attributes.


Initializing a BVolume

There are two ways to initialize a BVolume:


Mount and Unmount

A BVolume object doesn't know anything about mounting and unmounting:

It can't tell you directly whether the device that it represents is still mounted. If you want to ask, you can call a status_t-returning BVolume function; if the function returns B_BAD_VALUE, the device is no longer mounted.

You can't ask a BVolume to unmount itself.

If you want to be told when devices are mounted and unmounted, you have to ask the Node Monitor to help you. Call watch_node() thus:

   watch_node(NULL, B_WATCH_MOUNT, messenger);

messenger is a BMessenger object that acts as the target of subsequent mount and unmount notifications. See "The Node Monitor" for details.


Constructor and Destructor


BVolume()


      BVolume(void)

      BVolume(dev_id device)

      BVolume(BVolume &volume)

Creates a new BVolume object and initializes it according to the argument. The status of the initialization is recorded by the InitCheck() function.


~BVolume


      ~BVolume(void)

Destroys the BVolume object.


Member Functions


Capacity(), FreeBytes()


      off_t Capacity(void) const

      off_t FreeBytes(void) const

Returns the volume's total storage capacity and the amount of storage that's currently unused. Both measurements are in bytes.


GetName()


      status_t GetName(char *buffer) const

Copies the name of the volume into buffer.


IsRemovable(), IsReadOnly(), IsPersistent(), IsShared()


      bool IsRemovable(void) const
      bool IsReadOnly(void) const
      bool IsPersistent(void) const
      bool IsShared(void) const

These functions answer media-related questions about the volume:


KnowsMime(), KnowsQuery(), KnowsAttr()


      bool KnowsMime(void) const
      bool KnowsQuery(void) const
      bool KnowsAttr(void) const

These functions answer questions about the file system on the volume:


SetTo(), Unset()


      status_t SetTo(dev_t dev)

      void Unset(void)

SetTo() initializes the BVolume object to represent the volume (device) identified by the argument.

Unset() uninitializes the argument.


Device()


      dev_t Device(void) const

Returns the object's dev_t number.


GetRootDirectory()


      status_t GetRootDirectory(BDirectory *dir) const

Initializes dir (which must be allocated) to refer to the volume's "root directory." The root directory stands at the "root" of the volume's file hierarchy. Note that this isn't necessarily the root of the entire file hierarchy.


Operators


= (assignment)


      BVolume& operator=(const BEntry &volume)

In the expression

   BVolume a = b;

BVolume a is initialized to refer to the same volume as b. To gauge the success of the assignment, you should call InitCheck() immediately afterwards. Assigning a BVolume to itself is safe.

Assigning from an uninitialized BVolume is "successful": The assigned-to BVolume will also be uninitialized (B_NO_INIT).


==, != (comparison)


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

Two BVolume objects are said to be equal if they refer to the same volume, or if they're both uninitialized.






The Be Book, in lovely HTML, for the BeOS Preview Release.

Copyright © 1997 Be, Inc. All rights reserved.

Be is a registered trademark; BeOS, BeBox, BeWare, GeekPort, the Be logo, and the BeOS logo are trademarks of Be, Inc.

Last modified July 17, 1997.