The Storage Kit: BVolume

Derived from: (none)

Declared in: be/StorageKit/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 EINVAL, 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

Returns the name of the volume in 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:

  • IsRemovable(). Can the media be removed?
  • IsReadOnly(). Can it be read but not written to?
  • IsPersistent(). Is the storage persistent (such as on a floppy or hard disk)?
  • IsShared(). Is it accessed through the network (as opposed to being directly connected to this computer)?

  • 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:

  • KnowsMime(). Does it use MIME to type files?
  • KnowsQuery(). Can it respond to queries?
  • KnowsAttr(). Do its files accept attributes?





  • The Be Book, HTML Edition, for Developer Release 9 of the Be OS.

    Copyright © 1997 Be, Inc. All rights reserved.

    Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.

    Last modified