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


C++ UserStringParameter::Init方法代码示例

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


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

示例1: _

partition_id
_user_find_partition(const char *_filename, size_t *neededSize)
{
	UserStringParameter<false> filename;
	status_t error = filename.Init(_filename, B_PATH_NAME_LENGTH);
	if (error != B_OK)
		return error;

	KDiskDeviceManager *manager = KDiskDeviceManager::Default();
	// find the partition
	KPartition *partition = manager->RegisterPartition(filename);
	if (partition == NULL)
		return B_ENTRY_NOT_FOUND;
	PartitionRegistrar _(partition, true);
	partition_id id = partition->ID();
	if (neededSize != NULL) {
		// get and lock the partition's device
		KDiskDevice *device = manager->RegisterDevice(partition->ID(), false);
		if (device == NULL)
			return B_ENTRY_NOT_FOUND;
		PartitionRegistrar _2(device, true);
		if (DeviceReadLocker locker = device) {
			// get the needed size
			UserDataWriter writer;
			device->WriteUserData(writer);
			error = copy_to_user_value(neededSize, writer.AllocatedSize());
			if (error != B_OK)
				return error;
		} else
			return B_ERROR;
	}
	return id;
}
开发者ID:looncraz,项目名称:haiku,代码行数:33,代码来源:ddm_userland_interface.cpp

示例2: path

partition_id
_user_find_file_disk_device(const char *_filename, size_t *neededSize)
{
	UserStringParameter<false> filename;
	status_t error = filename.Init(_filename, B_PATH_NAME_LENGTH);
	if (error != B_OK)
		return error;

	KPath path(filename, KPath::NORMALIZE);

	KDiskDeviceManager *manager = KDiskDeviceManager::Default();
	// find the device
	KFileDiskDevice* device = manager->RegisterFileDevice(path.Path());
	if (device == NULL)
		return B_ENTRY_NOT_FOUND;
	PartitionRegistrar _(device, true);
	partition_id id = device->ID();
	if (neededSize != NULL) {
		if (DeviceReadLocker locker = device) {
			// get the needed size
			UserDataWriter writer;
			device->WriteUserData(writer);
			error = copy_to_user_value(neededSize, writer.AllocatedSize());
			if (error != B_OK)
				return error;
		} else
			return B_ERROR;
	}
	return id;
}
开发者ID:looncraz,项目名称:haiku,代码行数:30,代码来源:ddm_userland_interface.cpp

示例3: locker

status_t
_user_set_partition_content_name(partition_id partitionID,
	int32* _changeCounter, const char* _name)
{
	// copy parameters in
	UserStringParameter<true> name;
	int32 changeCounter;

	status_t error = name.Init(_name, B_DISK_DEVICE_NAME_LENGTH);
	if (error == B_OK)
		error = copy_from_user_value(changeCounter, _changeCounter);
	if (error != B_OK)
		return error;

	// get the partition
	KDiskDeviceManager* manager = KDiskDeviceManager::Default();
	KPartition* partition = manager->WriteLockPartition(partitionID);
	if (partition == NULL)
		return B_ENTRY_NOT_FOUND;

	PartitionRegistrar registrar1(partition, true);
	PartitionRegistrar registrar2(partition->Device(), true);
	DeviceWriteLocker locker(partition->Device(), true);

	// check change counter
	if (changeCounter != partition->ChangeCounter())
		return B_BAD_VALUE;

	// the partition must be initialized
	KDiskSystem* diskSystem = partition->DiskSystem();
	if (diskSystem == NULL)
		return B_BAD_VALUE;

	// mark the partition busy and unlock
	if (!partition->CheckAndMarkBusy(false))
		return B_BUSY;
	locker.Unlock();

	// set content parameters
	error = diskSystem->SetContentName(partition, name.value, DUMMY_JOB_ID);

	// re-lock and unmark busy
	locker.Lock();
	partition->UnmarkBusy(false);

	if (error != B_OK)
		return error;

	// return change counter
	return copy_to_user_value(_changeCounter, partition->ChangeCounter());
}
开发者ID:looncraz,项目名称:haiku,代码行数:51,代码来源:ddm_userland_interface.cpp

示例4:

status_t
_user_unregister_file_device(partition_id deviceID, const char *_filename)
{
	if (deviceID < 0 && _filename == NULL)
		return B_BAD_VALUE;
	KDiskDeviceManager *manager = KDiskDeviceManager::Default();
	if (deviceID >= 0)
		return manager->DeleteFileDevice(deviceID);

	UserStringParameter<false> filename;
	status_t error = filename.Init(_filename, B_PATH_NAME_LENGTH);
	if (error != B_OK)
		return error;

	return manager->DeleteFileDevice(filename);
}
开发者ID:looncraz,项目名称:haiku,代码行数:16,代码来源:ddm_userland_interface.cpp


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