1 // ----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the OpenBeOS license.
5 // File Name: VolumeRoster.cpp
7 // Description: BVolumeRoster class
8 // ----------------------------------------------------------------------
15 #include <Directory.h>
18 #include <NodeMonitor.h>
19 #include <VolumeRoster.h>
22 static const char kBootVolumePath
[] = "/boot";
27 #ifdef USE_OPENBEOS_NAMESPACE
32 BVolumeRoster::BVolumeRoster()
39 // Deletes the volume roster and frees all associated resources.
40 BVolumeRoster::~BVolumeRoster()
46 // Fills out the passed in BVolume object with the next available volume.
48 BVolumeRoster::GetNextVolume(BVolume
*volume
)
51 status_t error
= (volume
? B_OK
: B_BAD_VALUE
);
55 device
= next_dev(&fCookie
);
61 error
= volume
->SetTo(device
);
66 // Rewinds the list of available volumes back to the first item.
68 BVolumeRoster::Rewind()
74 // Fills out the passed in BVolume object with the boot volume.
76 BVolumeRoster::GetBootVolume(BVolume
*volume
)
79 status_t error
= (volume
? B_OK
: B_BAD_VALUE
);
83 device
= dev_for_path(kBootVolumePath
);
89 error
= volume
->SetTo(device
);
94 // Starts watching the available volumes for changes.
96 BVolumeRoster::StartWatching(BMessenger messenger
)
99 status_t error
= (messenger
.IsValid() ? B_OK
: B_ERROR
);
102 fTarget
= new(nothrow
) BMessenger(messenger
);
108 error
= watch_node(NULL
, B_WATCH_MOUNT
, messenger
);
109 // cleanup on failure
110 if (error
!= B_OK
&& fTarget
) {
118 // Stops watching volumes initiated by StartWatching().
120 BVolumeRoster::StopWatching()
123 stop_watching(*fTarget
);
130 // Returns the messenger currently watching the volume list.
132 BVolumeRoster::Messenger() const
134 return (fTarget
? *fTarget
: BMessenger());
139 void BVolumeRoster::_SeveredVRoster1() {}
140 void BVolumeRoster::_SeveredVRoster2() {}
143 #ifdef USE_OPENBEOS_NAMESPACE