bool GeneralView::_CanFindServer(entry_ref* ref) { // Try searching with be_roster if (be_roster->FindApp(kNotificationServerSignature, ref) == B_OK) return true; // Try with a query and take the first result BVolumeRoster vroster; BVolume volume; char volName[B_FILE_NAME_LENGTH]; vroster.Rewind(); while (vroster.GetNextVolume(&volume) == B_OK) { if ((volume.InitCheck() != B_OK) || !volume.KnowsQuery()) continue; volume.GetName(volName); BQuery *query = new BQuery(); query->SetPredicate("(BEOS:APP_SIG==\""kNotificationServerSignature"\")"); query->SetVolume(&volume); query->Fetch(); if (query->GetNextRef(ref) == B_OK) return true; } return false; }
void TTracker::Pulse() { if (!TrackerSettings().ShowVolumeSpaceBar()) return; // update the volume icon's free space bars BVolumeRoster roster; BVolume volume; while (roster.GetNextVolume(&volume) == B_NO_ERROR) { BDirectory dir; volume.GetRootDirectory(&dir); node_ref nodeRef; dir.GetNodeRef(&nodeRef); BMessage notificationMessage; notificationMessage.AddInt32("device", *(int32 *)&nodeRef.device); LockLooper(); SendNotices(kUpdateVolumeSpaceBar, ¬ificationMessage); UnlockLooper(); } }
int getextmntent_haiku(int* cookie, struct extmnttab *mp, int len) { static BLocker extmntent_locker; extmntent_locker.Lock(); BVolumeRoster roster; BVolume volume; int ret = -1; roster.Rewind(); for (int i = 0; i <= *cookie; i++) if (roster.GetNextVolume(&volume) != B_NO_ERROR) return -1; if (getmntent_haiku(cookie, (struct mnttab*)mp) == 0) { mp->mnt_major = volume.Device(); mp->mnt_minor = volume.Device(); ret = 0; } extmntent_locker.Unlock(); return ret; }
void IndexServer::AddVolume(const BVolume& volume) { // ignore volumes like / or /dev if (volume.Capacity() == 0) return; // check if volume is already in our list for (int i = 0; i < fVolumeWatcherList.CountItems(); i++) { VolumeWatcher* current = fVolumeWatcherList.ItemAt(i); if (current->Volume() == volume) return; } char name[256]; volume.GetName(name); STRACE("IndexServer::AddVolume %s\n", name); VolumeWatcher* watcher = new VolumeWatcher(volume); /* if (!watcher->Enabled()) { delete watcher; return; }*/ fVolumeWatcherList.AddItem(watcher); _SetupVolumeWatcher(watcher); watcher->StartWatching(); }
void AutoMounter::GetSettings(BMessage *_DEVICE_MAP_ONLY(message)) { #if _INCLUDES_CLASS_DEVICE_MAP message->AddBool("checkRemovableOnly", fScanParams.removableOrUnknownOnly); message->AddBool("checkCDs", fScanParams.checkCDROMs); message->AddBool("checkFloppies", fScanParams.checkFloppies); message->AddBool("checkOtherRemovables", fScanParams.checkOtherRemovable); message->AddBool("autoMountRemovableOnly", fAutomountParams.mountRemovableDisksOnly); message->AddBool("autoMountAll", fAutomountParams.mountAllFS); message->AddBool("autoMountAllBFS", fAutomountParams.mountBFS); message->AddBool("autoMountAllHFS", fAutomountParams.mountHFS); message->AddBool("initialMountAll", fInitialMountAll); message->AddBool("initialMountAllBFS", fInitialMountAllBFS); message->AddBool("initialMountRestore", fInitialMountRestore); message->AddBool("initialMountAllHFS", fInitialMountAllHFS); message->AddBool("suspended", fSuspended); // Save mounted volumes so we can optionally mount them on next // startup BVolumeRoster volumeRoster; BVolume volume; while (volumeRoster.GetNextVolume(&volume) == B_OK) { fs_info info; if (fs_stat_dev(volume.Device(), &info) == 0 && info.flags & (B_FS_IS_REMOVABLE | B_FS_IS_PERSISTENT)) message->AddString(info.device_name, info.volume_name); } #endif }
static char *getMountPoint(const char *devname) { BVolumeRoster mounts; BVolume vol; mounts.Rewind(); while (mounts.GetNextVolume(&vol) == B_NO_ERROR) { fs_info fsinfo; fs_stat_dev(vol.Device(), &fsinfo); if (strcmp(devname, fsinfo.device_name) == 0) { //char buf[B_FILE_NAME_LENGTH]; BDirectory directory; BEntry entry; BPath path; status_t rc; rc = vol.GetRootDirectory(&directory); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL); rc = directory.GetEntry(&entry); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL); rc = entry.GetPath(&path); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL); const char *str = path.Path(); BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL); /* ?! */ char *retval = (char *) allocator.Malloc(strlen(str) + 1); BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); strcpy(retval, str); return(retval); } /* if */ } /* while */ return(NULL); } /* getMountPoint */
bool ExpanderWindow::ValidateDest() { BEntry entry(fDestText->Text(), true); BVolume volume; if (!entry.Exists()) { BAlert* alert = new BAlert("destAlert", B_TRANSLATE("The destination folder does not exist."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); alert->Go(); return false; } else if (!entry.IsDirectory()) { (new BAlert("destAlert", B_TRANSLATE("The destination is not a folder."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT))->Go(); return false; } else if (entry.GetVolume(&volume) != B_OK || volume.IsReadOnly()) { (new BAlert("destAlert", B_TRANSLATE("The destination is read only."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT))->Go(); return false; } else { entry.GetRef(&fDestRef); return true; } }
void BVolumeWindow::MenusBeginning() { _inherited::MenusBeginning(); if (!fMenuBar) return; BVolume boot; BVolumeRoster().GetBootVolume(&boot); bool ejectableVolumeSelected = false; int32 count = PoseView()->SelectionList()->CountItems(); for (int32 index = 0; index < count; index++) { Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel(); if (model->IsVolume()) { BVolume volume; volume.SetTo(model->NodeRef()->device); if (volume != boot) { ejectableVolumeSelected = true; break; } } } BMenuItem* item = fMenuBar->FindItem(kUnmountVolume); if (item) item->SetEnabled(ejectableVolumeSelected); }
void BTrashWatcher::UpdateTrashIcons() { BVolume boot; if (BVolumeRoster().GetBootVolume(&boot) != B_OK) return; BDirectory trashDir; if (FSGetTrashDir(&trashDir, boot.Device()) == B_OK) { // pull out the icons for the current trash state from resources and // apply them onto the trash directory node size_t largeSize = 0; size_t smallSize = 0; const void *largeData = GetTrackerResources()->LoadResource('ICON', fTrashFull ? kResTrashFullIcon : kResTrashIcon, &largeSize); const void *smallData = GetTrackerResources()->LoadResource('MICN', fTrashFull ? kResTrashFullIcon : kResTrashIcon, &smallSize); if (largeData) trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0, largeData, largeSize); else TRESPASS(); if (smallData) trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0, smallData, smallSize); else TRESPASS(); } }
// get_volume_info bool get_volume_info( BVolume& volume, BString& volumeName, bool& isCDROM, BString& deviceName ) { bool success = false; isCDROM = false; deviceName = ""; volumeName = ""; char name[B_FILE_NAME_LENGTH]; if ( volume.GetName( name ) >= B_OK ) // disk is currently mounted { volumeName = name; dev_t dev = volume.Device(); fs_info info; if ( fs_stat_dev( dev, &info ) == B_OK ) { success = true; deviceName = info.device_name; if ( volume.IsReadOnly() ) { int i_dev = open( info.device_name, O_RDONLY ); if ( i_dev >= 0 ) { device_geometry g; if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 ) isCDROM = ( g.device_type == B_CD ); close( i_dev ); } } } } return success; }
void ControlsView::VolumeTabView::AttachedToWindow() { // Populate the menu with the persistent volumes. fVolumeRoster = new BVolumeRoster(); BVolume tempVolume; while (fVolumeRoster->GetNextVolume(&tempVolume) == B_OK) { if (!tempVolume.IsPersistent()) continue; char name[B_PATH_NAME_LENGTH]; if (tempVolume.GetName(name) != B_OK) continue; if (strcmp(name, "system") == 0 || strcmp(name, "config") == 0) { // Don't include virtual volumes. continue; } BVolume* volume = new BVolume(tempVolume); VolumeView* volumeView = new VolumeView(name, volume); VolumeTab* volumeTab = new VolumeTab(volume); AddTab(volumeView, volumeTab); } // Begin watching mount and unmount events. fVolumeRoster->StartWatching(BMessenger(this)); }
inline bool QStorageIterator::next() { BVolume volume; if (m_volumeRoster.GetNextVolume(&volume) != B_OK) return false; BDirectory directory; if (volume.GetRootDirectory(&directory) != B_OK) return false; const BPath path(&directory); fs_info fsInfo; memset(&fsInfo, 0, sizeof(fsInfo)); if (fs_stat_dev(volume.Device(), &fsInfo) != 0) return false; m_rootPath = path.Path(); m_fileSystemType = QByteArray(fsInfo.fsh_name); const QByteArray deviceName(fsInfo.device_name); m_device = (deviceName.isEmpty() ? QByteArray::number(qint32(volume.Device())) : deviceName); return true; }
/*! \brief Returns an icon for this partition. Note, that currently there are only per-device icons, i.e. the method returns the same icon for each partition of a device. But this may change in the future. \param icon Pointer to a pre-allocated BBitmap to be set to the icon of the partition. \param which Size of the icon to be retrieved. Can be \c B_MINI_ICON or \c B_LARGE_ICON. \return \c B_OK, if everything went fine, another error code otherwise. */ status_t BPartition::GetIcon(BBitmap* icon, icon_size which) const { if (icon == NULL) return B_BAD_VALUE; status_t error; if (IsMounted()) { // mounted: get the icon from the volume BVolume volume; error = GetVolume(&volume); if (error == B_OK) error = volume.GetIcon(icon, which); } else { // not mounted: retrieve the icon ourselves if (BDiskDevice* device = Device()) { BPath path; error = device->GetPath(&path); // get the icon if (error == B_OK) error = get_device_icon(path.Path(), icon, which); } else error = B_ERROR; } return error; }
bool BNavMenu::StartBuildingItemList() { BEntry entry; if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK || !entry.Exists()) return false; fItemList = new BObjectList<BMenuItem>(50); fIteratingDesktop = false; BDirectory parent; status_t status = entry.GetParent(&parent); // if ref is the root item then build list of volume root dirs fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0)); if (fFlags & kVolumesOnly) return true; Model startModel(&entry, true); if (startModel.InitCheck() != B_OK || !startModel.IsContainer()) return false; if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); else if (FSIsDeskDir(&entry)) { fIteratingDesktop = true; fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef()); AddRootItemsIfNeeded(); } else if (FSIsTrashDir(&entry)) { // the trash window needs to display a union of all the // trash folders from all the mounted volumes BVolumeRoster volRoster; volRoster.Rewind(); BVolume volume; fContainer = new EntryIteratorList(); while (volRoster.GetNextVolume(&volume) == B_OK) { if (!volume.IsPersistent()) continue; BDirectory trashDir; if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) dynamic_cast<EntryIteratorList *>(fContainer)-> AddItem(new DirectoryEntryList(trashDir)); } } else fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory *> (startModel.Node())); if (fContainer == NULL || fContainer->InitCheck() != B_OK) return false; fContainer->Rewind(); return true; }
status_t BPartition::GetIcon(uint8** _data, size_t* _size, type_code* _type) const { if (_data == NULL || _size == NULL || _type == NULL) return B_BAD_VALUE; status_t error; if (IsMounted()) { // mounted: get the icon from the volume BVolume volume; error = GetVolume(&volume); if (error == B_OK) error = volume.GetIcon(_data, _size, _type); } else { // not mounted: retrieve the icon ourselves if (BDiskDevice* device = Device()) { BPath path; error = device->GetPath(&path); // get the icon if (error == B_OK) error = get_device_icon(path.Path(), _data, _size, _type); } else error = B_ERROR; } return error; }
static char *getMountPoint(const char *devname, char *buf, size_t bufsize) { BVolumeRoster mounts; BVolume vol; mounts.Rewind(); while (mounts.GetNextVolume(&vol) == B_NO_ERROR) { fs_info fsinfo; fs_stat_dev(vol.Device(), &fsinfo); if (strcmp(devname, fsinfo.device_name) == 0) { BDirectory directory; BEntry entry; BPath path; const char *str; if ( (vol.GetRootDirectory(&directory) < B_OK) || (directory.GetEntry(&entry) < B_OK) || (entry.GetPath(&path) < B_OK) || ( (str = path.Path()) == NULL) ) return NULL; strncpy(buf, str, bufsize-1); buf[bufsize-1] = '\0'; return buf; } /* if */ } /* while */ return NULL; } /* getMountPoint */
void Feeder::HandleDeviceUpdate(BMessage *message) { int32 opcode ; BVolume *volume = new BVolume ; dev_t device ; message->FindInt32("opcode", &opcode) ; switch (opcode) { case B_DEVICE_MOUNTED : message->FindInt32("new device", &device) ; volume->SetTo(device) ; AddQuery(volume) ; // Forward the message to Indexer so that it can spawn // a new thread for volume. be_app->PostMessage(message) ; break ; case B_DEVICE_UNMOUNTED : message->FindInt32("device", &device) ; volume->SetTo(device) ; RemoveQuery(volume) ; be_app->PostMessage(message) ; break ; } delete volume ; }
void CDDBLookup::LookupAll(CDDBServer& server, bool dumpOnly, bool verbose) { BVolumeRoster roster; BVolume volume; while (roster.GetNextVolume(&volume) == B_OK) { Lookup(server, volume.Device(), dumpOnly, verbose); } }
void PanelView::ReadDisks(void) //////////////////////////////////////////////////////////////////////// { char drivename[256]; char drivepath[256]; // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); CustomListItem *item; item = new CustomListItem("..",m_Path.String(),FT_DISKBACK, 0); item->AddIcon(m_ParentIcon); m_CustomListView->AddItem(item); item->SetHeight(15.0f); // Collect available volumes... BVolumeRoster *vr = new BVolumeRoster(); if (vr) { BVolume v; while (vr->GetNextVolume(&v)==B_NO_ERROR) { if (v.GetName(drivename)==B_NO_ERROR) { if (strlen(drivename)>0) { BDirectory dir; BEntry entry; BPath path; v.GetRootDirectory(&dir); dir.GetEntry(&entry); entry.GetPath(&path); sprintf(drivepath,"%s",path.Path()); item = new CustomListItem(drivename,drivepath,FT_DISKITEM,v.FreeBytes(),v.Capacity(),v.Device()); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&v)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } } delete vr; } m_CustomListView->DoSortList(); m_CustomListView->Select(0,false); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }
status_t TaskFS::SetUpMimeTyp(void) { status_t err; //set the MimeType BMimeType mime(TASK_MIMETYPE); //later do better check bool valid = mime.IsInstalled(); if (!valid) { mime.Install(); mime.SetShortDescription(B_TRANSLATE_CONTEXT("Tasks", "Short mimetype description")); mime.SetLongDescription(B_TRANSLATE_CONTEXT("Tasks", "Long mimetype description")); //get the icon from our Ressources BResources* res = BApplication::AppResources(); if (res != NULL){ size_t size; const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "TASK_ICON", &size); if (data!=NULL) mime.SetIcon(reinterpret_cast<const uint8*>(data), size); } mime.SetPreferredApp(APP_SIG); // add default task fields to meta-mime type BMessage fields; for (int32 i = 0; sDefaultAttributes[i].attribute; i++) { fields.AddString("attr:public_name", sDefaultAttributes[i].name); fields.AddString("attr:name", sDefaultAttributes[i].attribute); fields.AddInt32("attr:type", sDefaultAttributes[i].type); fields.AddString("attr:display_as", sDefaultAttributes[i].displayAs); fields.AddBool("attr:viewable", sDefaultAttributes[i].isPublic); fields.AddBool("attr:editable", sDefaultAttributes[i].editable); fields.AddInt32("attr:width", sDefaultAttributes[i].width); fields.AddInt32("attr:alignment", B_ALIGN_LEFT); fields.AddBool("attr:extra", false); } mime.SetAttrInfo(&fields); // create indices on all volumes for the found attributes. int32 count = 8; BVolumeRoster volumeRoster; BVolume volume; while (volumeRoster.GetNextVolume(&volume) == B_OK) { for (int32 i = 0; i < count; i++) { if (sDefaultAttributes[i].isPublic == true) fs_create_index(volume.Device(), sDefaultAttributes[i].attribute, sDefaultAttributes[i].type, 0); } } } else err = B_OK; return err; }
void BTrashWatcher::UpdateTrashIcons() { BVolumeRoster roster; BVolume volume; roster.Rewind(); BDirectory trashDir; while (roster.GetNextVolume(&volume) == B_OK) { if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) { // pull out the icons for the current trash state from resources // and apply them onto the trash directory node size_t largeSize = 0; size_t smallSize = 0; const void* largeData = GetTrackerResources()->LoadResource('ICON', fTrashFull ? R_TrashFullIcon : R_TrashIcon, &largeSize); const void* smallData = GetTrackerResources()->LoadResource('MICN', fTrashFull ? R_TrashFullIcon : R_TrashIcon, &smallSize); #ifdef HAIKU_TARGET_PLATFORM_HAIKU size_t vectorSize = 0; const void* vectorData = GetTrackerResources()->LoadResource( B_VECTOR_ICON_TYPE, fTrashFull ? R_TrashFullIcon : R_TrashIcon, &vectorSize); if (vectorData) { trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, vectorData, vectorSize); } else TRESPASS(); #endif if (largeData) { trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0, largeData, largeSize); } else TRESPASS(); if (smallData) { trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0, smallData, smallSize); } else TRESPASS(); } } }
CDDBDaemon::CDDBDaemon() : BApplication("application/x-vnd.Haiku-cddb_daemon"), fVolumeRoster(new BVolumeRoster) { fVolumeRoster->StartWatching(); BVolume volume; printf("Checking currently mounted volumes ...\n"); while (fVolumeRoster->GetNextVolume(&volume) == B_OK) { if (_Lookup(volume.Device()) != B_OK) { continue; } } printf("Checking complete. Listening for device mounts.\n"); }
/*! \brief Returns the mount point for the partition. If the partition is mounted this is the actual mount point. If it is not mounted, but contains a file system, derived from the partition name the name for a not yet existing directory in the root directory is constructed and the path to it returned. For partitions not containing a file system the method returns an error. \param mountPoint Pointer to the path to be set to refer the mount point (respectively potential mount point) of the partition. \return \c B_OK, if everything went fine, an error code otherwise. */ status_t BPartition::GetMountPoint(BPath* mountPoint) const { if (!mountPoint || !ContainsFileSystem()) return B_BAD_VALUE; // if the partition is mounted, return the actual mount point BVolume volume; if (GetVolume(&volume) == B_OK) { BDirectory dir; status_t error = volume.GetRootDirectory(&dir); if (error == B_OK) error = mountPoint->SetTo(&dir, NULL); return error; } // partition not mounted // get the volume name const char* volumeName = ContentName(); if (!volumeName || strlen(volumeName) == 0) volumeName = Name(); if (!volumeName || strlen(volumeName) == 0) volumeName = "unnamed volume"; // construct a path name from the volume name // replace '/'s and prepend a '/' BString mountPointPath(volumeName); mountPointPath.ReplaceAll('/', '-'); mountPointPath.Insert("/", 0); // make the name unique BString basePath(mountPointPath); int counter = 1; while (true) { BEntry entry; status_t error = entry.SetTo(mountPointPath.String()); if (error != B_OK) return error; if (!entry.Exists()) break; mountPointPath = basePath; mountPointPath << counter; counter++; } return mountPoint->SetTo(mountPointPath.String()); }
void TReplicantTray::InitAddOnSupport() { // list to maintain refs to each rep added/deleted fItemList = new BList(); bool haveKey = false; BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { path.Append(kDeskbarSecurityCodeFile); BFile file(path.Path(),B_READ_ONLY); if (file.InitCheck() == B_OK && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)) == sizeof(fDeskbarSecurityCode)) haveKey = true; } if (!haveKey) { // create the security code bigtime_t real = real_time_clock_usecs(); bigtime_t boot = system_time(); // two computers would have to have exactly matching clocks, and launch // Deskbar at the exact same time into the bootsequence in order for // their security-ID to be identical fDeskbarSecurityCode = ((real & 0xffffffffULL) << 32) | (boot & 0xffffffffULL); if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { path.Append(kDeskbarSecurityCodeFile); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() == B_OK) file.Write(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)); } } // for each volume currently mounted // index the volume with our indices BVolumeRoster roster; BVolume volume; while (roster.GetNextVolume(&volume) == B_OK) { fs_create_index(volume.Device(), kStatusPredicate, B_STRING_TYPE, 0); RunAddOnQuery(&volume, kEnabledPredicate); } // we also watch for volumes mounted and unmounted watch_node(NULL, B_WATCH_MOUNT | B_WATCH_ATTR, this, Window()); }
status_t TeamWindow::_RetrieveMatchingSourceEntries(const BString& path, BStringList* _entries) { BPath filePath(path); status_t error = filePath.InitCheck(); if (error != B_OK) return error; _entries->MakeEmpty(); BQuery query; BString predicate; query.PushAttr("name"); query.PushString(filePath.Leaf()); query.PushOp(B_EQ); error = query.GetPredicate(&predicate); if (error != B_OK) return error; BVolumeRoster roster; BVolume volume; while (roster.GetNextVolume(&volume) == B_OK) { if (!volume.KnowsQuery()) continue; if (query.SetVolume(&volume) != B_OK) continue; error = query.SetPredicate(predicate.String()); if (error != B_OK) continue; if (query.Fetch() != B_OK) continue; entry_ref ref; while (query.GetNextRef(&ref) == B_OK) { filePath.SetTo(&ref); _entries->Add(filePath.Path()); } query.Clear(); } return B_OK; }
/*! \brief Finds a BPartition by BVolume. */ status_t BDiskDeviceRoster::FindPartitionByVolume(const BVolume& volume, BDiskDevice* device, BPartition** _partition) { class FindPartitionVisitor : public BDiskDeviceVisitor { public: FindPartitionVisitor(dev_t volume) : fVolume(volume) { } virtual bool Visit(BDiskDevice* device) { return Visit(device, 0); } virtual bool Visit(BPartition* partition, int32 level) { BVolume volume; return partition->GetVolume(&volume) == B_OK && volume.Device() == fVolume; } private: dev_t fVolume; } visitor(volume.Device()); if (VisitEachMountedPartition(&visitor, device, _partition)) return B_OK; return B_ENTRY_NOT_FOUND; }
void Feeder::StartWatching() { BVolume *volume = new BVolume ; while (fVolumeRoster.GetNextVolume(volume) != B_BAD_VALUE) { if ((volume->IsRemovable() && !fMonitorRemovableDevices) || !volume->KnowsQuery()) continue ; AddQuery(volume) ; volume = new BVolume ; } fVolumeRoster.StartWatching(this) ; }
status_t CDDBLookup::Lookup(CDDBServer& server, const char* path, bool dumpOnly, bool verbose) { BVolumeRoster roster; BVolume volume; while (roster.GetNextVolume(&volume) == B_OK) { fs_info info; if (fs_stat_dev(volume.Device(), &info) != B_OK) continue; if (strcmp(path, info.device_name) == 0) return Lookup(server, volume.Device(), dumpOnly, verbose); } return B_ENTRY_NOT_FOUND; }
void NameAttributeText::ReadValue(BString *result) { #ifdef DEBUG // x86 support :-) if ((modifiers() & B_CAPS_LOCK) != 0) { if (fModel->IsVolume()) { BVolumeRoster roster; roster.Rewind(); BVolume volume; char device = 'A'; while (roster.GetNextVolume(&volume) == B_OK) { char name[256]; if (volume.GetName(name) == B_OK && strcmp(name, fModel->Name()) == 0) { *result += device; *result += ':'; fValueDirty = false; return; } device++; } } const char *modelName = fModel->Name(); bool hasDot = strstr(".", modelName) != 0; for (int32 index = 0; index < 8; index++) { if (!modelName[index] || modelName[index] == '.') break; *result += toupper(modelName[index]); } if (hasDot) { modelName = strstr(".", modelName); for (int32 index = 0; index < 4; index++) { if (!modelName[index]) break; *result += toupper(modelName[index]); } } else if (fModel->IsExecutable()) *result += ".EXE"; } else #endif *result = fModel->Name(); fValueDirty = false; }
void ControlsView::VolumeTabView::_AddVolume(dev_t device) { // Make sure the volume is not already in the menu. for (int i = 0; VolumeTab* item = (VolumeTab*)TabAt(i); i++) { if (item->Volume()->Device() == device) return; } BVolume* volume = new BVolume(device); VolumeTab* item = new VolumeTab(volume); char name[B_PATH_NAME_LENGTH]; volume->GetName(name); AddTab(new VolumeView(name, volume), item); Invalidate(); }