-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copy_file implemented for Windows, Linux and Darwin #3186
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things to fix up, otherwise decent.
It would be nice if on *nix platforms it'd copy permissions (chmod) and ownership (chown) instead of assigning the new file to the current user with some default permissions, or being able to pass in the desired owner and permission. |
I did stat for and copy the permissions at first, but decided to simplify |
Should I make it possible to pass chmod and chown? |
For a simple implementation copying the original permissions should be enough |
Ok, now I stat for the mode first and open the new file with that mode |
I tested the implementation on MacOS and it works as expected |
thanks! |
Some thoughts:
|
You probably also want |
It currently doesn't remove a partially copied file - at least not explicitly. |
I am unable to test it on darwin, but I assumed it's the same as Linux, so I copied it
Linux tested with WSL
Windows tested on Windows 11
This function was inspired by - https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-copyfile