From 9ee1f2c9d0fd7cd25edeaf12c88aeb8a6e996a01 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 14 Sep 2023 22:58:31 +0200 Subject: [PATCH] Move unix platforms into the same folder to move the unix files into it as well --- src/lib.rs | 46 ++++--------------- src/macros.rs | 2 +- src/{ => unix}/apple/app_store/component.rs | 2 +- src/{ => unix}/apple/app_store/mod.rs | 0 src/{ => unix}/apple/app_store/process.rs | 2 +- src/{ => unix}/apple/component.rs | 0 src/{ => unix}/apple/cpu.rs | 2 +- src/{ => unix}/apple/disk.rs | 2 +- src/{ => unix}/apple/ffi.rs | 0 src/{ => unix}/apple/ios.rs | 0 src/{ => unix}/apple/macos/component/arm.rs | 4 +- src/{ => unix}/apple/macos/component/mod.rs | 0 src/{ => unix}/apple/macos/component/x86.rs | 2 +- src/{ => unix}/apple/macos/cpu.rs | 0 src/{ => unix}/apple/macos/disk.rs | 0 src/{ => unix}/apple/macos/ffi.rs | 0 src/{ => unix}/apple/macos/mod.rs | 0 src/{ => unix}/apple/macos/process.rs | 4 +- src/{ => unix}/apple/macos/system.rs | 0 src/{ => unix}/apple/macos/utils.rs | 0 src/{ => unix}/apple/mod.rs | 0 src/{ => unix}/apple/network.rs | 2 +- src/{ => unix}/apple/process.rs | 0 src/{ => unix}/apple/system.rs | 4 +- src/{ => unix}/apple/users.rs | 0 src/{ => unix}/apple/utils.rs | 0 src/{ => unix}/freebsd/component.rs | 2 +- src/{ => unix}/freebsd/cpu.rs | 2 +- src/{ => unix}/freebsd/disk.rs | 2 +- src/{ => unix}/freebsd/mod.rs | 0 src/{ => unix}/freebsd/network.rs | 2 +- src/{ => unix}/freebsd/process.rs | 2 +- src/{ => unix}/freebsd/system.rs | 2 +- src/{ => unix}/freebsd/utils.rs | 0 src/{ => unix}/linux/component.rs | 2 +- src/{ => unix}/linux/cpu.rs | 2 +- src/{ => unix}/linux/disk.rs | 2 +- src/{ => unix}/linux/mod.rs | 0 src/{ => unix}/linux/network.rs | 2 +- src/{ => unix}/linux/process.rs | 2 +- src/{ => unix}/linux/system.rs | 2 +- src/{ => unix}/linux/utils.rs | 0 src/unix/mod.rs | 28 +++++++++++ .../network_helper.rs} | 0 src/{ => unix}/users.rs | 2 +- src/windows/mod.rs | 1 + .../network_helper.rs} | 0 47 files changed, 64 insertions(+), 63 deletions(-) rename src/{ => unix}/apple/app_store/component.rs (87%) rename src/{ => unix}/apple/app_store/mod.rs (100%) rename src/{ => unix}/apple/app_store/process.rs (96%) rename src/{ => unix}/apple/component.rs (100%) rename src/{ => unix}/apple/cpu.rs (99%) rename src/{ => unix}/apple/disk.rs (99%) rename src/{ => unix}/apple/ffi.rs (100%) rename src/{ => unix}/apple/ios.rs (100%) rename src/{ => unix}/apple/macos/component/arm.rs (98%) rename src/{ => unix}/apple/macos/component/mod.rs (100%) rename src/{ => unix}/apple/macos/component/x86.rs (99%) rename src/{ => unix}/apple/macos/cpu.rs (100%) rename src/{ => unix}/apple/macos/disk.rs (100%) rename src/{ => unix}/apple/macos/ffi.rs (100%) rename src/{ => unix}/apple/macos/mod.rs (100%) rename src/{ => unix}/apple/macos/process.rs (99%) rename src/{ => unix}/apple/macos/system.rs (100%) rename src/{ => unix}/apple/macos/utils.rs (100%) rename src/{ => unix}/apple/mod.rs (100%) rename src/{ => unix}/apple/network.rs (99%) rename src/{ => unix}/apple/process.rs (100%) rename src/{ => unix}/apple/system.rs (99%) rename src/{ => unix}/apple/users.rs (100%) rename src/{ => unix}/apple/utils.rs (100%) rename src/{ => unix}/freebsd/component.rs (96%) rename src/{ => unix}/freebsd/cpu.rs (99%) rename src/{ => unix}/freebsd/disk.rs (98%) rename src/{ => unix}/freebsd/mod.rs (100%) rename src/{ => unix}/freebsd/network.rs (99%) rename src/{ => unix}/freebsd/process.rs (99%) rename src/{ => unix}/freebsd/system.rs (99%) rename src/{ => unix}/freebsd/utils.rs (100%) rename src/{ => unix}/linux/component.rs (99%) rename src/{ => unix}/linux/cpu.rs (99%) rename src/{ => unix}/linux/disk.rs (99%) rename src/{ => unix}/linux/mod.rs (100%) rename src/{ => unix}/linux/network.rs (99%) rename src/{ => unix}/linux/process.rs (99%) rename src/{ => unix}/linux/system.rs (99%) rename src/{ => unix}/linux/utils.rs (100%) create mode 100644 src/unix/mod.rs rename src/{network_helper_nix.rs => unix/network_helper.rs} (100%) rename src/{ => unix}/users.rs (98%) rename src/{network_helper_win.rs => windows/network_helper.rs} (100%) diff --git a/src/lib.rs b/src/lib.rs index 0e984883d..f86d9a650 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,52 +22,24 @@ cfg_if::cfg_if! { #[cfg(test)] pub(crate) const MIN_USERS: usize = 0; - } else if #[cfg(any(target_os = "macos", target_os = "ios"))] { - mod apple; - use apple as sys; - pub(crate) mod users; - mod network_helper_nix; - use network_helper_nix as network_helper; + } else if #[cfg(any( + target_os = "macos", target_os = "ios", + target_os = "linux", target_os = "android", + target_os = "freebsd"))] + { + mod unix; + use unix::sys as sys; + use unix::{network_helper, users}; mod network; - pub(crate) use libc::__error as libc_errno; - #[cfg(test)] pub(crate) const MIN_USERS: usize = 1; } else if #[cfg(windows)] { mod windows; use windows as sys; - mod network_helper_win; - use network_helper_win as network_helper; - mod network; - - #[cfg(test)] - pub(crate) const MIN_USERS: usize = 1; - } else if #[cfg(any(target_os = "linux", target_os = "android"))] { - mod linux; - use linux as sys; - pub(crate) mod users; - mod network_helper_nix; - use network_helper_nix as network_helper; + use windows::network_helper; mod network; - #[cfg(target_os = "linux")] - pub(crate) use libc::__errno_location as libc_errno; - #[cfg(target_os = "android")] - pub(crate) use libc::__errno as libc_errno; - - #[cfg(test)] - pub(crate) const MIN_USERS: usize = 1; - } else if #[cfg(target_os = "freebsd")] { - mod freebsd; - use freebsd as sys; - pub(crate) mod users; - mod network_helper_nix; - use network_helper_nix as network_helper; - mod network; - - pub(crate) use libc::__error as libc_errno; - #[cfg(test)] pub(crate) const MIN_USERS: usize = 1; } else { diff --git a/src/macros.rs b/src/macros.rs index 84d651cf5..eba86b2cd 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -60,7 +60,7 @@ macro_rules! declare_signals { #[cfg(all(unix, not(feature = "unknown-ci")))] macro_rules! retry_eintr { (set_to_0 => $($t:tt)+) => {{ - let errno = crate::libc_errno(); + let errno = crate::unix::libc_errno(); if !errno.is_null() { *errno = 0; } diff --git a/src/apple/app_store/component.rs b/src/unix/apple/app_store/component.rs similarity index 87% rename from src/apple/app_store/component.rs rename to src/unix/apple/app_store/component.rs index 914fc9406..339914b7c 100644 --- a/src/apple/app_store/component.rs +++ b/src/unix/apple/app_store/component.rs @@ -2,7 +2,7 @@ use crate::ComponentExt; -#[doc = include_str!("../../../md_doc/component.md")] +#[doc = include_str!("../../../../md_doc/component.md")] pub struct Component {} impl ComponentExt for Component { diff --git a/src/apple/app_store/mod.rs b/src/unix/apple/app_store/mod.rs similarity index 100% rename from src/apple/app_store/mod.rs rename to src/unix/apple/app_store/mod.rs diff --git a/src/apple/app_store/process.rs b/src/unix/apple/app_store/process.rs similarity index 96% rename from src/apple/app_store/process.rs rename to src/unix/apple/app_store/process.rs index d7df72afb..033075bfa 100644 --- a/src/apple/app_store/process.rs +++ b/src/unix/apple/app_store/process.rs @@ -4,7 +4,7 @@ use std::path::Path; use crate::{DiskUsage, Gid, Pid, ProcessExt, ProcessStatus, Signal, Uid}; -#[doc = include_str!("../../../md_doc/process.md")] +#[doc = include_str!("../../../../md_doc/process.md")] pub struct Process; impl ProcessExt for Process { diff --git a/src/apple/component.rs b/src/unix/apple/component.rs similarity index 100% rename from src/apple/component.rs rename to src/unix/apple/component.rs diff --git a/src/apple/cpu.rs b/src/unix/apple/cpu.rs similarity index 99% rename from src/apple/cpu.rs rename to src/unix/apple/cpu.rs index 1fe7bc287..30df4547c 100644 --- a/src/apple/cpu.rs +++ b/src/unix/apple/cpu.rs @@ -103,7 +103,7 @@ impl Drop for CpuData { } } -#[doc = include_str!("../../md_doc/cpu.md")] +#[doc = include_str!("../../../md_doc/cpu.md")] pub struct Cpu { name: String, cpu_usage: f32, diff --git a/src/apple/disk.rs b/src/unix/apple/disk.rs similarity index 99% rename from src/apple/disk.rs rename to src/unix/apple/disk.rs index a18039961..f9a81d750 100644 --- a/src/apple/disk.rs +++ b/src/unix/apple/disk.rs @@ -19,7 +19,7 @@ use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; use std::ptr; -#[doc = include_str!("../../md_doc/disk.md")] +#[doc = include_str!("../../../md_doc/disk.md")] pub struct Disk { pub(crate) type_: DiskKind, pub(crate) name: OsString, diff --git a/src/apple/ffi.rs b/src/unix/apple/ffi.rs similarity index 100% rename from src/apple/ffi.rs rename to src/unix/apple/ffi.rs diff --git a/src/apple/ios.rs b/src/unix/apple/ios.rs similarity index 100% rename from src/apple/ios.rs rename to src/unix/apple/ios.rs diff --git a/src/apple/macos/component/arm.rs b/src/unix/apple/macos/component/arm.rs similarity index 98% rename from src/apple/macos/component/arm.rs rename to src/unix/apple/macos/component/arm.rs index 328ffebfa..4d46748a7 100644 --- a/src/apple/macos/component/arm.rs +++ b/src/unix/apple/macos/component/arm.rs @@ -8,7 +8,7 @@ use core_foundation_sys::string::{ kCFStringEncodingUTF8, CFStringCreateWithBytes, CFStringGetCStringPtr, }; -use crate::apple::inner::ffi::{ +use crate::sys::inner::ffi::{ kHIDPage_AppleVendor, kHIDUsage_AppleVendor_TemperatureSensor, kIOHIDEventTypeTemperature, matching, IOHIDEventFieldBase, IOHIDEventGetFloatValue, IOHIDEventSystemClientCopyServices, IOHIDEventSystemClientCreate, IOHIDEventSystemClientSetMatching, IOHIDServiceClientCopyEvent, @@ -109,7 +109,7 @@ impl Components { unsafe impl Send for Components {} unsafe impl Sync for Components {} -#[doc = include_str!("../../../../md_doc/component.md")] +#[doc = include_str!("../../../../../md_doc/component.md")] pub struct Component { service: CFReleaser<__IOHIDServiceClient>, temperature: f32, diff --git a/src/apple/macos/component/mod.rs b/src/unix/apple/macos/component/mod.rs similarity index 100% rename from src/apple/macos/component/mod.rs rename to src/unix/apple/macos/component/mod.rs diff --git a/src/apple/macos/component/x86.rs b/src/unix/apple/macos/component/x86.rs similarity index 99% rename from src/apple/macos/component/x86.rs rename to src/unix/apple/macos/component/x86.rs index e89d7c5d2..aebb84f41 100644 --- a/src/apple/macos/component/x86.rs +++ b/src/unix/apple/macos/component/x86.rs @@ -77,7 +77,7 @@ impl Components { } } -#[doc = include_str!("../../../../md_doc/component.md")] +#[doc = include_str!("../../../../../md_doc/component.md")] pub struct Component { temperature: f32, max: f32, diff --git a/src/apple/macos/cpu.rs b/src/unix/apple/macos/cpu.rs similarity index 100% rename from src/apple/macos/cpu.rs rename to src/unix/apple/macos/cpu.rs diff --git a/src/apple/macos/disk.rs b/src/unix/apple/macos/disk.rs similarity index 100% rename from src/apple/macos/disk.rs rename to src/unix/apple/macos/disk.rs diff --git a/src/apple/macos/ffi.rs b/src/unix/apple/macos/ffi.rs similarity index 100% rename from src/apple/macos/ffi.rs rename to src/unix/apple/macos/ffi.rs diff --git a/src/apple/macos/mod.rs b/src/unix/apple/macos/mod.rs similarity index 100% rename from src/apple/macos/mod.rs rename to src/unix/apple/macos/mod.rs diff --git a/src/apple/macos/process.rs b/src/unix/apple/macos/process.rs similarity index 99% rename from src/apple/macos/process.rs rename to src/unix/apple/macos/process.rs index 102a8a6bc..e6fa4f58e 100644 --- a/src/apple/macos/process.rs +++ b/src/unix/apple/macos/process.rs @@ -14,7 +14,7 @@ use crate::{DiskUsage, Gid, Pid, ProcessExt, ProcessRefreshKind, ProcessStatus, use crate::sys::process::ThreadStatus; use crate::sys::system::Wrap; -#[doc = include_str!("../../../md_doc/process.md")] +#[doc = include_str!("../../../../md_doc/process.md")] pub struct Process { pub(crate) name: String, pub(crate) cmd: Vec, @@ -316,7 +316,7 @@ fn check_if_pid_is_alive(pid: Pid, check_if_alive: bool) -> bool { return true; } // `kill` failed but it might not be because the process is dead. - let errno = crate::libc_errno(); + let errno = crate::unix::libc_errno(); // If errno is equal to ESCHR, it means the process is dead. !errno.is_null() && *errno != libc::ESRCH } diff --git a/src/apple/macos/system.rs b/src/unix/apple/macos/system.rs similarity index 100% rename from src/apple/macos/system.rs rename to src/unix/apple/macos/system.rs diff --git a/src/apple/macos/utils.rs b/src/unix/apple/macos/utils.rs similarity index 100% rename from src/apple/macos/utils.rs rename to src/unix/apple/macos/utils.rs diff --git a/src/apple/mod.rs b/src/unix/apple/mod.rs similarity index 100% rename from src/apple/mod.rs rename to src/unix/apple/mod.rs diff --git a/src/apple/network.rs b/src/unix/apple/network.rs similarity index 99% rename from src/apple/network.rs rename to src/unix/apple/network.rs index a4de0851d..405ade727 100644 --- a/src/apple/network.rs +++ b/src/unix/apple/network.rs @@ -164,7 +164,7 @@ impl NetworksExt for Networks { } } -#[doc = include_str!("../../md_doc/network_data.md")] +#[doc = include_str!("../../../md_doc/network_data.md")] #[derive(PartialEq, Eq)] pub struct NetworkData { current_in: u64, diff --git a/src/apple/process.rs b/src/unix/apple/process.rs similarity index 100% rename from src/apple/process.rs rename to src/unix/apple/process.rs diff --git a/src/apple/system.rs b/src/unix/apple/system.rs similarity index 99% rename from src/apple/system.rs rename to src/unix/apple/system.rs index b4eeeda44..54df79c66 100644 --- a/src/apple/system.rs +++ b/src/unix/apple/system.rs @@ -74,7 +74,7 @@ declare_signals! { _ => None, } -#[doc = include_str!("../../md_doc/system.md")] +#[doc = include_str!("../../../md_doc/system.md")] pub struct System { process_list: HashMap, mem_total: u64, @@ -327,7 +327,7 @@ impl SystemExt for System { } fn refresh_users_list(&mut self) { - self.users = crate::apple::users::get_users_list(); + self.users = crate::sys::users::get_users_list(); } // COMMON PART diff --git a/src/apple/users.rs b/src/unix/apple/users.rs similarity index 100% rename from src/apple/users.rs rename to src/unix/apple/users.rs diff --git a/src/apple/utils.rs b/src/unix/apple/utils.rs similarity index 100% rename from src/apple/utils.rs rename to src/unix/apple/utils.rs diff --git a/src/freebsd/component.rs b/src/unix/freebsd/component.rs similarity index 96% rename from src/freebsd/component.rs rename to src/unix/freebsd/component.rs index c4e84fe63..ba8220f91 100644 --- a/src/freebsd/component.rs +++ b/src/unix/freebsd/component.rs @@ -3,7 +3,7 @@ use super::utils::get_sys_value_by_name; use crate::ComponentExt; -#[doc = include_str!("../../md_doc/component.md")] +#[doc = include_str!("../../../md_doc/component.md")] pub struct Component { id: Vec, label: String, diff --git a/src/freebsd/cpu.rs b/src/unix/freebsd/cpu.rs similarity index 99% rename from src/freebsd/cpu.rs rename to src/unix/freebsd/cpu.rs index 6946b6a7e..4ff67f83f 100644 --- a/src/freebsd/cpu.rs +++ b/src/unix/freebsd/cpu.rs @@ -132,7 +132,7 @@ impl CpusWrapper { } } -#[doc = include_str!("../../md_doc/cpu.md")] +#[doc = include_str!("../../../md_doc/cpu.md")] pub struct Cpu { pub(crate) cpu_usage: f32, name: String, diff --git a/src/freebsd/disk.rs b/src/unix/freebsd/disk.rs similarity index 98% rename from src/freebsd/disk.rs rename to src/unix/freebsd/disk.rs index efcdd6bda..1fcff2e8e 100644 --- a/src/freebsd/disk.rs +++ b/src/unix/freebsd/disk.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use super::utils::c_buf_to_str; -#[doc = include_str!("../../md_doc/disk.md")] +#[doc = include_str!("../../../md_doc/disk.md")] pub struct Disk { name: OsString, c_mount_point: Vec, diff --git a/src/freebsd/mod.rs b/src/unix/freebsd/mod.rs similarity index 100% rename from src/freebsd/mod.rs rename to src/unix/freebsd/mod.rs diff --git a/src/freebsd/network.rs b/src/unix/freebsd/network.rs similarity index 99% rename from src/freebsd/network.rs rename to src/unix/freebsd/network.rs index 60c2049d4..43d621d63 100644 --- a/src/freebsd/network.rs +++ b/src/unix/freebsd/network.rs @@ -113,7 +113,7 @@ impl Networks { } } -#[doc = include_str!("../../md_doc/network_data.md")] +#[doc = include_str!("../../../md_doc/network_data.md")] pub struct NetworkData { /// Total number of bytes received over interface. ifi_ibytes: u64, diff --git a/src/freebsd/process.rs b/src/unix/freebsd/process.rs similarity index 99% rename from src/freebsd/process.rs rename to src/unix/freebsd/process.rs index 52064e179..40c5fce58 100644 --- a/src/freebsd/process.rs +++ b/src/unix/freebsd/process.rs @@ -40,7 +40,7 @@ impl fmt::Display for ProcessStatus { } } -#[doc = include_str!("../../md_doc/process.md")] +#[doc = include_str!("../../../md_doc/process.md")] pub struct Process { pub(crate) name: String, pub(crate) cmd: Vec, diff --git a/src/freebsd/system.rs b/src/unix/freebsd/system.rs similarity index 99% rename from src/freebsd/system.rs rename to src/unix/freebsd/system.rs index 51b4dc0fc..608ba157c 100644 --- a/src/freebsd/system.rs +++ b/src/unix/freebsd/system.rs @@ -57,7 +57,7 @@ declare_signals! { _ => None, } -#[doc = include_str!("../../md_doc/system.md")] +#[doc = include_str!("../../../md_doc/system.md")] pub struct System { process_list: HashMap, mem_total: u64, diff --git a/src/freebsd/utils.rs b/src/unix/freebsd/utils.rs similarity index 100% rename from src/freebsd/utils.rs rename to src/unix/freebsd/utils.rs diff --git a/src/linux/component.rs b/src/unix/linux/component.rs similarity index 99% rename from src/linux/component.rs rename to src/unix/linux/component.rs index 8aa72e661..e04201231 100644 --- a/src/linux/component.rs +++ b/src/unix/linux/component.rs @@ -11,7 +11,7 @@ use std::fs::{read_dir, File}; use std::io::Read; use std::path::{Path, PathBuf}; -#[doc = include_str!("../../md_doc/component.md")] +#[doc = include_str!("../../../md_doc/component.md")] #[derive(Default)] pub struct Component { /// Optional associated device of a `Component`. diff --git a/src/linux/cpu.rs b/src/unix/linux/cpu.rs similarity index 99% rename from src/linux/cpu.rs rename to src/unix/linux/cpu.rs index 80765c89d..e73ff2928 100644 --- a/src/linux/cpu.rs +++ b/src/unix/linux/cpu.rs @@ -305,7 +305,7 @@ impl CpuValues { } } -#[doc = include_str!("../../md_doc/cpu.md")] +#[doc = include_str!("../../../md_doc/cpu.md")] pub struct Cpu { old_values: CpuValues, new_values: CpuValues, diff --git a/src/linux/disk.rs b/src/unix/linux/disk.rs similarity index 99% rename from src/linux/disk.rs rename to src/unix/linux/disk.rs index cefbf3692..7f840b03a 100644 --- a/src/linux/disk.rs +++ b/src/unix/linux/disk.rs @@ -16,7 +16,7 @@ macro_rules! cast { }; } -#[doc = include_str!("../../md_doc/disk.md")] +#[doc = include_str!("../../../md_doc/disk.md")] #[derive(PartialEq, Eq)] pub struct Disk { type_: DiskKind, diff --git a/src/linux/mod.rs b/src/unix/linux/mod.rs similarity index 100% rename from src/linux/mod.rs rename to src/unix/linux/mod.rs diff --git a/src/linux/network.rs b/src/unix/linux/network.rs similarity index 99% rename from src/linux/network.rs rename to src/unix/linux/network.rs index 3c53f64ca..1d2b73b27 100644 --- a/src/linux/network.rs +++ b/src/unix/linux/network.rs @@ -126,7 +126,7 @@ impl NetworksExt for Networks { } } -#[doc = include_str!("../../md_doc/network_data.md")] +#[doc = include_str!("../../../md_doc/network_data.md")] pub struct NetworkData { /// Total number of bytes received over interface. rx_bytes: u64, diff --git a/src/linux/process.rs b/src/unix/linux/process.rs similarity index 99% rename from src/linux/process.rs rename to src/unix/linux/process.rs index 7c2d599e0..9fc8e5547 100644 --- a/src/linux/process.rs +++ b/src/unix/linux/process.rs @@ -56,7 +56,7 @@ impl fmt::Display for ProcessStatus { } } -#[doc = include_str!("../../md_doc/process.md")] +#[doc = include_str!("../../../md_doc/process.md")] pub struct Process { pub(crate) name: String, pub(crate) cmd: Vec, diff --git a/src/linux/system.rs b/src/unix/linux/system.rs similarity index 99% rename from src/linux/system.rs rename to src/unix/linux/system.rs index c9c6eb4bb..2b09a27a6 100644 --- a/src/linux/system.rs +++ b/src/unix/linux/system.rs @@ -147,7 +147,7 @@ declare_signals! { Signal::Sys => libc::SIGSYS, } -#[doc = include_str!("../../md_doc/system.md")] +#[doc = include_str!("../../../md_doc/system.md")] pub struct System { process_list: Process, mem_total: u64, diff --git a/src/linux/utils.rs b/src/unix/linux/utils.rs similarity index 100% rename from src/linux/utils.rs rename to src/unix/linux/utils.rs diff --git a/src/unix/mod.rs b/src/unix/mod.rs new file mode 100644 index 000000000..5c50ede2d --- /dev/null +++ b/src/unix/mod.rs @@ -0,0 +1,28 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +cfg_if::cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios"))] { + pub(crate) mod apple; + pub(crate) use apple as sys; + + pub(crate) use libc::__error as libc_errno; + } else if #[cfg(any(target_os = "linux", target_os = "android"))] { + pub(crate) mod linux; + pub(crate) use linux as sys; + + #[cfg(target_os = "linux")] + pub(crate) use libc::__errno_location as libc_errno; + #[cfg(target_os = "android")] + pub(crate) use libc::__errno as libc_errno; + } else if #[cfg(target_os = "freebsd")] { + pub(crate) mod freebsd; + pub(crate) use freebsd as sys; + + pub(crate) use libc::__error as libc_errno; + } else { + compile_error!("Invalid cfg!"); + } +} + +pub(crate) mod network_helper; +pub(crate) mod users; diff --git a/src/network_helper_nix.rs b/src/unix/network_helper.rs similarity index 100% rename from src/network_helper_nix.rs rename to src/unix/network_helper.rs diff --git a/src/users.rs b/src/unix/users.rs similarity index 98% rename from src/users.rs rename to src/unix/users.rs index 5da1066e5..7e5fc2b42 100644 --- a/src/users.rs +++ b/src/unix/users.rs @@ -9,7 +9,7 @@ use libc::{getgrgid_r, getgrouplist}; use std::fs::File; use std::io::Read; -#[doc = include_str!("../md_doc/user.md")] +#[doc = include_str!("../../md_doc/user.md")] pub struct User { pub(crate) uid: Uid, pub(crate) gid: Gid, diff --git a/src/windows/mod.rs b/src/windows/mod.rs index a525f84a2..f7781038d 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -4,6 +4,7 @@ mod component; mod cpu; mod disk; mod network; +pub(crate) mod network_helper; mod process; mod sid; mod system; diff --git a/src/network_helper_win.rs b/src/windows/network_helper.rs similarity index 100% rename from src/network_helper_win.rs rename to src/windows/network_helper.rs