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


C++ Directory::ParentDirectory方法代码示例

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


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

示例1: if

static status_t
checksumfs_lookup(fs_volume* fsVolume, fs_vnode* fsDir, const char* name,
	ino_t* _id)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	Node* node = (Node*)fsDir->private_node;

	Directory* directory = dynamic_cast<Directory*>(node);
	if (directory == NULL)
		return B_NOT_A_DIRECTORY;

	uint64 blockIndex;

	if (strcmp(name, ".") == 0) {
		blockIndex = directory->BlockIndex();
	} else if (strcmp(name, "..") == 0) {
		blockIndex = directory->ParentDirectory();
	} else {
		// TODO: Implement!
		return B_ENTRY_NOT_FOUND;
	}

	// get the node
	Node* childNode;
	status_t error = volume->GetNode(blockIndex, childNode);
	if (error != B_OK)
		return error;

	*_id = blockIndex;
	return B_OK;
}
开发者ID:mariuz,项目名称:haiku,代码行数:31,代码来源:checksumfs.cpp

示例2: ReadNextEntry

	status_t ReadNextEntry(struct dirent* buffer, size_t size,
		uint32& _countRead)
	{
		const char* name;
		uint64 blockIndex;

		int nextIterationState = OTHERS;
		switch (iterationState) {
			case DOT:
				name = ".";
				blockIndex = directory->BlockIndex();
				nextIterationState = DOT_DOT;
				break;
			case DOT_DOT:
				name = "..";
				blockIndex = directory->ParentDirectory();
				break;
			default:
				// TODO: Implement!
				_countRead = 0;
				return B_OK;
		}

		size_t entrySize = sizeof(dirent) + strlen(name);
		if (entrySize > size)
			return B_BUFFER_OVERFLOW;

		buffer->d_dev = directory->GetVolume()->ID();
		buffer->d_ino = blockIndex;
		buffer->d_reclen = entrySize;
		strcpy(buffer->d_name, name);

		iterationState = nextIterationState;

		_countRead = 1;
		return B_OK;
	}
开发者ID:mariuz,项目名称:haiku,代码行数:37,代码来源:checksumfs.cpp


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