FNA-XNA/FNA

Add support for ContentManager's ReadAsset function to read from custom streams instead of only on the disk

Closed this issue · 3 comments

This just an issue page that is based off the comment found in ContentManager.cs which is shown as

// Okay, so we couldn't open it. Maybe it needs a different extension?
// FIXME: This only works for files on the disk, what about custom streams? -flibit
modifiedAssetName = MonoGame.Utilities.FileHelpers.NormalizeFilePathSeparators(
	Path.Combine(RootDirectoryFullPath, assetName)

I don't see an issue already listing it, so I am creating this so it doesn't get forgotten.

I think the fix is to do the same process but instead of querying the filesystem we have to take the Stream's "path" (or check the type maybe...?) and try to normalize that, or if the Stream is already valid, peek a few bytes to determine the type (which I think we do, but in a different part of the reading process).

Took another look, we'll need to expand this functionality...

https://github.com/FNA-XNA/FNA/blob/master/src/Content/ContentTypeReader.cs#L69

... to check with the ContentManager's OpenStream function, probably by passing the function pointer.

Does this commit resolve the issue?

fb3f62e

EDIT: One more because Song/Video are weird:

9863f72