Skip to main content

libarchive_oxide_core/
meta.rs

1// SPDX-FileCopyrightText: 2026 libarchive_oxide contributors
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! Small metadata value types shared by the richer v0.2 metadata model.
6
7/// Entry kind.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum EntryKind {
11    /// Regular file.
12    File,
13    /// Directory.
14    Dir,
15    /// Symbolic link.
16    Symlink,
17    /// Hard link.
18    Hardlink,
19    /// Character device.
20    Char,
21    /// Block device.
22    Block,
23    /// Named pipe (FIFO).
24    Fifo,
25    /// UNIX domain socket.
26    Socket,
27}
28
29/// Sensible portable permissions for formats whose mode field is mandatory.
30pub(crate) const fn default_mode(kind: EntryKind) -> u32 {
31    match kind {
32        EntryKind::Dir => 0o755,
33        EntryKind::Symlink => 0o777,
34        EntryKind::File | EntryKind::Hardlink => 0o644,
35        EntryKind::Char | EntryKind::Block | EntryKind::Fifo | EntryKind::Socket => 0o600,
36    }
37}
38
39/// A timestamp in seconds and nanoseconds, independent of `std`.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub struct Timestamp {
42    /// Seconds since the UNIX epoch.
43    pub secs: i64,
44    /// Nanoseconds within the second (`0..1_000_000_000`).
45    pub nanos: u32,
46}