Шаблон:CreateFileAsBinaryDataStorage example

Материал из CAMaaS preliminary wiki
Версия от 12:32, 14 августа 2019; Андрей Чусов (обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к навигации Перейти к поиску
	char l_filename[] = "./somefile";
	std::size_t cb_filename = sizeof(l_filename) - 1 /*term. 0*/;

	IContiguousDataStorage* pIO = nullptr;
	IDataStorage* pStorage = nullptr;
	return_code_t err = CreateFileAsBinaryDataStorage(l_filename, cb_filename, FileRead | FileWrite, FileCreateAlways, &pStorage);
	if (err < 0)
		goto cleanup; //failure of CreateFileAsBinaryDataStorage
	err = pStorage->IsInterfaceAvailable(ContiguousDataStorageType);
	if (err < 0)
		goto cleanup; //failure of IsInterfaceAvailable
	err = pStorage->RepresentAs(ContiguousDataStorageType, (void**) &pIO);
	if (err < 0)
		goto cleanup; //failure of RepresentAs
	
	//access the file via pIO...
	
cleanup:
	if (pStorage)
		pStrorage->Release();
	if (pIO)
		pIO->Release();