fix(fs): correct ReadLink error message and add missing read_link wra… (#19287)

This commit is contained in:
Maximilian Hubert
2025-10-27 11:17:29 +01:00
committed by GitHub
parent 74cc561917
commit 4f660dac85

View File

@@ -39,7 +39,7 @@ pub enum FsPathError {
},
/// Error variant for failed read link operation with additional path context.
#[error("failed to read from {path:?}: {source}")]
#[error("failed to read link {path:?}: {source}")]
ReadLink {
/// The source `io::Error`.
source: io::Error,
@@ -230,6 +230,12 @@ pub fn read(path: impl AsRef<Path>) -> Result<Vec<u8>> {
fs::read(path).map_err(|err| FsPathError::read(err, path))
}
/// Wrapper for `std::fs::read_link`
pub fn read_link(path: impl AsRef<Path>) -> Result<PathBuf> {
let path = path.as_ref();
fs::read_link(path).map_err(|err| FsPathError::read_link(err, path))
}
/// Wrapper for `std::fs::write`
pub fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
let path = path.as_ref();