mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
GH-73991: Add follow_symlinks argument to pathlib.Path.copy()
(#120519)
Add support for not following symlinks in `pathlib.Path.copy()`. On Windows we add the `COPY_FILE_COPY_SYMLINK` flag is following symlinks is disabled. If the source is symlink to a directory, this call will fail with `ERROR_ACCESS_DENIED`. In this case we add `COPY_FILE_DIRECTORY` to the flags and retry. This can fail on old Windowses, which we note in the docs. No news as `copy()` was only just added.
This commit is contained in:
parent
9f741e55c1
commit
20d5b84f57
6 changed files with 86 additions and 11 deletions
|
@ -3166,6 +3166,11 @@ static int winapi_exec(PyObject *m)
|
|||
#define COPY_FILE_REQUEST_COMPRESSED_TRAFFIC 0x10000000
|
||||
#endif
|
||||
WINAPI_CONSTANT(F_DWORD, COPY_FILE_REQUEST_COMPRESSED_TRAFFIC);
|
||||
#ifndef COPY_FILE_DIRECTORY
|
||||
// Only defined in newer WinSDKs
|
||||
#define COPY_FILE_DIRECTORY 0x00000080
|
||||
#endif
|
||||
WINAPI_CONSTANT(F_DWORD, COPY_FILE_DIRECTORY);
|
||||
|
||||
WINAPI_CONSTANT(F_DWORD, COPYFILE2_CALLBACK_CHUNK_STARTED);
|
||||
WINAPI_CONSTANT(F_DWORD, COPYFILE2_CALLBACK_CHUNK_FINISHED);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue