Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to set ReadWrite access to file descriptor in FileStream #119

Closed
OptionalAssistant opened this issue Mar 29, 2024 · 4 comments · Fixed by #120
Closed

Impossible to set ReadWrite access to file descriptor in FileStream #119

OptionalAssistant opened this issue Mar 29, 2024 · 4 comments · Fixed by #120
Labels
improvement Improvement of existing code

Comments

@OptionalAssistant
Copy link
Contributor

OptionalAssistant commented Mar 29, 2024

Hello,it seems there is a bug that does not allow to open file descriptor in read&write mode despite we have StreamMode::ReadWrite enum value.The problem in the following line of FileStream::open function _wfopen_s(&fp, path.wstring().c_str(), mode == StreamMode::Read ? L"rb" : L"wb");.The problem if we pass ReadWrite enum value to FileStream::open method or to constructor it open the file in wb mode and overwrites the content.It is not the problem for load and store func cause as I understood there is no sence to pass FileStream in ReadWrite value to save func cause it has to clear the content before writing bytes using his own patterns.But it is problem for user who wants to use FileStream as a wrapper to work with files cause he is not able to open file in rw mode using FileStream.I could create pull request but I can not firgure out how to fix it to not break load and store func.

P.S.As an option we can write something like this _ _wfopen_s(&fp, path.wstring().c_str(), mode == StreamMode::Read ? L"rb" : mode == StreamMode::Write ? L"wb" : L"r+b");
but it will break save func cause file will not be cleared before writing our Program;

@ZehMatt
Copy link
Collaborator

ZehMatt commented Mar 29, 2024

I don't think adding support for this would break the save/restore functionality, its up to the user to use the correct mode, I'm not against it.

@ZehMatt ZehMatt added the improvement Improvement of existing code label Mar 29, 2024
@OptionalAssistant
Copy link
Contributor Author

OptionalAssistant commented Mar 29, 2024

I don't think adding support for this would break the save/restore functionality, its up to the user to use the correct mode, I'm not against it.

So may I pull request it?

@ZehMatt
Copy link
Collaborator

ZehMatt commented Mar 29, 2024

I don't think adding support for this would break the save/restore functionality, its up to the user to use the correct mode, I'm not against it.

So may I pull request it?

All yours.

@ZehMatt
Copy link
Collaborator

ZehMatt commented Mar 29, 2024

Don't close issues until the PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement of existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants