Jump to content

FileType plugin Stream question


Hannawell

Recommended Posts

Is it possible to obtain the FileStream handle or the file's name from the input stream passed to the FileType plugin?

My plugin handles multiple extension types, & I need a quick way to determine the file extension type prior to processing the stream data.

I know the input stream is a 'PaintDotNet.SiphonStream'. I believe it contains another Stream which is 'the' FileStream (I can see it in the

debugger), however that member is private.

Is there a way to get to that data? If not, could an interface be added to the SiphonStream class?

(based on some source I'd seen for SiphonStream.cs)

thanks, Hannawell

Link to comment
Share on other sites

Your code is not allowed to know what underlying Stream is being used.

Imagine your code expects a FileStream and casts to that, and accesses those properties. Then imagine I change my implementation to send you a MemoryStream or some other type of serialization stream because I'm embedding your data into something else. Your plugin would crash. Not a smart thing to do. The reason you're given a Stream is because you're supposed to write data to it, nothing else.

Like Simon said, just register different extensions instead of using 1 uber FileType implementation.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Thanks! That helps a great deal.

I am also using the plugin to choose one of many images from pack/zip/wad type image collections.

To do so, the plugin pops up a dialog box. It would be nice (not critical) if the dialog could display the wad's filename.

I understand its not available now, possibly consider a static PaintDotNet.GetActiveFilename()?

H

Link to comment
Share on other sites

I understand its not available now, possibly consider a static PaintDotNet.GetActiveFilename()?

What? I just told you that information is, by design, not available to the plugin. Asking for a static method instead of an abusable type cast is completely isomorphic.

You're going about things the wrong way. FileTypes are supposed to open whole files, not import slices of them. They are not supposed to show UI, except via the Save Configuration dialog. You should write a tool to dump the contents of a WAD, and then have the user just edit the individual images via normal means, then have a tool to recompile everything into a new WAD. What you're trying to do is effectively treat a file as a directory, and then you're popping up a second "pick a file" dialog. That is absolutely the wrong approach.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...