本文整理汇总了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;
}
示例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;
}