Sha256: cfd2ad4ac6f1588d43d0cf8b1f92f736515299a0738824095b86432ab81027e2
Contents?: true
Size: 959 Bytes
Versions: 36
Compression:
Stored size: 959 Bytes
Contents
use super::open_parent; use crate::fs::{read_link_unchecked, MaybeOwnedFile}; use std::path::{Path, PathBuf}; use std::{fs, io}; /// Implement `read_link` by `open`ing up the parent component of the path and /// then calling `read_link_unchecked` on the last component. /// /// This technique doesn't work in all cases on Windows. In particular, a /// directory symlink such as `C:\Documents and Settings` may not grant any /// access other than what is needed to resolve the symlink, so `open_parent`'s /// technique of returning a relative path of `.` from that point doesn't work, /// because opening `.` within such a directory is denied. Consequently, we use /// a different implementation on Windows. pub(crate) fn read_link(start: &fs::File, path: &Path) -> io::Result<PathBuf> { let start = MaybeOwnedFile::borrowed(start); let (dir, basename) = open_parent(start, path)?; read_link_unchecked(&dir, basename.as_ref(), PathBuf::new()) }
Version data entries
36 entries across 36 versions & 1 rubygems