github.com/josephvusich/fdf@v0.0.0-20230522095411-9326dd32e33f/copyfile_darwin.go (about) 1 package main 2 3 // #include <copyfile.h> 4 // #include <stdlib.h> 5 // #include <errno.h> 6 // 7 // int copyAndFree(char *src, char *dst) { 8 // int result = copyfile(src, dst, NULL, COPYFILE_CLONE); 9 // int err = errno; 10 // free(src); 11 // free(dst); 12 // errno = err; 13 // return result; 14 // } 15 import "C" 16 17 func copyFile(src, dst string) error { 18 result, err := C.copyAndFree(C.CString(src), C.CString(dst)) 19 if result != 0 { 20 return err 21 } 22 return nil 23 }