Skip to content

Commit

Permalink
(f)copyfile fn for apple
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Feb 3, 2022
1 parent 34a9889 commit 4dfb4de
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ fn test_apple(target: &str) {
"aio.h",
"CommonCrypto/CommonCrypto.h",
"CommonCrypto/CommonRandom.h",
"copyfile.h",
"crt_externs.h",
"ctype.h",
"dirent.h",
Expand Down
35 changes: 35 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,39 @@ CODESET
CONNECT_DATA_AUTHENTICATED
CONNECT_DATA_IDEMPOTENT
CONNECT_RESUME_ON_READ_WRITE
COPYFILE_ACL
COPYFILE_CHECK
COPYFILE_CLONE
COPYFILE_CLONE_FORCE
COPYFILE_CONTINUE
COPYFILE_COPY_DATA
COPYFILE_COPY_XATTR
COPYFILE_DATA
COPYFILE_DATA_SPARSE
COPYFILE_ERR
COPYFILE_EXCL
COPYFILE_FINISH
COPYFILE_METADATA
COPYFILE_MOVE
COPYFILE_NOFOLLOW
COPYFILE_NOFOLLOW_DST
COPYFILE_NOFOLLOW_SRC
COPYFILE_PRESERVE_DST_TRACKED
COPYFILE_PROGRESS
COPYFILE_QUIT
COPYFILE_RECURSE_DIR
COPYFILE_RECURSE_DIR_CLEANUP
COPYFILE_RECURSE_ERROR
COPYFILE_RECURSE_FILE
COPYFILE_RECURSIVE
COPYFILE_RUN_IN_PLACE
COPYFILE_SECURITY
COPYFILE_SKIP
COPYFILE_START
COPYFILE_STAT
COPYFILE_VERBOSE
COPYFILE_UNLINK
COPYFILE_XATTR
CR0
CR1
CR2
Expand Down Expand Up @@ -1644,6 +1677,8 @@ clonefile
clonefileat
cmsghdr
connectx
copyfile
copyfile_flags_t
cpu_subtype_t
cpu_type_t
difftime
Expand Down
53 changes: 53 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ pub type CCStatus = i32;
pub type CCCryptorStatus = i32;
pub type CCRNGStatus = ::CCCryptorStatus;

pub type copyfile_state_t = *mut ::c_void;
pub type copyfile_flags_t = u32;

deprecated_mach! {
pub type mach_timebase_info_data_t = mach_timebase_info;
}
Expand Down Expand Up @@ -4611,6 +4614,43 @@ pub const RUSAGE_INFO_V2: ::c_int = 2;
pub const RUSAGE_INFO_V3: ::c_int = 3;
pub const RUSAGE_INFO_V4: ::c_int = 4;

// copyfile.h
pub const COPYFILE_ACL: ::copyfile_flags_t = 1 << 0;
pub const COPYFILE_STAT: ::copyfile_flags_t = 1 << 1;
pub const COPYFILE_XATTR: ::copyfile_flags_t = 1 << 2;
pub const COPYFILE_DATA: ::copyfile_flags_t = 1 << 3;
pub const COPYFILE_SECURITY: ::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL;
pub const COPYFILE_METADATA: ::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR;
pub const COPYFILE_RECURSIVE: ::copyfile_flags_t = 1 << 15;
pub const COPYFILE_CHECK: ::copyfile_flags_t = 1 << 16;
pub const COPYFILE_EXCL: ::copyfile_flags_t = 1 << 17;
pub const COPYFILE_NOFOLLOW_SRC: ::copyfile_flags_t = 1 << 18;
pub const COPYFILE_NOFOLLOW_DST: ::copyfile_flags_t = 1 << 19;
pub const COPYFILE_MOVE: ::copyfile_flags_t = 1 << 20;
pub const COPYFILE_UNLINK: ::copyfile_flags_t = 1 << 21;
pub const COPYFILE_NOFOLLOW: ::copyfile_flags_t = COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST;
pub const COPYFILE_PACK: ::copyfile_flags_t = 1 << 22;
pub const COPYFILE_UNPACK: ::copyfile_flags_t = 1 << 23;
pub const COPYFILE_CLONE: ::copyfile_flags_t = 1 << 24;
pub const COPYFILE_CLONE_FORCE: ::copyfile_flags_t = 1 << 25;
pub const COPYFILE_RUN_IN_PLACE: ::copyfile_flags_t = 1 << 26;
pub const COPYFILE_DATA_SPARSE: ::copyfile_flags_t = 1 << 27;
pub const COPYFILE_PRESERVE_DST_TRACKED: ::copyfile_flags_t = 1 << 28;
pub const COPYFILE_VERBOSE: ::copyfile_flags_t = 1 << 30;
pub const COPYFILE_RECURSE_ERROR: ::c_int = 0;
pub const COPYFILE_RECURSE_FILE: ::c_int = 1;
pub const COPYFILE_RECURSE_DIR: ::c_int = 2;
pub const COPYFILE_RECURSE_DIR_CLEANUP: ::c_int = 3;
pub const COPYFILE_COPY_DATA: ::c_int = 4;
pub const COPYFILE_COPY_XATTR: ::c_int = 5;
pub const COPYFILE_START: ::c_int = 1;
pub const COPYFILE_FINISH: ::c_int = 2;
pub const COPYFILE_ERR: ::c_int = 3;
pub const COPYFILE_PROGRESS: ::c_int = 4;
pub const COPYFILE_CONTINUE: ::c_int = 0;
pub const COPYFILE_SKIP: ::c_int = 1;
pub const COPYFILE_QUIT: ::c_int = 2;

cfg_if! {
if #[cfg(libc_const_extern_fn)] {
const fn __DARWIN_ALIGN32(p: usize) -> usize {
Expand Down Expand Up @@ -5267,6 +5307,19 @@ extern "C" {
flags: u32,
) -> ::c_int;

pub fn copyfile(
from: *const ::c_char,
to: *const ::c_char,
state: copyfile_state_t,
flags: copyfile_flags_t,
) -> ::c_int;
pub fn fcopyfile(
from: ::c_int,
to: ::c_int,
state: copyfile_state_t,
flags: copyfile_flags_t,
) -> ::c_int;

// Added in macOS 10.13
// ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1
pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int;
Expand Down

0 comments on commit 4dfb4de

Please sign in to comment.