Clear error_code on entry in win32_unicode_path constructor
Fixes #3035
Issue
The win32_unicode_path constructor accepts an error_code& parameter but wasn't clearing it on successful path conversion. This led to callers retaining stale error values even when operations succeeded.
Problem
As reported in #3035, when using file.open() with a pre-set error code (e.g., initialized to error::not_found as a default), the error would persist even after successful file operations. This is inconsistent with std::filesystem conventions where error_code parameters are cleared on success.
Solution
Added ec = {}; at the beginning of the constructor to ensure the error_code is always in a known state - either cleared for success or properly set for failure.
This aligns with:
- The std::filesystem API convention (e.g.,
std::filesystem::create_directory) - The recommendation from @vinniefalco to clear
ecimmediately upon entry to avoid these kinds of issues - Beast's own
file_win32::openwhich already clears ec on line 222
Testing
Windows-specific change. The fix is minimal and follows established error handling patterns in the codebase.
@vinniefalco - Can you please get a chance to review this PR?
Please review all file-related operations to ensure they clear ec on success, and also determine how we can add appropriate tests to confirm this.