Шаблон:CreateFileAsBinaryDataStorage example
Версия от 16:22, 16 марта 2017; Андрей Чусов (обсуждение | вклад) (Новая страница: «<source lang='cpp'> char l_filename[] = "./somefile"; std::size_t cb_filename = sizeof(l_filename) - 1 →term. 0: ; IIOBinaryData* pIO; //uninitialized pointer {…»)
char l_filename[] = "./somefile";
std::size_t cb_filename = sizeof(l_filename) - 1 /*term. 0*/;
IIOBinaryData* pIO; //uninitialized pointer
{
IBinaryDataBase* pStorage; //uninitialized pointer
int32_t err = CreateFileAsBinaryDataStorage(l_filename, cb_filename, FileRead | FileWrite, FileCreateAlways, std::addressof(pStorage));
if (err < 0)
return -1; //failure
err = pStorage->IsInterfaceAvailable(IOBinaryDataType);
if (err < 0)
return -1; //failure of IsInterfaceAvailable
if (err == 1)
return 0; //Interface is not available
err = pStorage->RepresentAs(IOBinaryDataType, (void**) std::addressof(pIO));
if (err < 0)
return -1; //failure of RepresentAs
}
//access file via pIO...