mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-23 16:07:52 +00:00
os2: better copy_directory, and add native copy_file and copy_directory variants on MacOS
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package darwin
|
||||
|
||||
import "core:sys/posix"
|
||||
|
||||
copyfile_state_t :: distinct rawptr
|
||||
|
||||
copyfile_flags :: bit_set[enum {
|
||||
ACL,
|
||||
STAT,
|
||||
XATTR,
|
||||
DATA,
|
||||
|
||||
RECURSIVE = 15,
|
||||
|
||||
CHECK,
|
||||
EXCL,
|
||||
NOFOLLOW_SRC,
|
||||
NOFOLLOW_DST,
|
||||
MOVE,
|
||||
UNLINK,
|
||||
PACK,
|
||||
UNPACK,
|
||||
|
||||
CLONE,
|
||||
CLONE_FORCE,
|
||||
RUN_IN_PLACE,
|
||||
DATA_SPARSE,
|
||||
PRESERVE_DST_TRACKED,
|
||||
VERBOSE = 30,
|
||||
}; u32]
|
||||
|
||||
COPYFILE_SECURITY :: copyfile_flags{.STAT, .ACL}
|
||||
COPYFILE_METADATA :: COPYFILE_SECURITY + copyfile_flags{.XATTR}
|
||||
COPYFILE_ALL :: COPYFILE_METADATA + copyfile_flags{.DATA}
|
||||
|
||||
COPYFILE_NOFOLLOW :: copyfile_flags{.NOFOLLOW_SRC, .NOFOLLOW_DST}
|
||||
|
||||
copyfile_state_flag :: enum u32 {
|
||||
SRC_FD = 1,
|
||||
SRC_FILENAME,
|
||||
DST_FD,
|
||||
DST_FILENAME,
|
||||
QUARANTINE,
|
||||
STATUS_CB,
|
||||
STATUS_CTX,
|
||||
COPIED,
|
||||
XATTRNAME,
|
||||
WAS_CLONED,
|
||||
SRC_BSIZE,
|
||||
DST_BSIZE,
|
||||
BSIZE,
|
||||
FORBID_CROSS_MOUNT,
|
||||
NOCPROTECT,
|
||||
PRESERVE_SUID,
|
||||
RECURSIVE_SRC_FTSENT,
|
||||
FORBID_DST_EXISTING_SYMLINKS,
|
||||
}
|
||||
|
||||
foreign system {
|
||||
copyfile :: proc(from, to: cstring, state: copyfile_state_t, flags: copyfile_flags) -> i32 ---
|
||||
fcopyfile :: proc(from, to: posix.FD, state: copyfile_state_t, flags: copyfile_flags) -> i32 ---
|
||||
|
||||
copyfile_state_alloc :: proc() -> copyfile_state_t ---
|
||||
copyfile_state_free :: proc(state: copyfile_state_t) -> posix.result ---
|
||||
copyfile_state_get :: proc(state: copyfile_state_t, flag: copyfile_state_flag, dst: rawptr) -> posix.result ---
|
||||
copyfile_state_set :: proc(state: copyfile_state_t, flag: copyfile_state_flag, src: rawptr) -> posix.result ---
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package darwin
|
||||
|
||||
import "core:c"
|
||||
|
||||
@(export)
|
||||
foreign import system "system:System.framework"
|
||||
|
||||
Bool :: b8
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package darwin
|
||||
|
||||
foreign import system "system:System.framework"
|
||||
|
||||
// #define OS_WAIT_ON_ADDR_AVAILABILITY \
|
||||
// __API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), watchos(10.4))
|
||||
when ODIN_OS == .Darwin {
|
||||
|
||||
@@ -19,16 +19,6 @@ X_OK :: c.int((1 << 0)) /* test for execute or search permission */
|
||||
W_OK :: c.int((1 << 1)) /* test for write permission */
|
||||
R_OK :: c.int((1 << 2)) /* test for read permission */
|
||||
|
||||
/* copyfile flags */
|
||||
COPYFILE_ACL :: (1 << 0)
|
||||
COPYFILE_STAT :: (1 << 1)
|
||||
COPYFILE_XATTR :: (1 << 2)
|
||||
COPYFILE_DATA :: (1 << 3)
|
||||
|
||||
COPYFILE_SECURITY :: (COPYFILE_STAT | COPYFILE_ACL)
|
||||
COPYFILE_METADATA :: (COPYFILE_SECURITY | COPYFILE_XATTR)
|
||||
COPYFILE_ALL :: (COPYFILE_METADATA | COPYFILE_DATA)
|
||||
|
||||
/* syslimits.h */
|
||||
PATH_MAX :: 1024 /* max bytes in pathname */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user