<div dir="ltr">Hi,<div><br></div><div>I'm integrating GDAL in C++ with a system that defines its own asset types stored on disk, and am writing a wrapper for datasets using this asset system. To 'import' a dataset I call GDALOpenEx on it, CreateCopy() it to some "/vsimem/foo.shp" path, GDALClose() the datasets to flush it, and call VSIGetMemFileBuffer with bUnlinkAndSeize=true to take ownership of the underlying memory buffer. </div><div><br></div><div>GDALDataset* Dataset = GDALOpenEx("foo.shp", GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR, nullptr, nullptr, nullptr);</div><div>GDALDataset* Copy = Dataset->GetDriver()->CreateCopy("/vsimem/foo.shp", Dataset, false, nullptr, nullptr, nullptr); //appears to produce a valid Dataset containing the same layers & features as its source.</div><div>GDALClose(Dataset);</div><div>GDALClose(Copy);</div><div>size_t DataLength;</div><div>GByte* Buffer = VSIGetMemFileBuffer("/vsimem/foo.shp", &DataLength, true); //<-- returns NULL</div><div><br></div><div>For some reason VSIGetMemFileBuffer always fails, returning a nullptr. This is basically identical to a similar problem I had, described here:<a href="https://stackoverflow.com/questions/73644157/get-raw-buffer-for-in-memory-dataset-in-gdal-c-api" target="_blank"> https://stackoverflow.com/questions/73644157/get-raw-buffer-for-in-memory-dataset-in-gdal-c-api </a> which I never really found a solution to. I have similar issues with other VSI functions, e.g. calling GDALOpenEx on a path created by VSIFileFromMemBuffer also fails.</div><div><br></div><div>Any idea as to what the problem is here?</div><div><br></div><div>Alternatively, maybe there's a better way to 'emplace' datasets inside some other file?</div><div><br></div><div>Thanks,</div><div>Soren Saville Scott</div></div>