Symbolic links are implemented in Windows as reparse points with a dedicated reparse tag. Such reparse points' data contains the name of the target of the symbolic link, i.e. the file or directory referenced by the symbolic link.
In order to support symbolic links, an application must do the following things:
- Enable reparse points by setting the use_reparse_points property to True and implementing the corresponding events:
- For files and directories which are symbolic links, include the FILE_ATTRIBUTE_REPARSE_POINT flag in the attributes of the corresponding file or directory when handling the on_enumerate_directory and on_get_file_info events.
- When handling the on_open_file event, check whether the Attributes event parameter contains the FILE_FLAG_OPEN_REPARSE_POINT flag. If the flag is present, the application must open the target instead of the file itself. If the flag is not present, the application must act as if the file didn't have a reparse point attached to it.
Additionally, for Network-type mounting points (i.e., those where STGMP_NETWORK was included in the value passed for the add_mounting_point method's Flags parameter), symbolic links will only work if support for symbolic links on network drives is enabled in the system. This can be done by running the following commands in an elevated command prompt:
- fsutil behavior set symlinkEvaluation R2R:1
- fsutil behavior set symlinkEvaluation L2R:1
- fsutil behavior set symlinkEvaluation R2L:1