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


C++ BDirectory::GetNodeRef方法代码示例

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


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

示例1:

bool
AddOnManager::_FindDecoder(const media_format& format, const BPath& path,
	entry_ref* _decoderRef)
{
	node_ref nref;
	BDirectory directory;
	if (directory.SetTo(path.Path()) != B_OK
		|| directory.GetNodeRef(&nref) != B_OK) {
		return false;
	}

	decoder_info* info;
	for (fDecoderList.Rewind(); fDecoderList.GetNext(&info);) {
		if (info->ref.directory != nref.node)
			continue;

		media_format* decoderFormat;
		for (info->formats.Rewind(); info->formats.GetNext(&decoderFormat);) {
			// check if the decoder matches the supplied format
			if (!decoderFormat->Matches(&format))
				continue;

			*_decoderRef = info->ref;
			return true;
		}
	}
	return false;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:28,代码来源:AddOnManager.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: first

status_t
PathHandler::_GetClosest(const char* path, bool updatePath, node_ref& nodeRef)
{
	BPath first(path);
	BString missing;

	while (true) {
		// try to find the first part of the path that exists
		BDirectory directory;
		status_t status = directory.SetTo(first.Path());
		if (status == B_OK) {
			status = directory.GetNodeRef(&nodeRef);
			if (status == B_OK) {
				if (updatePath) {
					// normalize path
					status = fPath.SetTo(&directory, NULL, true);
					if (status == B_OK) {
						fPath.Append(missing.String());
						fPathLength = strlen(fPath.Path());
					}
				}
				return status;
			}
		}

		if (updatePath) {
			if (missing.Length() > 0)
				missing.Prepend("/");
			missing.Prepend(first.Leaf());
		}

		if (first.GetParent(&first) != B_OK)
			return B_ERROR;
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:35,代码来源:PathMonitor.cpp

示例4: info

void
PrinterListView::_AddPrinter(BDirectory& printer, bool calculateLayout)
{
	BString state;
	node_ref node;
		// If the entry is a directory
	if (printer.InitCheck() == B_OK
		&& printer.GetNodeRef(&node) == B_OK
		&& _FindItem(&node) == NULL
		&& printer.ReadAttrString(PSRV_PRINTER_ATTR_STATE, &state) == B_OK
		&& state == "free") {
			// Check it's Mime type for a spool director
		BNodeInfo info(&printer);
		char buffer[256];

		if (info.GetType(buffer) == B_OK
			&& strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
				// Yes, it is a printer definition node
			AddItem(new PrinterItem(static_cast<PrintersWindow*>(Window()),
				printer, fLayoutData));
			if (calculateLayout)
				_LayoutPrinterItems();
		}
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:25,代码来源:PrinterListView.cpp

示例5: CheckTrashDirs

void
BTrashWatcher::MessageReceived(BMessage* message)
{
	if (message->what != B_NODE_MONITOR) {
		_inherited::MessageReceived(message);
		return;
	}

	switch (message->FindInt32("opcode")) {
		case B_ENTRY_CREATED:
			if (!fTrashFull) {
				fTrashFull = true;
				UpdateTrashIcons();
			}
			break;

		case B_ENTRY_MOVED:
		{
			// allow code to fall through if move is from/to trash
			// but do nothing for moves in the same directory
			ino_t toDir;
			ino_t fromDir;
			message->FindInt64("from directory", &fromDir);
			message->FindInt64("to directory", &toDir);
			if (fromDir == toDir)
				break;
		} // fall thru
		case B_DEVICE_UNMOUNTED: // fall thru
		case B_ENTRY_REMOVED:
		{
			bool full = CheckTrashDirs();
			if (fTrashFull != full) {
				fTrashFull = full;
				UpdateTrashIcons();
			}
			break;
		}
		// We should handle DEVICE_UNMOUNTED here too to remove trash

		case B_DEVICE_MOUNTED:
		{
			dev_t device;
			BDirectory trashDir;
			if (message->FindInt32("new device", &device) == B_OK
				&& FSGetTrashDir(&trashDir, device) == B_OK) {
				node_ref trashNode;
				trashDir.GetNodeRef(&trashNode);
				TTracker::WatchNode(&trashNode, B_WATCH_DIRECTORY, this);
				fTrashNodeList.AddItem(new node_ref(trashNode));

				// Check if the new volume has anything trashed.
				if (CheckTrashDirs() && !fTrashFull) {
					fTrashFull = true;
					UpdateTrashIcons();
				}
			}
			break;
		}
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:60,代码来源:TrashWatcher.cpp

示例6:

bool
AddOnManager::_FindDecoder(const media_format& format, const BPath& path,
	xfer_entry_ref* _decoderRef)
{
	node_ref nref;
	BDirectory directory;
	if (directory.SetTo(path.Path()) != B_OK
		|| directory.GetNodeRef(&nref) != B_OK) {
		return false;
	}

	decoder_info* info;
	for (fDecoderList.Rewind(); fDecoderList.GetNext(&info);) {
		if (info->ref.directory != nref.node)
			continue;

		media_format* decoderFormat;
		for (info->formats.Rewind(); info->formats.GetNext(&decoderFormat);) {
			// check if the decoder matches the supplied format
			if (!decoderFormat->Matches(&format))
				continue;

			printf("AddOnManager::GetDecoderForFormat: found decoder %s/%s "
				"for encoding %" B_PRIu32 "\n", path.Path(), info->ref.name,
				decoderFormat->Encoding());

			*_decoderRef = info->ref;
			return true;
		}
	}
	return false;
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:32,代码来源:AddOnManager.cpp

示例7: locker

void
AddOnManager::_RegisterAddOns()
{
	CALLED();
	BAutolock locker(this);
	status_t err;

	fHandler = new MonitorHandler(this);
	fAddOnMonitor = new AddOnMonitor(fHandler);

	err = fAddOnMonitor->InitCheck();
	if (err != B_OK) {
		ERROR("AddOnManager::RegisterAddOns(): fAddOnMonitor->InitCheck() "
			"returned %s\n", strerror(err));
		return;
	}

	const directory_which directories[] = {
		B_USER_ADDONS_DIRECTORY,
		B_COMMON_ADDONS_DIRECTORY,
		B_BEOS_ADDONS_DIRECTORY
	};
	const char* subDirectories[] = {
		"input_server/devices",
		"input_server/filters",
		"input_server/methods"
	};
	int32 subDirectoryCount = sizeof(subDirectories) / sizeof(const char*);

	node_ref nref;
	BDirectory directory;
	BPath path;
	// when safemode, only B_BEOS_ADDONS_DIRECTORY is used
	for (uint32 i = fSafeMode ? 2 : 0;
			i < sizeof(directories) / sizeof(directory_which); i++) {
		for (int32 j = 0; j < subDirectoryCount; j++) {
			if (find_directory(directories[i], &path) == B_OK
				&& path.Append(subDirectories[j]) == B_OK
				&& directory.SetTo(path.Path()) == B_OK
				&& directory.GetNodeRef(&nref) == B_OK) {
				fHandler->AddDirectory(&nref);
			}
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:45,代码来源:AddOnManager.cpp

示例8:

void
BTrashWatcher::WatchTrashDirs()
{
	BVolumeRoster volRoster;
	volRoster.Rewind();
	BVolume	volume;
	while (volRoster.GetNextVolume(&volume) == B_OK) {
		if (volume.IsReadOnly() || !volume.IsPersistent())
			continue;

		BDirectory trashDir;
		if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
			node_ref trash_node;
			trashDir.GetNodeRef(&trash_node);
			watch_node(&trash_node, B_WATCH_DIRECTORY, this);
			fTrashNodeList.AddItem(new node_ref(trash_node));
		}
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:19,代码来源:TrashWatcher.cpp

示例9: entry

void
TTracker::ReadyToRun()
{
	gStatusWindow = new BStatusWindow();
	InitMimeTypes();
	InstallDefaultTemplates();
	InstallIndices();
	
	HideVarDir();

	fTrashWatcher = new BTrashWatcher();
	fTrashWatcher->Run();

	fClipboardRefsWatcher = new BClipboardRefsWatcher();
	fClipboardRefsWatcher->Run();
	
	fAutoMounter = new AutoMounter();
	fAutoMounter->Run();
	
	fTaskLoop = new StandAloneTaskLoop(true);

	bool openDisksWindow = false;

	// open desktop window 
	BContainerWindow *deskWindow = NULL;
	BVolume	bootVol;
	BVolumeRoster().GetBootVolume(&bootVol);
	BDirectory deskDir;
	if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) {
		// create desktop
		BEntry entry;
		deskDir.GetEntry(&entry);
		Model *model = new Model(&entry);
		if (model->InitCheck() == B_OK) {
			AutoLock<WindowList> lock(&fWindowList);
			deskWindow = new BDeskWindow(&fWindowList);
			AutoLock<BWindow> windowLock(deskWindow);
			deskWindow->CreatePoseView(model);
			deskWindow->Init();
		} else
			delete model;

		// open previously open windows
		attr_info attrInfo;
		if (!BootedInSafeMode()
			&& deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) {
			char *buffer = (char *)malloc((size_t)attrInfo.size);
			BMessage message;
			if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size)
				== attrInfo.size
				&& message.Unflatten(buffer) == B_OK) {

				node_ref nodeRef;
				deskDir.GetNodeRef(&nodeRef);
	
				int32 stateMessageCounter = 0;
				const char *path;
				for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) {
					int8 flags = 0;
					for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) {
						BEntry entry(path, true);
						if (entry.InitCheck() == B_OK) {
							Model *model = new Model(&entry);
							if (model->InitCheck() == B_OK && model->IsContainer()) {
								BMessage state;
								bool restoreStateFromMessage = false;
								if ((flags & kOpenWindowHasState) != 0
									&& message.FindMessage("window state", stateMessageCounter++, &state) == B_OK)
									restoreStateFromMessage = true;

								if (restoreStateFromMessage)
									OpenContainerWindow(model, 0, kOpen, 
										kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U),
										false, &state);
								else
									OpenContainerWindow(model, 0, kOpen, 
										kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U));
							} else
								delete model;
						}
					}
				}
	
				if (message.HasBool("open_disks_window"))
					openDisksWindow = true;
			}
			free(buffer);
		}
	}

	// create model for root of everything
	if (deskWindow) {
		BEntry entry("/");
		Model model(&entry);
		if (model.InitCheck() == B_OK) {

			if (TrackerSettings().ShowDisksIcon()) {
				// add the root icon to desktop window
				BMessage message;
				message.what = B_NODE_MONITOR;
//.........这里部分代码省略.........
开发者ID:Ithamar,项目名称:cosmoe,代码行数:101,代码来源:Tracker.cpp

示例10: SearchAddOns

void BeHappy::SearchAddOns()
{
	// on vide les listes
	{
		BPath *p;
		while ((p=(BPath*)addOnsPaths.RemoveItem((int32)0))!=NULL)
			delete p;
			
		BString *s;
		while ((s=(BString*)addOnsNames.RemoveItem((int32)0))!=NULL)
			delete s;
	}
		
	// d'abord on cherche le dossier
	app_info myInfo;
	be_app->GetAppInfo(&myInfo);
	BEntry appEntry(&(myInfo.ref));
	BDirectory addOnsDir;
	appEntry.GetParent(&addOnsDir);
	
	// parcours de tous les fichiers du dossier
	if (addOnsDir.SetTo(&addOnsDir,"Add-ons")==B_OK)
	{
		BEntry addOn;
		while (addOnsDir.GetNextEntry(&addOn,true) == B_OK)
		{
			BPath *addOnPath = new BPath;
			addOn.GetPath(addOnPath);
			// extraction du type MIME
			{
				BNode myNode(&addOn);
								
				BNodeInfo myNodeInfo(&myNode);
				char mimeType[256];
				myNodeInfo.GetType(mimeType);
				if (BString("application/x-vnd.Be-elfexecutable") != mimeType)
					continue;
			}
			
			// on est sûrs que c'est un Add-on
			BString *projName = new BString;
			if (CheckAddOn(addOnPath->Path(),true,projName))
			{
				addOnsPaths.AddItem(addOnPath);
				addOnsNames.AddItem(projName);
			}
			else
			{
				delete addOnPath;
				delete projName;
			}
			
			// si c'est la première fois que SearchAddOns est appelé, on doit activer le node monitor
			if (!addOnsSearched)
			{
				addOnsSearched = true;
				
				node_ref myRef;
				addOnsDir.GetNodeRef(&myRef);
				watch_node(&myRef,B_WATCH_DIRECTORY,be_app_messenger);
			}
		}
	}
	else
	{
		BAlert *myAlert = new BAlert("BeHappy",T("Can't find Add-ons folder"),
			"Quit",NULL,NULL,B_WIDTH_AS_USUAL,B_STOP_ALERT);
		
		myAlert->Go();
		PostMessage(B_QUIT_REQUESTED);
	}
}
开发者ID:mmadia,项目名称:behappy-svn_clone,代码行数:72,代码来源:BeHappy.cpp

示例11: AddOnCreated

void
AddOnManager::_RegisterAddOns()
{
	class CodecHandler : public AddOnMonitorHandler {
	private:
		AddOnManager* fManager;

	public:
		CodecHandler(AddOnManager* manager)
		{
			fManager = manager;
		}

		virtual void AddOnCreated(const add_on_entry_info* entryInfo)
		{
		}

		virtual void AddOnEnabled(const add_on_entry_info* entryInfo)
		{
			entry_ref ref;
			make_entry_ref(entryInfo->dir_nref.device,
				entryInfo->dir_nref.node, entryInfo->name, &ref);
			fManager->_RegisterAddOn(ref);
		}

		virtual void AddOnDisabled(const add_on_entry_info* entryInfo)
		{
			entry_ref ref;
			make_entry_ref(entryInfo->dir_nref.device,
				entryInfo->dir_nref.node, entryInfo->name, &ref);
			fManager->_UnregisterAddOn(ref);
		}

		virtual void AddOnRemoved(const add_on_entry_info* entryInfo)
		{
		}
	};

	fAddOnMonitorHandler = new CodecHandler(this);
	fAddOnMonitor = new AddOnMonitor(fAddOnMonitorHandler);

	// get safemode option for disabling user add-ons

	char buffer[16];
	size_t size = sizeof(buffer);

	bool disableUserAddOns = _kern_get_safemode_option(
			B_SAFEMODE_DISABLE_USER_ADD_ONS, buffer, &size) == B_OK
		&& (!strcasecmp(buffer, "true")
			|| !strcasecmp(buffer, "yes")
			|| !strcasecmp(buffer, "on")
			|| !strcasecmp(buffer, "enabled")
			|| !strcmp(buffer, "1"));

	node_ref nref;
	BDirectory directory;
	BPath path;
	for (uint i = 0; i < sizeof(sDirectories) / sizeof(directory_which); i++) {
		if (disableUserAddOns && i <= 1)
			continue;

		if (find_directory(sDirectories[i], &path) == B_OK
			&& path.Append("media/plugins") == B_OK
			&& directory.SetTo(path.Path()) == B_OK
			&& directory.GetNodeRef(&nref) == B_OK) {
			fAddOnMonitorHandler->AddDirectory(&nref);
				// NOTE: This may already start registering add-ons in the
				// AddOnMonitor looper thread after the call returns!
		}
	}
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:71,代码来源:AddOnManager.cpp


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