Having trouble implementing a readlink() function

后端 未结 2 696
[愿得一人]
[愿得一人] 2020-12-11 04:26

I\'ve been trying to figure out a way to get some sort of ability to be able to return the true abspath of a symbolic link in Windows, under Python 2.7. (I cannot upgrade to

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 05:27

    This is implemented in Tcl as file readlink and the implementation of this might be worth reading as there seem to be a few differences. The WinReadLinkDirectory function calls NativeReadReparse to read the REPARSE_DATA_BUFFER but this uses different flags to the CreateFile function. Also the buffer size is different I think and the size of structures in Win32 calls is often used to detect the version of the API used so it is likely worth taking care to set the size to the correct value (or possibly the same value used in the Tcl implementation).

    Just to show what I mean by Tcl support for this:

    C:\>dir
     Directory of C:\
    
    22/09/2014  14:29         Code [C:\src]
    ...
    
    C:\>tclsh
    % file readlink Code
    C:\src
    

提交回复
热议问题