os2: better copy_directory, and add native copy_file and copy_directory variants on MacOS

This commit is contained in:
Laytan Laats
2025-05-08 19:32:30 +02:00
parent edbe7aa06e
commit cacb9f9f54
8 changed files with 162 additions and 25 deletions
+17
View File
@@ -0,0 +1,17 @@
#+private
package os2
import "core:sys/darwin"
_copy_directory_all_native :: proc(dst, src: string, dst_perm := 0o755) -> (err: Error) {
temp_allocator := TEMP_ALLOCATOR_GUARD({})
csrc := clone_to_cstring(src, temp_allocator) or_return
cdst := clone_to_cstring(dst, temp_allocator) or_return
if darwin.copyfile(csrc, cdst, nil, darwin.COPYFILE_ALL + {.RECURSIVE}) < 0 {
err = _get_platform_error()
}
return
}