I'm trying to use an archive that can work with multiple file types in an SDL-based program. I've got a routine to open the archive and retrieve individual files from it as PSDL_RWops pointers. Problem is, only certain file types are able to be read from a SDL_RWops. I'd like to be able to define custom loaders for other file types.

But the preferred method of working with files in Delphi isn't an SDL_RWops, it's a TStream. For compatibility purposes, I need a way to convert the one buffer to the other. Can anyone help me fill in the following function?

[pascal]function rwToStream(rw: PSdl_RWops): TMemoryStream
begin
result := TMemoryStream.Create;
{insert functional code here}
end;[/pascal]