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


C++ BNode::SetTo方法代码示例

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


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

示例1: memIO

/*
 * this method is not currently being used, but it may be useful in the future...
 */
status_t
DefaultCatalog::ReadFromAttribute(const entry_ref &appOrAddOnRef)
{
	BNode node;
	status_t res = node.SetTo(&appOrAddOnRef);
	if (res != B_OK)
		return B_ENTRY_NOT_FOUND;

	attr_info attrInfo;
	res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
	if (res != B_OK)
		return B_NAME_NOT_FOUND;
	if (attrInfo.type != B_MESSAGE_TYPE)
		return B_BAD_TYPE;

	size_t size = attrInfo.size;
	auto_ptr<char> buf(new(std::nothrow) char [size]);
	if (buf.get() == NULL)
		return B_NO_MEMORY;
	res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
		buf.get(), size);
	if (res < (ssize_t)size)
		return res < B_OK ? res : B_BAD_DATA;

	BMemoryIO memIO(buf.get(), size);
	res = Unflatten(&memIO);

	return res;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:32,代码来源:DefaultCatalog.cpp

示例2: fDocIO

CDoc::CDoc(const char* mimetype, BLooper *target, const entry_ref *doc)
	: fDocIO(NULL)
	, fSavePanel(NULL)
	, fMimeType(mimetype ? mimetype : "")
	, fDirty(false)
	, fReadOnly(false)
	, fEncoding(B_UNICODE_UTF8)
	, fLineEndType(kle_LF)
{
	fDocIO = new CLocalDocIO(this, doc, target);
	FailNil(fDocIO);
	if (doc)
	{
		BEntry e;
		FailOSErr(e.SetTo(doc, true));
		FailOSErr(e.GetParent(&gCWD));

		BNode node;
		FailOSErr(node.SetTo(doc));

		struct stat st;
		FailOSErr(node.GetStat(&st));

		fReadOnly = !((gUid == st.st_uid && (S_IWUSR & st.st_mode))
						||	(gGid == st.st_gid && (S_IWGRP & st.st_mode))
						||	(S_IWOTH & st.st_mode));

		char s[NAME_MAX];
		if (BNodeInfo(&node).GetType(s) == B_OK)
			fMimeType = s;
	}
	sfDocList.push_back(this);
}
开发者ID:diversys,项目名称:pe,代码行数:33,代码来源:CDoc.cpp

示例3: BBitmap

TListItem::TListItem(BEntry *entry, bool source)
	:	BListItem()
{
	BNode		node;
	BNodeInfo	node_info;
	is_source = source;

	// try to get node info for this entry
	if ((node.SetTo(entry) == B_NO_ERROR) && (node_info.SetTo(&node) == B_NO_ERROR)) 
	{
		// cache name
		entry->GetName(fName);
		// create bitmap large enough for icon
		fIcon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON -1 ), B_COLOR_8_BIT);
		// cache the icon
		node_info.GetTrackerIcon(fIcon, B_MINI_ICON);
		// adjust size of item to fit icon
		SetHeight(fIcon->Bounds().Height() + kITEM_MARGIN);
		// cache ref
		entry->GetRef(&fRef);
		//save = true;
	}
	else 
	{
		// no icon
		fIcon = NULL; 
		// make dummy for seperators
		strcpy(fName, " "); 
		SetHeight(kDEFAULT_ITEM_HEIGHT);
		save = true;
	}
	
	super = false;
}
开发者ID:HaikuArchives,项目名称:Niue,代码行数:34,代码来源:listview.cpp

示例4: GetMessageEntryRef

/*!	Synchronizes the message flags/state from the server with the local
	one.
*/
void
IMAPFolder::SyncMessageFlags(uint32 uid, uint32 mailboxFlags)
{
	if (uid > LastUID())
		return;

	entry_ref ref;
	BNode node;

	while (true) {
		status_t status = GetMessageEntryRef(uid, ref);
		if (status == B_ENTRY_NOT_FOUND) {
			// The message does not exist anymore locally, delete it on the
			// server
			// TODO: copy it to the trash directory first!
			fProtocol.UpdateMessageFlags(*this, uid, IMAP::kDeleted);
			return;
		}
		if (status == B_OK)
			status = node.SetTo(&ref);
		if (status == B_TIMED_OUT) {
			// We don't know the message state yet
			fPendingFlagsMap.insert(std::make_pair(uid, mailboxFlags));
		}
		if (status != B_OK)
			return;

		break;
	}
	fSynchronizedUIDsSet.insert(uid);

	uint32 previousFlags = MessageFlags(uid);
	uint32 currentFlags = previousFlags;
	if (_MailToIMAPFlags(node, currentFlags) != B_OK)
		return;

	// Compare flags to previous/current flags, and update either the
	// message on the server, or the message locally (or even both)

	uint32 nextFlags = mailboxFlags;
	_TestMessageFlags(previousFlags, mailboxFlags, currentFlags,
		IMAP::kSeen, nextFlags);
	_TestMessageFlags(previousFlags, mailboxFlags, currentFlags,
		IMAP::kAnswered, nextFlags);

	if (nextFlags != previousFlags)
		_WriteFlags(node, nextFlags);
	if (currentFlags != nextFlags) {
		// Update mail message attributes
		BMessage attributes;
		_IMAPToMailFlags(nextFlags, attributes);
		node << attributes;

		fFlagsMap[uid] = nextFlags;
	}
	if (mailboxFlags != nextFlags) {
		// Update server flags
		fProtocol.UpdateMessageFlags(*this, uid, nextFlags);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:63,代码来源:IMAPFolder.cpp

示例5: strerror

int
main(int argc, char **argv)
{
	if (argc != 2) {
		fprintf(stderr, "usage: lock_node <file>\n");
		return 1;
	}

	BNode node;
	status_t status = node.SetTo(argv[1]);
	if (status != B_OK) {
		fprintf(stderr, "lock_node: could not open \"%s\": %s\n", argv[1], strerror(status));
		return 1;
	}

	status = node.Lock();
	if (status != B_OK) {
		fprintf(stderr, "lock_node: could not lock \"%s\": %s\n", argv[1], strerror(status));
		return 1;
	}

	puts("press <enter> to continue...");
	char a[5];
	fgets(a, 5, stdin);

	node.Unlock();
	node.Unset();
	return 0;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:29,代码来源:lock_node_test.cpp

示例6: SetMimeType

void CDoc::SetMimeType(const char *type, bool updateOnDisk)
{
	fMimeType = type;

	if (updateOnDisk && EntryRef())
	{
		BNode node;
		FailOSErr(node.SetTo(EntryRef()));
		FailOSErr(BNodeInfo(&node).SetType(type));
	}
}
开发者ID:diversys,项目名称:pe,代码行数:11,代码来源:CDoc.cpp

示例7:

void
THeaderView::InitEmailCompletion()
{
	// get boot volume
	BVolume volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.SetPredicate("META:email=**");
		// Due to R5 BFS bugs, you need two stars, META:email=** for the query.
		// META:email="*" will just return one entry and stop, same with
		// META:email=* and a few other variations.  Grumble.
	query.Fetch();
	entry_ref ref;

	while (query.GetNextRef (&ref) == B_OK) {
		BNode file;
		if (file.SetTo(&ref) == B_OK) {
			// Add the e-mail address as an auto-complete string.
			BString email;
			if (file.ReadAttrString("META:email", &email) >= B_OK)
				fEmailList.AddChoice(email.String());

			// Also add the quoted full name as an auto-complete string.  Can't
			// do unquoted since auto-complete isn't that smart, so the user
			// will have to type a quote mark if he wants to select someone by
			// name.
			BString fullName;
			if (file.ReadAttrString("META:name", &fullName) >= B_OK) {
				if (email.FindFirst('<') < 0) {
					email.ReplaceAll('>', '_');
					email.Prepend("<");
					email.Append(">");
				}
				fullName.ReplaceAll('\"', '_');
				fullName.Prepend("\"");
				fullName << "\" " << email;
				fEmailList.AddChoice(fullName.String());
			}

			// support for 3rd-party People apps.  Looks like a job for
			// multiple keyword (so you can have several e-mail addresses in
			// one attribute, perhaps comma separated) indices!  Which aren't
			// yet in BFS.
			for (int16 i = 2; i < 6; i++) {
				char attr[16];
				sprintf(attr, "META:email%d", i);
				if (file.ReadAttrString(attr, &email) >= B_OK)
					fEmailList.AddChoice(email.String());
			}
		}
	}
}
开发者ID:sahil9912,项目名称:haiku,代码行数:54,代码来源:Header.cpp

示例8: WriteSetting

/*	WriteSetting
*	this method writes a setting to the settings file (boolean)
*/
void IOSettings::WriteSetting(const char* Setting, bool SettCont)
{
	if(!SettingsFileExists())
		CreateSettingsFile();

	BNode objNode;
	objNode.SetTo(fSettingsFile.String());
	
	if(objNode.WriteAttr(Setting, B_BOOL_TYPE, 0, (void*)&SettCont, sizeof(SettCont)) == B_FILE_ERROR)
		throw new IOSettingsException(new BString("can't write attr. to settings file (IOSettings::WriteSetting(const char* Setting, bool SettCont))"));

}
开发者ID:HaikuArchives,项目名称:Lava,代码行数:15,代码来源:iosettings.cpp

示例9: directory

void
IMAPFolder::_ReadFolderState()
{
	BDirectory directory(&fRef);
	BEntry entry;
	while (directory.GetNextEntry(&entry) == B_OK) {
		entry_ref ref;
		BNode node;
		if (!entry.IsFile() || entry.GetRef(&ref) != B_OK
			|| node.SetTo(&entry) != B_OK)
			continue;

		uint32 uidValidity = _ReadUniqueIDValidity(node);
		if (uidValidity != fUIDValidity) {
			// TODO: add file to mailbox
			continue;
		}
		uint32 uid = _ReadUniqueID(node);
		uint32 flags = _ReadFlags(node);

		MutexLocker locker(fLock);
		if (fQuitFolderState)
			return;

		fRefMap.insert(std::make_pair(uid, ref));
		fFlagsMap.insert(std::make_pair(uid, flags));

//		// TODO: make sure a listener exists at this point!
//		std::set<uint32>::iterator found = lastUIDs.find(uid);
//		if (found != lastUIDs.end()) {
//			// The message is still around
//			lastUIDs.erase(found);
//
//			uint32 flagsFound = MessageFlags(uid);
//			if (flagsFound != flags) {
//				// Its flags have changed locally, and need to be updated
//				fListener->MessageFlagsChanged(_Token(uid), ref,
//					flagsFound, flags);
//			}
//		} else {
//			// This is a new message
//			// TODO: the token must be the originating token!
//			uid = fListener->MessageAdded(_Token(uid), ref);
//			_WriteUniqueID(node, uid);
//		}
//
	}

	fFolderStateInitialized = true;
	mutex_unlock(&fFolderStateLock);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:51,代码来源:IMAPFolder.cpp

示例10: FileForId

entry_ref* TaskFS::FileForId(Task *theTask)
{
	//**scan through all files for the ID or shell we do a querry??
	BString		fileID;
	entry_ref	*ref;
	BNode		theNode;
	
	while (tasksDir.GetNextRef(ref) == B_OK){
		theNode.SetTo(ref);
		if (theNode.ReadAttrString("META:task_id", &fileID) == B_OK)
			if (fileID==theTask->ID() && fileID.Length() != 0)
				return ref;
	}
	return NULL;
}
开发者ID:Paradoxianer,项目名称:Tasks,代码行数:15,代码来源:TaskFS.cpp

示例11: instance

char *add_printer(char *printerName)
{
	BPath path;
	BNode folder;
	BNode* spoolFolder = NULL;
	// get spool folder
	if (find_directory(B_USER_PRINTERS_DIRECTORY, &path) == B_OK &&
		path.Append(printerName) == B_OK &&
		folder.SetTo(path.Path()) == B_OK) {
		spoolFolder = &folder;
	}

	PrinterDriverInstance instance(spoolFolder);
	return instance.GetPrinterDriver()->AddPrinter(printerName);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:15,代码来源:PrinterDriver.cpp

示例12: memIO

/*
 * this method is not currently being used, but it may be useful in the future...
 */
status_t
DefaultCatalog::ReadFromAttribute(entry_ref *appOrAddOnRef)
{
	BNode node;
	status_t res = node.SetTo(appOrAddOnRef);
	if (res != B_OK) {
		log_team(LOG_ERR,
			"couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
			appOrAddOnRef->device, appOrAddOnRef->directory,
			appOrAddOnRef->name);
		return B_ENTRY_NOT_FOUND;
	}

	log_team(LOG_DEBUG,
		"looking for embedded catalog-attribute in app/add-on"
		"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
		appOrAddOnRef->directory, appOrAddOnRef->name);

	attr_info attrInfo;
	res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
	if (res != B_OK) {
		log_team(LOG_DEBUG, "no embedded catalog found");
		return B_NAME_NOT_FOUND;
	}
	if (attrInfo.type != B_MESSAGE_TYPE) {
		log_team(LOG_ERR, "attribute %s has incorrect type and is ignored!",
			BLocaleRoster::kEmbeddedCatAttr);
		return B_BAD_TYPE;
	}

	size_t size = attrInfo.size;
	auto_ptr<char> buf(new(std::nothrow) char [size]);
	if (buf.get() == NULL) {
		log_team(LOG_ERR, "couldn't allocate array of %d chars", size);
		return B_NO_MEMORY;
	}
	res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
		buf.get(), size);
	if (res < (ssize_t)size) {
		log_team(LOG_ERR, "unable to read embedded catalog from attribute");
		return res < B_OK ? res : B_BAD_DATA;
	}

	BMemoryIO memIO(buf.get(), size);
	res = Unflatten(&memIO);

	return res;
}
开发者ID:,项目名称:,代码行数:51,代码来源:

示例13: sizeof

/*	isProject
* checks if an selected folder is a lava project folder.
*/
bool
ProjectTypeSelector::isProject()
{
	BNode objNode;
	BString *Project = (BString*)FileList->FirstItem();
	objNode.SetTo(Project->String());
	
	char buffer[500];
	memset(buffer, 0, sizeof(buffer));

	if(objNode.ReadAttr("LAVA:Type", B_STRING_TYPE, 0, buffer, sizeof(buffer)) == B_ENTRY_NOT_FOUND)
		return false;
	else {
		BDirectory objDir;
		objDir.SetTo(Project->String());
		if(objDir.InitCheck() != B_OK)
			return false;
		else
			return true;
	}
}
开发者ID:HaikuArchives,项目名称:Lava,代码行数:24,代码来源:ProjectTypeSelector.cpp

示例14: file

void
ResView::OpenFile(const entry_ref &ref)
{
	// Add all the 133t resources and attributes of the file
	BFile file(&ref, B_READ_ONLY);
	BResources resources;
	if (resources.SetTo(&file) != B_OK)
		return;
	file.Unset();
	
	resources.PreloadResourceType();
	
	int32 index = 0;
	ResDataRow *row;
	ResourceData *resData = new ResourceData();
	while (resData->SetFromResource(index, resources)) {
		row = new ResDataRow(resData);
		fListView->AddRow(row);
		fDataList.AddItem(resData);
		resData = new ResourceData();
		index++;
	}
	delete resData;

	BNode node;
	if (node.SetTo(&ref) == B_OK) {
		char attrName[B_ATTR_NAME_LENGTH];
		node.RewindAttrs();
		resData = new ResourceData();
		while (node.GetNextAttrName(attrName) == B_OK) {
			if (resData->SetFromAttribute(attrName, node)) {
				row = new ResDataRow(resData);
				fListView->AddRow(row);
				fDataList.AddItem(resData);
				resData = new ResourceData();
			}
		}
		delete resData;
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:40,代码来源:ResView.cpp

示例15: OpenItem

void PProjectWindow::OpenItem()
{
	PEntryItem *gi;
	gi = dynamic_cast<PEntryItem*>(fList->ItemAt(fList->CurrentSelection()));
	if (gi)
	{
		try
		{
			BNode node;
			FailOSErr(node.SetTo(&gi->Ref()));
			BNodeInfo info;
			FailOSErr(info.SetTo(&node));

			char mime[B_MIME_TYPE_LENGTH];

			CProjectFile* subProject
				= dynamic_cast<CProjectFile*>(gi->ModelItem());
			if (subProject) {
				if (!subProject->HasBeenParsed()) {
					subProject->Read();
					if (subProject->HasBeenParsed()) {
						list<CProjectItem*>::const_iterator iter;
						for( iter = subProject->begin();
							  iter != subProject->end(); ++iter) {
							AddItemsToList( *iter, gi);
						}
					}
				}
			} else if (info.GetType(mime) || strncmp(mime, "text/", 5))
				OpenInTracker(gi->Ref());
			else
				gApp->OpenWindow(gi->Ref());
		}
		catch (HErr& e)
		{
			e.DoError();
			gApp->OpenWindow(gi->Ref());
		}
	}
} /* PProjectWindow::OpenItem */
开发者ID:HaikuArchives,项目名称:Pe,代码行数:40,代码来源:PProjectWindow.cpp


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