I am running os.walk()
on "C:\Users\confusedDev\Documents"
, I see ["My Music", "My Pictures"...]
returned as subDirs but they are not actually being visited. After some research I found that they are actually junctions in Windows.
My understanding is that junction is a symlink points to directory, which gets ignored by default during os.walk()
, but the following test has failed me
>>> os.path.islink("C:\\Users\\confusedDev\\Documents\\My Pictures")
False
hmm...how did os.walk()
know that "C:\Users\confusedDev\Documents\My Pictures" is a symlink to "C:\Users\confusedDev\Pictures" and needed to be skipped? I want to call the same api...For now, my workaround logic simply assumes that if a directory is skipped by os.walk()
, it is a junction
os.[l]stat
is internally inconsistent. Forfollow_symlinks
it handles any reparse point as a link, instead of correctly limiting this to just symlinks and [some] junctions. Additionally, when creating the stat result, it accepts only symlink reparse points for theS_IFLNK
mode flag, which is whatislink
checks. It should also accept junctions, but only when they implement a legacy link, i.e. not when the target is a "\\?\Volume{...}" mountpoint for whichGetVolumeNameForVolumeMountPoint
would succeed. – Rosenjunction links
, not symbolic links: #9043042. they are not the same in windows.. andislink
returns false even in Python3 forjunction links
. Any idea how to checkjunction links
in python? – Dissimulation