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


C++ Partition::VolumeName方法代码示例

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


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

示例1: vol

void
AutoMounter::UnmountAndEjectVolume(BMessage *_DEVICE_MAP_ONLY(message))
{
#if _INCLUDES_CLASS_DEVICE_MAP
	dev_t device;
	if (message->FindInt32("device_id", &device) != B_OK)
		return;

	PRINT(("Unmount device %i\n", device));
	
	AutoLock<BLooper> lock(this);

	UnmountDeviceParams params;
	params.device = device;
	params.result = B_OK;
	Partition *partition = fList.EachMountedPartition(UnmountIfMatchingID, 
		&params);
	
	if (!partition) {
		PRINT(("Couldn't unmount partition.  Rescan and try again\n"));

		// could not find partition - must have been mounted by someone
		// else
		// sync up and try again
		// this should really be handled by watching for mount and unmount
		// events like the tracker does, not doing that because it is
		// a bigger change and we are close to freezing
		fList.UnmountDisappearedPartitions();
		
		DeviceScanParams syncRescanParams;
		syncRescanParams.checkFloppies = true;
		syncRescanParams.checkCDROMs = true;
		syncRescanParams.checkOtherRemovable = true;
		syncRescanParams.removableOrUnknownOnly = true;
		
		fList.UpdateChangedDevices(&syncRescanParams);
		partition = fList.EachMountedPartition(UnmountIfMatchingID, &params);	
	}
	
	if (!partition) {
		PRINT(("Device not in list, unmounting directly\n"));

		char path[B_FILE_NAME_LENGTH];

		BVolume vol(device);
		status_t err = vol.InitCheck();
		if (err == B_OK) {
			BDirectory mountPoint;		
			if (err == B_OK)
				err = vol.GetRootDirectory(&mountPoint);		
	
			BPath mountPointPath;
			if (err == B_OK)
				err = mountPointPath.SetTo(&mountPoint, ".");
	
			if (err == B_OK)
				strcpy(path, mountPointPath.Path());	
		}

		if (err == B_OK) {
			PRINT(("unmounting '%s'\n", path));
			err = unmount(path);
		}
		
		if (err == B_OK) {
			PRINT(("deleting '%s'\n", path));
			err = rmdir(path);
		}

		if (err != B_OK) {
		
			PRINT(("error %s\n", strerror(err)));
			BString text;
			text << "Could not unmount disk";
			(new BAlert("", text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL, 
				B_WARNING_ALERT))->Go(0);
		}
		
	} else if (params.result != B_OK) {
		BString text;
		text << "Could not unmount disk  " << partition->VolumeName() <<
			". An item on the disk is busy.";
		(new BAlert("", text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL, 
			B_WARNING_ALERT))->Go(0);
	}
#endif
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:87,代码来源:AutoMounter.cpp


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