当前位置: 首页>>代码示例>>C++>>正文


C++ BVolume类代码示例

本文整理汇总了C++中BVolume的典型用法代码示例。如果您正苦于以下问题:C++ BVolume类的具体用法?C++ BVolume怎么用?C++ BVolume使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BVolume类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BQuery

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;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:31,代码来源:GeneralView.cpp

示例2:

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, &notificationMessage);
		UnlockLooper();
	}
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:25,代码来源:Tracker.cpp

示例3: getextmntent_haiku

    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;
    }
开发者ID:s3thi,项目名称:zfs-haiku,代码行数:25,代码来源:mntent.cpp

示例4: VolumeWatcher

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();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:27,代码来源:IndexServer.cpp

示例5:

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
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:30,代码来源:AutoMounter.cpp

示例6: while

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 */
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:34,代码来源:beos.cpp

示例7: entry

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;
	}
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:29,代码来源:ExpanderWindow.cpp

示例8: BVolumeRoster

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);
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:30,代码来源:VolumeWindow.cpp

示例9: GetTrackerResources

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();
	}
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:32,代码来源:TrashWatcher.cpp

示例10: get_volume_info

// 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;
}
开发者ID:FLYKingdom,项目名称:vlc,代码行数:33,代码来源:InterfaceWindow.cpp

示例11: BVolumeRoster

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));
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:30,代码来源:ControlsView.cpp

示例12: next

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;
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:27,代码来源:qstorageinfo_unix.cpp

示例13: GetVolume

/*!	\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;
}
开发者ID:mmanley,项目名称:Antares,代码行数:39,代码来源:Partition.cpp

示例14: uint8

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;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:60,代码来源:NavMenu.cpp

示例15: while

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 */
开发者ID:Alexander-r,项目名称:physfs,代码行数:31,代码来源:physfs_platform_haiku.cpp


注:本文中的BVolume类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。