2 * Copyright 2011, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
9 #include <DiskDevice.h>
10 #include <DiskDeviceRoster.h>
12 #include <VolumeRoster.h>
15 BootDrive::BootDrive(const char* path
)
22 BootDrive::~BootDrive()
28 BootDrive::InstalledMenu(const BootMenuList
& menus
) const
30 for (int32 i
= 0; i
< menus
.CountItems(); i
++) {
31 BootMenu
* menu
= menus
.ItemAt(i
);
32 if (menu
->IsInstalled(*this))
40 BootDrive::CanMenuBeInstalled(const BootMenuList
& menus
) const
42 status_t status
= B_ERROR
;
44 for (int32 i
= 0; i
< menus
.CountItems(); i
++) {
45 status
= menus
.ItemAt(i
)->CanBeInstalled(*this);
53 /*! Adds all boot menus from the list \a from that support the drive to \a to.
56 BootDrive::AddSupportedMenus(const BootMenuList
& from
, BootMenuList
& to
)
58 for (int32 i
= 0; i
< from
.CountItems(); i
++) {
59 BootMenu
* menu
= from
.ItemAt(i
);
60 if (menu
->CanBeInstalled(*this))
67 BootDrive::Path() const
74 BootDrive::IsBootDrive() const
76 BVolumeRoster volumeRoster
;
78 if (volumeRoster
.GetBootVolume(&volume
) != B_OK
)
81 BDiskDeviceRoster roster
;
83 if (roster
.FindPartitionByVolume(volume
, &device
, NULL
) == B_OK
) {
85 if (device
.GetPath(&path
) == B_OK
&& path
== fPath
)
94 BootDrive::GetDiskDevice(BDiskDevice
& device
) const
96 BDiskDeviceRoster roster
;
97 return roster
.GetDeviceForPath(fPath
.Path(), &device
);