3 ms·
Just want to mention: Apple ships a modified version of the copy command (good old cp) that supports the ability to use the cloning feature of APFS by using the
by alwillis 2y ago
Just want to mention: Apple ships a modified version of the copy command (good old cp) that supports the ability to use the cloning feature of APFS by using the -c flag.
- kccqzy 2y agoAnd in case your cp doesn't support it, you could also do it by invoking Python. Something like `import Foundation; Foundation.NSFileManager.defaultManager().copyItemAtPath_toPath_error_(...)`.
- jlhawn 2y agothat function name `copyItemAtPath_toPath_error_` sounds like it was ported directly from objective-c!
- kccqzy 2y agoThey might not have ported it. They could have a Python __getattr__ implementation that returns a callable that simply uses objc_msgSend under the hood.
- xenadu02 2y agoCorrect. Foundation's NSFileManager / FileManager will automatically use clone for same-volume copies if the underlying filesystem supports it. This makes all file copies in all apps that use Foundation support cloning even if the app does nothing. libcopyfile also supports cloning via two flags: COPYFILE_CLONE and COPYFILE_CLONE_FORCE. The former clones if supported (same volume and filesystem supports it) and falls back to actual copy if not. The force variant fails if cloning isn't supported.
- alwillis 2y agoApparently the cp command in CoreUtilities also supports copy-on-write on macOS: https://unix.stackexchange.com/questions/311536/cp-reflink-auto-for-macos-x https://unix.stackexchange.com/questions/311536/cp-reflink-a...