diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-06-19 00:59:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 00:59:54 (GMT) |
commit | 20d5b84f57a6f7e5a76109e483abe39d9f703d56 (patch) | |
tree | db0e439b59968cd5fcff982e13f1b155ed3f0a80 /Modules | |
parent | 9f741e55c16376412c1473aa45b94314c00a0c43 (diff) | |
download | cpython-20d5b84f57a6f7e5a76109e483abe39d9f703d56.zip cpython-20d5b84f57a6f7e5a76109e483abe39d9f703d56.tar.gz cpython-20d5b84f57a6f7e5a76109e483abe39d9f703d56.tar.bz2 |
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.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_winapi.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 8794d56..c90d6c5 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -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); |