Skip to content

Commit ebc145f

Browse files
committed
Auto merge of #2667 - devnexen:fcopyfile_mac, r=Amanieu
(f)copyfile fn for apple
2 parents 6449ebc + 4dfb4de commit ebc145f

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ fn test_apple(target: &str) {
182182
"aio.h",
183183
"CommonCrypto/CommonCrypto.h",
184184
"CommonCrypto/CommonRandom.h",
185+
"copyfile.h",
185186
"crt_externs.h",
186187
"ctype.h",
187188
"dirent.h",

libc-test/semver/apple.txt

+35
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,39 @@ CODESET
130130
CONNECT_DATA_AUTHENTICATED
131131
CONNECT_DATA_IDEMPOTENT
132132
CONNECT_RESUME_ON_READ_WRITE
133+
COPYFILE_ACL
134+
COPYFILE_CHECK
135+
COPYFILE_CLONE
136+
COPYFILE_CLONE_FORCE
137+
COPYFILE_CONTINUE
138+
COPYFILE_COPY_DATA
139+
COPYFILE_COPY_XATTR
140+
COPYFILE_DATA
141+
COPYFILE_DATA_SPARSE
142+
COPYFILE_ERR
143+
COPYFILE_EXCL
144+
COPYFILE_FINISH
145+
COPYFILE_METADATA
146+
COPYFILE_MOVE
147+
COPYFILE_NOFOLLOW
148+
COPYFILE_NOFOLLOW_DST
149+
COPYFILE_NOFOLLOW_SRC
150+
COPYFILE_PRESERVE_DST_TRACKED
151+
COPYFILE_PROGRESS
152+
COPYFILE_QUIT
153+
COPYFILE_RECURSE_DIR
154+
COPYFILE_RECURSE_DIR_CLEANUP
155+
COPYFILE_RECURSE_ERROR
156+
COPYFILE_RECURSE_FILE
157+
COPYFILE_RECURSIVE
158+
COPYFILE_RUN_IN_PLACE
159+
COPYFILE_SECURITY
160+
COPYFILE_SKIP
161+
COPYFILE_START
162+
COPYFILE_STAT
163+
COPYFILE_VERBOSE
164+
COPYFILE_UNLINK
165+
COPYFILE_XATTR
133166
CR0
134167
CR1
135168
CR2
@@ -1644,6 +1677,8 @@ clonefile
16441677
clonefileat
16451678
cmsghdr
16461679
connectx
1680+
copyfile
1681+
copyfile_flags_t
16471682
cpu_subtype_t
16481683
cpu_type_t
16491684
difftime

src/unix/bsd/apple/mod.rs

+53
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ pub type CCStatus = i32;
128128
pub type CCCryptorStatus = i32;
129129
pub type CCRNGStatus = ::CCCryptorStatus;
130130

131+
pub type copyfile_state_t = *mut ::c_void;
132+
pub type copyfile_flags_t = u32;
133+
131134
deprecated_mach! {
132135
pub type mach_timebase_info_data_t = mach_timebase_info;
133136
}
@@ -4611,6 +4614,43 @@ pub const RUSAGE_INFO_V2: ::c_int = 2;
46114614
pub const RUSAGE_INFO_V3: ::c_int = 3;
46124615
pub const RUSAGE_INFO_V4: ::c_int = 4;
46134616

4617+
// copyfile.h
4618+
pub const COPYFILE_ACL: ::copyfile_flags_t = 1 << 0;
4619+
pub const COPYFILE_STAT: ::copyfile_flags_t = 1 << 1;
4620+
pub const COPYFILE_XATTR: ::copyfile_flags_t = 1 << 2;
4621+
pub const COPYFILE_DATA: ::copyfile_flags_t = 1 << 3;
4622+
pub const COPYFILE_SECURITY: ::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL;
4623+
pub const COPYFILE_METADATA: ::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR;
4624+
pub const COPYFILE_RECURSIVE: ::copyfile_flags_t = 1 << 15;
4625+
pub const COPYFILE_CHECK: ::copyfile_flags_t = 1 << 16;
4626+
pub const COPYFILE_EXCL: ::copyfile_flags_t = 1 << 17;
4627+
pub const COPYFILE_NOFOLLOW_SRC: ::copyfile_flags_t = 1 << 18;
4628+
pub const COPYFILE_NOFOLLOW_DST: ::copyfile_flags_t = 1 << 19;
4629+
pub const COPYFILE_MOVE: ::copyfile_flags_t = 1 << 20;
4630+
pub const COPYFILE_UNLINK: ::copyfile_flags_t = 1 << 21;
4631+
pub const COPYFILE_NOFOLLOW: ::copyfile_flags_t = COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST;
4632+
pub const COPYFILE_PACK: ::copyfile_flags_t = 1 << 22;
4633+
pub const COPYFILE_UNPACK: ::copyfile_flags_t = 1 << 23;
4634+
pub const COPYFILE_CLONE: ::copyfile_flags_t = 1 << 24;
4635+
pub const COPYFILE_CLONE_FORCE: ::copyfile_flags_t = 1 << 25;
4636+
pub const COPYFILE_RUN_IN_PLACE: ::copyfile_flags_t = 1 << 26;
4637+
pub const COPYFILE_DATA_SPARSE: ::copyfile_flags_t = 1 << 27;
4638+
pub const COPYFILE_PRESERVE_DST_TRACKED: ::copyfile_flags_t = 1 << 28;
4639+
pub const COPYFILE_VERBOSE: ::copyfile_flags_t = 1 << 30;
4640+
pub const COPYFILE_RECURSE_ERROR: ::c_int = 0;
4641+
pub const COPYFILE_RECURSE_FILE: ::c_int = 1;
4642+
pub const COPYFILE_RECURSE_DIR: ::c_int = 2;
4643+
pub const COPYFILE_RECURSE_DIR_CLEANUP: ::c_int = 3;
4644+
pub const COPYFILE_COPY_DATA: ::c_int = 4;
4645+
pub const COPYFILE_COPY_XATTR: ::c_int = 5;
4646+
pub const COPYFILE_START: ::c_int = 1;
4647+
pub const COPYFILE_FINISH: ::c_int = 2;
4648+
pub const COPYFILE_ERR: ::c_int = 3;
4649+
pub const COPYFILE_PROGRESS: ::c_int = 4;
4650+
pub const COPYFILE_CONTINUE: ::c_int = 0;
4651+
pub const COPYFILE_SKIP: ::c_int = 1;
4652+
pub const COPYFILE_QUIT: ::c_int = 2;
4653+
46144654
cfg_if! {
46154655
if #[cfg(libc_const_extern_fn)] {
46164656
const fn __DARWIN_ALIGN32(p: usize) -> usize {
@@ -5267,6 +5307,19 @@ extern "C" {
52675307
flags: u32,
52685308
) -> ::c_int;
52695309

5310+
pub fn copyfile(
5311+
from: *const ::c_char,
5312+
to: *const ::c_char,
5313+
state: copyfile_state_t,
5314+
flags: copyfile_flags_t,
5315+
) -> ::c_int;
5316+
pub fn fcopyfile(
5317+
from: ::c_int,
5318+
to: ::c_int,
5319+
state: copyfile_state_t,
5320+
flags: copyfile_flags_t,
5321+
) -> ::c_int;
5322+
52705323
// Added in macOS 10.13
52715324
// ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1
52725325
pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int;

0 commit comments

Comments
 (0)