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


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

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


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

示例1: sizeof

static status_t
load_modules_from(Directory *volume, const char *path)
{
	// we don't have readdir() & co. (yet?)...

	int fd = open_from(volume, path, O_RDONLY);
	if (fd < B_OK)
		return fd;

	Directory *modules = (Directory *)get_node_from(fd);
	if (modules == NULL)
		return B_ENTRY_NOT_FOUND;

	void *cookie;
	if (modules->Open(&cookie, O_RDONLY) == B_OK) {
		char name[B_FILE_NAME_LENGTH];
		while (modules->GetNextEntry(cookie, name, sizeof(name)) == B_OK) {
			if (!strcmp(name, ".") || !strcmp(name, ".."))
				continue;

			status_t status = elf_load_image(modules, name);
			if (status != B_OK)
				dprintf("Could not load \"%s\" error %ld\n", name, status);
		}

		modules->Close(cookie);
	}

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

示例2: packagesNodeReleaser

int
BootVolume::_OpenSystemPackage()
{
	// open the packages directory
	Node* packagesNode = fSystemDirectory->Lookup("packages", false);
	if (packagesNode == NULL)
		return -1;
	MethodDeleter<Node, status_t> packagesNodeReleaser(packagesNode,
		&Node::Release);

	if (!S_ISDIR(packagesNode->Type()))
		return -1;
	Directory* packageDirectory = (Directory*)packagesNode;

	// search for the system package
	int fd = -1;
	void* cookie;
	if (packageDirectory->Open(&cookie, O_RDONLY) == B_OK) {
		char name[B_FILE_NAME_LENGTH];
		while (packageDirectory->GetNextEntry(cookie, name, sizeof(name))
				== B_OK) {
			// The name must end with ".hpkg".
			size_t nameLength = strlen(name);
			if (nameLength < 6 || strcmp(name + nameLength - 5, ".hpkg") != 0)
				continue;

			// The name must either be "haiku.hpkg" or start with "haiku-".
			if (strcmp(name, "haiku.hpkg") == 0
				|| strncmp(name, "haiku-", 6) == 0) {
				fd = open_from(packageDirectory, name, O_RDONLY);
				break;
			}
		}
		packageDirectory->Close(cookie);
	}

	return fd;
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:38,代码来源:vfs.cpp

示例3: sizeof

status_t
mount_file_systems(stage2_args *args)
{
	// mount other partitions on boot device (if any)
	NodeIterator iterator = gPartitions.GetIterator();

	Partition *partition = NULL;
	while ((partition = (Partition *)iterator.Next()) != NULL) {
		// don't scan known partitions again
		if (partition->IsFileSystem())
			continue;

		// remove the partition if it doesn't contain a (known) file system
		if (partition->Scan(true) != B_OK && !partition->IsFileSystem()) {
			gPartitions.Remove(partition);
			delete partition;
		}
	}

	// add all block devices the platform has for us

	status_t status = platform_add_block_devices(args, &gBootDevices);
	if (status < B_OK)
		return status;

	iterator = gBootDevices.GetIterator();
	Node *device = NULL, *last = NULL;
	while ((device = iterator.Next()) != NULL) {
		// don't scan former boot device again
		if (device == sBootDevice)
			continue;

		if (add_partitions_for(device, true) == B_OK) {
			// ToDo: we can't delete the object here, because it must
			//	be removed from the list before we know that it was
			//	deleted.

/*			// if the Release() deletes the object, we need to skip it
			if (device->Release() > 0) {
				list_remove_item(&gBootDevices, device);
				device = last;
			}
*/
(void)last;
		}
		last = device;
	}

	if (gPartitions.IsEmpty())
		return B_ENTRY_NOT_FOUND;

#if 0
	void *cookie;
	if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
		Directory *directory;
		while (gRoot->GetNextNode(cookie, (Node **)&directory) == B_OK) {
			char name[256];
			if (directory->GetName(name, sizeof(name)) == B_OK)
				printf(":: %s (%p)\n", name, directory);

			void *subCookie;
			if (directory->Open(&subCookie, O_RDONLY) == B_OK) {
				while (directory->GetNextEntry(subCookie, name, sizeof(name)) == B_OK) {
					printf("\t%s\n", name);
				}
				directory->Close(subCookie);
			}
		}
		gRoot->Close(cookie);
	}
#endif

	return B_OK;
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:74,代码来源:vfs.cpp


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