Skip to content

Commit b583af4

Browse files
committed
fs: fix Windows is_symlink type mismatch and add explanatory comment
1 parent fdd0b1d commit b583af4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • src/uucore/src/lib/features

src/uucore/src/lib/features/fs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,18 @@ impl FileInformation {
167167
return self.0.st_ino.into();
168168
}
169169

170+
// The concept of symlinks doesn't map exactly to Windows (which has reparse
171+
// points, junctions, etc.), so having our own method lets us control what
172+
// we consider a symlink across platforms.
170173
#[cfg(unix)]
171174
pub fn is_symlink(&self) -> bool {
172175
(self.0.st_mode as mode_t & S_IFMT) == S_IFLNK
173176
}
174177

175178
#[cfg(windows)]
176179
pub fn is_symlink(&self) -> bool {
177-
(self.0.file_attributes() & windows_sys::Win32::Storage::FileSystem::FILE_ATTRIBUTE_REPARSE_POINT) != 0
180+
use windows_sys::Win32::Storage::FileSystem::FILE_ATTRIBUTE_REPARSE_POINT;
181+
self.0.file_attributes() & u64::from(FILE_ATTRIBUTE_REPARSE_POINT) != 0
178182
}
179183
}
180184

0 commit comments

Comments
 (0)