| 1 |
// Take a look at the license at the top of the repository in the LICENSE file. |
| 2 |
|
| 3 |
use std::mem; |
| 4 |
|
| 5 |
use glib::translate::*; |
| 6 |
|
| 7 |
use crate::{MountEntry, ffi}; |
| 8 |
|
| 9 |
impl MountEntry { |
| 10 |
#[doc(alias = "g_unix_mounts_get")] |
| 11 |
#[doc(alias = "g_unix_mount_entries_get")] |
| 12 |
#[doc(alias = "get_mounts")] |
| 13 |
pub fn mounts() -> (Vec<MountEntry>, u64) { |
| 14 |
unsafe { |
| 15 |
let mut time_read = mem::MaybeUninit::uninit(); |
| 16 |
let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mount_entries_get( |
| 17 |
time_read.as_mut_ptr(), |
| 18 |
)); |
| 19 |
let time_read = time_read.assume_init(); |
| 20 |
(ret, time_read) |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
#[doc(alias = "g_unix_mounts_get")] |
| 25 |
#[doc(alias = "g_unix_mount_entries_get")] |
| 26 |
#[doc(alias = "get_mounts")] |
| 27 |
pub fn mounts_from_file(table_path: impl AsRef<std::path::Path>) -> (Vec<MountEntry>, u64) { |
| 28 |
unsafe { |
| 29 |
let mut time_read = mem::MaybeUninit::uninit(); |
| 30 |
let mut n_entries_out = mem::MaybeUninit::uninit(); |
| 31 |
let ret = ffi::g_unix_mount_entries_get_from_file( |
| 32 |
table_path.as_ref().to_glib_none().0, |
| 33 |
time_read.as_mut_ptr(), |
| 34 |
n_entries_out.as_mut_ptr(), |
| 35 |
); |
| 36 |
let n_entries_out = n_entries_out.assume_init(); |
| 37 |
let ret = FromGlibContainer::from_glib_full_num(ret, n_entries_out); |
| 38 |
let time_read = time_read.assume_init(); |
| 39 |
(ret, time_read) |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
#[doc(alias = "g_unix_mounts_changed_since")] |
| 44 |
#[doc(alias = "g_unix_mount_entries_changed_since")] |
| 45 |
pub fn is_changed_since(time: u64) -> bool { |
| 46 |
unsafe { from_glib(ffi::g_unix_mount_entries_changed_since(time)) } |
| 47 |
} |
| 48 |
} |