authorgravatar for devnexen@gmail.comDavid Carlier <devnexen@gmail.com> 2023-05-16 20:21:31+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-17 06:06:41+03:00
log40e8c2243c139dc499298645a2b387e30ae09cba
tree98a8e0c5dd6e573dff631768cc541dc095faab83
parentc6966486e3d33054f1dfc822704dc48c62466d54

std.c: darwin's *copyfile api update.


2 files changed, 60 insertions(+), 6 deletions(-)

lib/std/c/darwin.zig+59-5
...@@ -163,13 +163,67 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;...@@ -163,13 +163,67 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;
163pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize;163pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize;
164pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8;164pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8;
165165
166pub const COPYFILE_ACL = 1 << 0;166pub const COPYFILE = struct {
167pub const COPYFILE_STAT = 1 << 1;167 pub const ACL = 1 << 0;
168pub const COPYFILE_XATTR = 1 << 2;168 pub const STAT = 1 << 1;
169pub const COPYFILE_DATA = 1 << 3;169 pub const XATTR = 1 << 2;
170 pub const DATA = 1 << 3;
171 pub const SECURITY = COPYFILE.STAT | COPYFILE.ACL;
172 pub const METADATA = COPYFILE.SECURITY | COPYFILE.XATTR;
173 pub const ALL = COPYFILE.METADATA | COPYFILE.DATA;
174 pub const RECURSIVE = 1 << 15;
175 pub const CHECK = 1 << 16;
176 pub const EXCL = 1 << 17;
177 pub const NOFOLLOW_SRC = 1 << 18;
178 pub const NOFOLLOW_DST = 1 << 19;
179 pub const MOVE = 1 << 20;
180 pub const UNLINK = 1 << 21;
181 pub const NOFOLLOW = COPYFILE.NOFOLLOW_SRC | NOFOLLOW_DST;
182 pub const PACK = 1 << 22;
183 pub const UNPACK = 1 << 23;
184 pub const CLONE = 1 << 24;
185 pub const CLONE_FORCE = 1 << 25;
186 pub const RUN_IN_PLACE = 1 << 26;
187 pub const DATA_SPARSE = 1 << 27;
188 pub const PRESERVE_DST_TRACKED = 1 << 28;
189 pub const VERBOSE = 1 << 30;
190 pub const RECURSE_ERROR = 0;
191 pub const RECURSE_FILE = 1;
192 pub const RECURSE_DIR = 2;
193 pub const RECURSE_DIR_CLEANUP = 3;
194 pub const COPY_DATA = 4;
195 pub const COPY_XATTR = 5;
196 pub const START = 1;
197 pub const FINISH = 2;
198 pub const ERR = 3;
199 pub const PROGRESS = 4;
200 pub const CONTINUE = 0;
201 pub const SKIP = 1;
202 pub const QUIT = 2;
203 pub const STATE_SRC_FD = 1;
204 pub const STATE_SRC_FILENAME = 2;
205 pub const STATE_DST_FD = 3;
206 pub const STATE_DST_FILENAME = 4;
207 pub const STATE_QUARANTINE = 5;
208 pub const STATE_STATUS_CB = 6;
209 pub const STATE_STATUS_CTX = 7;
210 pub const STATE_COPIED = 8;
211 pub const STATE_XATTRNAME = 9;
212 pub const STATE_WAS_CLONED = 10;
213 pub const STATE_SRC_BSIZE = 11;
214 pub const STATE_DST_BSIZE = 12;
215 pub const STATE_BSIZE = 13;
216 pub const DISABLE_VAR: [*]u8 = "COPYFILE_DISABLE";
217};
170218
171pub const copyfile_state_t = *opaque {};219pub const copyfile_state_t = *opaque {};
172pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int;220pub const copyfile_flags_t = u32;
221pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: copyfile_flags_t) c_int;
222pub extern "c" fn copyfile(from: [*:0]u8, to: [*:0]u8, state: ?copyfile_state_t, flags: copyfile_flags_t) c_int;
223pub extern "c" fn copyfile_state_alloc() copyfile_state_t;
224pub extern "c" fn copyfile_state_free(state: copyfile_state_t) void;
225pub extern "c" fn copyfile_state_get(s: copyfile_state_t, flag: u32, dst: ?*anyopaque) c_int;
226pub extern "c" fn copyfile_state_set(s: copyfile_state_t, flag: u32, dst: ?*const anyopaque) c_int;
173227
174pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;228pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
175pub const realpath = @"realpath$DARWIN_EXTSN";229pub const realpath = @"realpath$DARWIN_EXTSN";
lib/std/fs.zig+1-1
...@@ -3102,7 +3102,7 @@ const CopyFileRawError = error{SystemResources} || os.CopyFileRangeError || os.S...@@ -3102,7 +3102,7 @@ const CopyFileRawError = error{SystemResources} || os.CopyFileRangeError || os.S
3102// No metadata is transferred over.3102// No metadata is transferred over.
3103fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t, maybe_size: ?u64) CopyFileRawError!void {3103fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t, maybe_size: ?u64) CopyFileRawError!void {
3104 if (comptime builtin.target.isDarwin()) {3104 if (comptime builtin.target.isDarwin()) {
3105 const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA);3105 const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE.DATA);
3106 switch (os.errno(rc)) {3106 switch (os.errno(rc)) {
3107 .SUCCESS => return,3107 .SUCCESS => return,
3108 .INVAL => unreachable,3108 .INVAL => unreachable,