How to deconstruct an OpenOption?

For my project I need to deconstruct an OpenOption, but the methods on it just allow to set the flags, not to read them and the implementation details are all private. My only idea now is to create the Debug representation and parse it out of that, but that's obviously not an ideal solution.

Hmm, this is definitely not something it has been intended for. That being said, after thinking about it, I could imagine your having your own file-opening logic, and wanting to use the already existing OpenOptions as a general approach to handle the file opening :thinking:

One option would be to keep the given OpenOptions around, and use it to open each individual file.

Otherwise you'd have to make a feature request (e.g., over, and in the interim, use your own builder pattern which you can inspect.

Debug representation and parse it

Yeah, that's really not a long-term solution, since the contents of a debug representation have no guarantees attached to it whatsoever, thence leading to unstability and potential breakage as new versions of the standard library are released :grimacing:

Sadly I cannot keep the OpenOption around, because I'm implementing a virtual filesystem, so there is no one to hand it to.

I know, but for now this has to suffice.

Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.