libstdc++: Adjust filesystem::read_symlink error handling on Windows.
Corrected error handling for `std::filesystem::read_symlink` on Windows.
Error handling for std::filesystem::read_symlink on Windows has been adjusted to use std::error_code instead of errno. Helper functions like __open_for_stat and __check_handle_type now accept a std::error_code parameter, and errno is set only within the Windows-specific __stat_windows function. This change ensures consistent error reporting across different platforms and C++ APIs.
In Details
The Windows implementation of std::filesystem::read_symlink incorrectly modified errno in helper functions that are also used by other std::filesystem operations which rely on std::error_code. This commit rectifies this by making the helpers accept std::error_code and moving errno setting to the __stat_windows function, aligning with the expected error reporting mechanism for std::filesystem.
- std::filesystem
- A C++ standard library component that provides facilities for manipulating files and directories, including path operations, file status queries, and I/O.
- errno
- A global integer variable in C and C++ that holds the error code from the last library or system call that failed.
- std::error_code
- A C++ class used to represent platform-specific error codes, often used by libraries like
std::filesystemas an alternative toerrnofor more localized and type-safe error reporting. - read_symlink
- A function within
std::filesystemthat reads the target of a symbolic link.