• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::fs::CopyfileFlags;
2 use crate::{backend, io};
3 use backend::fd::AsFd;
4 
5 /// `copyfile_state_t`
6 pub use backend::fs::types::copyfile_state_t;
7 
8 /// `fcopyfile(from, to, state, flags)`
9 ///
10 /// # Safety
11 ///
12 /// The `state` operand must be allocated with `copyfile_state_alloc` and not
13 /// yet freed with `copyfile_state_free`.
14 ///
15 /// # References
16 ///  - [Apple]
17 ///
18 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html
19 #[inline]
fcopyfile<FromFd: AsFd, ToFd: AsFd>( from: FromFd, to: ToFd, state: copyfile_state_t, flags: CopyfileFlags, ) -> io::Result<()>20 pub unsafe fn fcopyfile<FromFd: AsFd, ToFd: AsFd>(
21     from: FromFd,
22     to: ToFd,
23     state: copyfile_state_t,
24     flags: CopyfileFlags,
25 ) -> io::Result<()> {
26     backend::fs::syscalls::fcopyfile(from.as_fd(), to.as_fd(), state, flags)
27 }
28 
29 /// `copyfile_state_alloc()`
30 ///
31 /// # References
32 ///  - [Apple]
33 ///
34 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html
35 #[inline]
copyfile_state_alloc() -> io::Result<copyfile_state_t>36 pub fn copyfile_state_alloc() -> io::Result<copyfile_state_t> {
37     backend::fs::syscalls::copyfile_state_alloc()
38 }
39 
40 /// `copyfile_state_free(state)`
41 ///
42 /// # Safety
43 ///
44 /// The `state` operand must be allocated with `copyfile_state_alloc` and not
45 /// yet freed with `copyfile_state_free`.
46 ///
47 /// # References
48 ///  - [Apple]
49 ///
50 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html
51 #[inline]
copyfile_state_free(state: copyfile_state_t) -> io::Result<()>52 pub unsafe fn copyfile_state_free(state: copyfile_state_t) -> io::Result<()> {
53     backend::fs::syscalls::copyfile_state_free(state)
54 }
55 
56 /// `copyfile_state_get(state, COPYFILE_STATE_COPIED)`
57 ///
58 /// # Safety
59 ///
60 /// The `state` operand must be allocated with `copyfile_state_alloc` and not
61 /// yet freed with `copyfile_state_free`.
62 ///
63 /// # References
64 ///  - [Apple]
65 ///
66 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html
67 #[inline]
copyfile_state_get_copied(state: copyfile_state_t) -> io::Result<u64>68 pub unsafe fn copyfile_state_get_copied(state: copyfile_state_t) -> io::Result<u64> {
69     backend::fs::syscalls::copyfile_state_get_copied(state)
70 }
71 
72 /// `copyfile_state_get(state, flags, dst)`
73 ///
74 /// # Safety
75 ///
76 /// The `state` operand must be allocated with `copyfile_state_alloc` and not
77 /// yet freed with `copyfile_state_free`.
78 ///
79 /// # References
80 ///  - [Apple]
81 ///
82 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html
83 #[inline]
copyfile_state_get( state: copyfile_state_t, flag: u32, dst: *mut core::ffi::c_void, ) -> io::Result<()>84 pub unsafe fn copyfile_state_get(
85     state: copyfile_state_t,
86     flag: u32,
87     dst: *mut core::ffi::c_void,
88 ) -> io::Result<()> {
89     backend::fs::syscalls::copyfile_state_get(state, flag, dst)
90 }
91