Given the following scenario: I have a windows client which is connected to an SMB share. I want to recursively dive into directories on that share to do something with the files (imagine calculating sha1 hashes for them if a certain size is exceeded).
What I would normally do: recursive dirInfo.EnumerateDirectories()
catching some exceptional cases like unauthorized access and queue the files to an operator thread (to calc the sha1 then).
The Challenge: Recursive symlinks. My testscenario is quite simple
me@smb:~$ ls -l /home/me/tmp/recursionStartsHere
lrwxrwxrwx recursion -> /home/me/tmp/recursionStartsHere
What I have tried (apart from googlin) is to use dirInfo.Attributes.HasFlag(FlagAttributes.ReparsePoint)
to detect symlinks which (of course) does not work out. The brute force approach seems like indexing every single directory with an accumulated checksum from their contents - which may not even be collision free.
As I am out of practical ideas now, how can I tell a certain directory is (only) a symlink? Of course, I'd prefer a platform independent so my code works the same for remote SMB as well as on local NTFS drives.