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


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

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


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

示例1: TRACE

status_t
IMAPStorage::AddNewMessage(int32 uid, int32 flags, BPositionIO** file)
{
    if (file != NULL)
        *file = NULL;
    // TODO: make sure there is not a valid mail with this name
    BString fileName = "Downloading file... uid: ";
    fileName << uid;

    BPath filePath = fMailboxPath;
    filePath.Append(fileName);
    TRACE("AddNewMessage %s\n", filePath.Path());
    BFile* newFile = new BFile(filePath.Path(), B_READ_WRITE | B_CREATE_FILE
                               | B_ERASE_FILE);
    if (newFile == NULL)
        return B_NO_MEMORY;

    StorageMailEntry storageEntry;
    storageEntry.uid = uid;
    storageEntry.flags = flags;
    storageEntry.fileName = fileName;
    newFile->GetNodeRef(&storageEntry.nodeRef);

    if (_WriteUniqueID(*newFile, uid) != B_OK) {
        delete newFile;
        return B_ERROR;
    }

    status_t status = _WriteFlags(flags, *newFile);
    if (status != B_OK) {
        delete newFile;
        return status;
    }

    if (file)
        *file = newFile;
    else
        delete newFile;
    fMailEntryMap[uid] = storageEntry;
    return B_OK;
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:41,代码来源:IMAPStorage.cpp

示例2: entry

/*! Message must contain an archivable view for later rehydration.
	This function takes over ownership of the provided message on success
	only.
	Returns the current replicant ID.
*/
status_t
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
{
	if (archive == NULL || id == NULL)
		return B_ERROR;

	// find entry_ref

	entry_ref ref;
	if (addOn) {
		// Use it if we got it
		ref = *addOn;
	} else {
		const char* signature;

		status_t status = archive->FindString("add_on", &signature);
		if (status == B_OK) {
			BRoster roster;
			status = roster.FindApp(signature, &ref);
		}
		if (status < B_OK)
			return status;
	}

	BFile file;
	status_t status = file.SetTo(&ref, B_READ_ONLY);
	if (status < B_OK)
		return status;

	node_ref nodeRef;
	status = file.GetNodeRef(&nodeRef);
	if (status < B_OK)
		return status;

	BEntry entry(&ref, true);
		// TODO: this resolves an eventual link for the item being added - this
		// is okay for now, but in multi-user environments, one might want to
		// have links that carry the be:deskbar_item_status attribute
	status = entry.InitCheck();
	if (status != B_OK)
		return status;

	*id = 999;
	if (archive->what == B_ARCHIVED_OBJECT)
		archive->what = 0;

	BRect originalBounds = archive->FindRect("_frame");
		// this is a work-around for buggy replicants that change their size in
		// AttachedToWindow() (such as "SVM")

	// TODO: check for name collisions?
	status = fShelf->AddReplicant(archive, BPoint(1, 1));
	if (status != B_OK)
		return status;

	int32 count = fShelf->CountReplicants();
	BView* view;
	fShelf->ReplicantAt(count - 1, &view, (uint32*)id, NULL);

	if (originalBounds != view->Bounds()) {
		// The replicant changed its size when added to the window, so we need
		// to recompute all over again (it's already done once via
		// BShelf::AddReplicant() and TReplicantShelf::CanAcceptReplicantView())
		RealignReplicants();
	}

	float oldWidth = Bounds().Width();
	float oldHeight = Bounds().Height();
	float width, height;
	GetPreferredSize(&width, &height);
	if (oldWidth != width || oldHeight != height)
		AdjustPlacement();

	// add the item to the add-on list

	AddItem(*id, nodeRef, entry, addOn != NULL);
	return B_OK;
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:83,代码来源:StatusView.cpp


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