diff options
author | Tim Golden <mail@timgolden.me.uk> | 2014-04-27 17:00:10 (GMT) |
---|---|---|
committer | Tim Golden <mail@timgolden.me.uk> | 2014-04-27 17:00:10 (GMT) |
commit | 4675d798bfdef3ad916d1eef6d5a4d0529ccfda7 (patch) | |
tree | 628685ce1f8db9455bb95819f876faa7c56bf020 /Modules/posixmodule.c | |
parent | dd41f246875494c9acc6ebd4338f8df3ec6c28f0 (diff) | |
download | cpython-4675d798bfdef3ad916d1eef6d5a4d0529ccfda7.zip cpython-4675d798bfdef3ad916d1eef6d5a4d0529ccfda7.tar.gz cpython-4675d798bfdef3ad916d1eef6d5a4d0529ccfda7.tar.bz2 |
Issue #18314 os.unlink will now remove junction points on Windows. Patch by Kim Gräsman.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8cd5485..916be81 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -27,6 +27,8 @@ #include "Python.h" #ifndef MS_WINDOWS #include "posixmodule.h" +#else +#include "winreparse.h" #endif #ifdef __cplusplus @@ -301,6 +303,9 @@ extern int lstat(const char *, struct stat *); #ifndef IO_REPARSE_TAG_SYMLINK #define IO_REPARSE_TAG_SYMLINK (0xA000000CL) #endif +#ifndef IO_REPARSE_TAG_MOUNT_POINT +#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) +#endif #include "osdefs.h" #include <malloc.h> #include <windows.h> @@ -1109,41 +1114,6 @@ _PyVerify_fd_dup2(int fd1, int fd2) #endif #ifdef MS_WINDOWS -/* The following structure was copied from - http://msdn.microsoft.com/en-us/library/ms791514.aspx as the required - include doesn't seem to be present in the Windows SDK (at least as included - with Visual Studio Express). */ -typedef struct _REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - }; -} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; - -#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\ - GenericReparseBuffer) -#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) static int win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag) @@ -4492,7 +4462,10 @@ BOOL WINAPI Py_DeleteFileW(LPCWSTR lpFileName) find_data_handle = FindFirstFileW(lpFileName, &find_data); if(find_data_handle != INVALID_HANDLE_VALUE) { - is_link = find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK; + /* IO_REPARSE_TAG_SYMLINK if it is a symlink and + IO_REPARSE_TAG_MOUNT_POINT if it is a junction point. */ + is_link = find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK || + find_data.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT; FindClose(find_data_handle); } } |