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


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

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


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

示例1: TrackerSettings

static Partition *
UnmountIfMatchingID(Partition *_DEVICE_MAP_ONLY(partition),
	void *_DEVICE_MAP_ONLY(castToParams))
{
	UnmountDeviceParams *params = (UnmountDeviceParams *)castToParams;
	
	if (partition->VolumeDeviceID() == params->device) {

		TTracker *tracker = dynamic_cast<TTracker *>(be_app);
		if (tracker && tracker->QueryActiveForDevice(params->device)) {
			BString text;
			text << "To unmount " << partition->VolumeName() << " some query "
			"windows have to be closed. Would you like to close the query "
			"windows?";
			if ((new BAlert("", text.String(), "Cancel", "Close and unmount", NULL,
				B_WIDTH_FROM_LABEL))->Go() == 0)
				return partition;
			tracker->CloseActiveQueryWindows(params->device);
		}

		params->result = partition->Unmount();
		Device *device = partition->GetDevice();
		bool deviceHasMountedPartitions = false;

		if (params->result == B_OK && device->Removable()) {
			for (int32 sessionIndex = 0; ; sessionIndex++) {
				Session *session = device->SessionAt(sessionIndex);
				if (!session)
					break;

				for (int32 partitionIndex = 0; ; partitionIndex++) {
					Partition *partition = session->PartitionAt(partitionIndex);
					if (!partition)
						break;

					if (partition->Mounted() == kMounted) {
						deviceHasMountedPartitions = true;
						break;
					}
				}
			}

			if (!deviceHasMountedPartitions
				&& TrackerSettings().EjectWhenUnmounting())
				params->result = partition->GetDevice()->Eject();
		}

		return partition;
	}

	return NULL;
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:52,代码来源:AutoMounter.cpp

示例2: root_entry

void
AutoMounter::MessageReceived(BMessage *message)
{
	switch (message->what) {
#if _INCLUDES_CLASS_DEVICE_MAP
		case kAutomounterRescan:
			RescanDevices();
			break;

		case kStartPolling:	
			// PRINT(("starting the automounter\n"));
			
			fScanThread = spawn_thread(AutoMounter::WatchVolumeBinder, 
#if DEBUG				
				"HiroshiLikesAtomountScan",	// long story
#else
				"AutomountScan",
#endif				
				B_LOW_PRIORITY, this);
			resume_thread(fScanThread);
			break;

		case kMountVolume:
			MountVolume(message);
			break;

		case kUnmountVolume:
			UnmountAndEjectVolume(message);
			break;

		case kSetAutomounterParams:
			{
				bool rescanNow = false;
				message->FindBool("rescanNow", &rescanNow);
				SetParams(message, rescanNow);
				WriteSettings();
				break;
			}

		case kMountAllNow:
			RescanDevices();
			MountAllNow();
			break;

		case kSuspendAutomounter:
			SuspendResume(true);
			break;

		case kResumeAutomounter:
			SuspendResume(false);
			break;

		case kTryMountingFloppy:
			TryMountingFloppy();
			break;

		case B_NODE_MONITOR:
			{
				int32 opcode;
				if (message->FindInt32("opcode", &opcode) != B_OK)
					break;
	
				switch (opcode) {
					case B_DEVICE_MOUNTED: {
						WRITELOG(("** Received Device Mounted Notification"));
						dev_t device;
						if (message->FindInt32("new device", &device) == B_OK) {
							Partition *partition =  FindPartition(device);
							if (partition == NULL || partition->Mounted() != kMounted) {
								WRITELOG(("Device %i not in device list.  Someone mounted it outside "
									"of Tracker", device));
		
								//
								// This is the worst case.  Someone has mounted
								// something from outside of tracker.  
								// Unfortunately, there's no easy way to tell which
								// partition was just mounted (or if we even know about the device),
								// so stop watching all nodes, rescan to see what is now mounted,
								// and start watching again.
								//
								RescanDevices();
							} else
								WRITELOG(("Found partition\n"));
						} else {
							WRITELOG(("ERROR: Could not find mounted device ID in message"));
							PRINT_OBJECT(*message);
						}
	
						break;
					}
	
	
					case B_DEVICE_UNMOUNTED: {
						WRITELOG(("*** Received Device Unmounted Notification"));
						dev_t device;
						if (message->FindInt32("device", &device) == B_OK) {
							Partition *partition = FindPartition(device);
	
							if (partition != 0) {
								WRITELOG(("Found device in device list. Updating state to unmounted."));
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:101,代码来源:AutoMounter.cpp


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