@@ -748,8 +748,37 @@ pub(super) mod _os {
748
748
#[ cfg( windows) ]
749
749
#[ pymethod]
750
750
fn is_junction ( & self , _vm : & VirtualMachine ) -> PyResult < bool > {
751
- fs:: metadata ( & path) . map_or ( false , |meta| meta. file_type ( ) . is_dir ( ) )
752
- && fs:: symlink_metadata ( & path) . map_or ( false , |meta| meta. file_type ( ) . is_symlink ( ) )
751
+ Ok ( junction:: exists ( self . pathval . clone ( ) ) . expect ( "Failed to check it is junction." ) )
752
+ // unsafe {
753
+ // use std::os::{
754
+ // windows::fs::{MetadataExt, IO_REPARSE_TAG_MOUNT_POINT},
755
+ // raw::c_ulong,
756
+ // };
757
+ // use std::mem;
758
+ // use window_sys::Win32::Storage::FileSystem::{FILE_ATTRIBUTE_TAG_INFO, FileAttributeTagInfo, GetFileInformationByHandleEx, FILE_ATTRIBUTE_REPARSE_POINT, GetFileInformationByHandle, BY_HANDLE_FILE_INFORMATION};
759
+ //
760
+ // let f = OpenOptions::new()
761
+ // .read(true)
762
+ // .custom_flags(windows_sys::Win32::Storage::FileSystem::FILE_FLAG_BACKUP_SEMANTICS)
763
+ // .open(path)
764
+ // .map_err(|err| err.into_pyexception(vm))?;
765
+ //
766
+ // let mut info: BY_HANDLE_FILE_INFORMATION = mem::zeroed();
767
+ // GetFileInformationByHandle(f.as_raw_handle(), &mut info);
768
+ // let mut reparse_tag = 0;
769
+ // if info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT != 0 {
770
+ // let mut attr_tag: FILE_ATTRIBUTE_TAG_INFO = mem::zeroed();
771
+ // GetFileInformationByHandleEx(
772
+ // self.handle.as_raw_handle(),
773
+ // FileAttributeTagInfo,
774
+ // ptr::addr_of_mut!(attr_tag).cast(),
775
+ // mem::size_of::<FILE_ATTRIBUTE_TAG_INFO>().try_into().unwrap(),
776
+ // );
777
+ // if attr_tag.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT != 0 {
778
+ // reparse_tag = attr_tag.ReparseTag;
779
+ // }
780
+ // }
781
+ // }
753
782
}
754
783
755
784
#[ pymethod( magic) ]
0 commit comments