Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

182 changes: 110 additions & 72 deletions crates/dua-lib/CHANGELOG.md

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion crates/dua-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dua-core"
version = "6.0.0"
version = "6.1.0"
authors.workspace = true
edition.workspace = true
repository.workspace = true
Expand All @@ -14,13 +14,18 @@ api-check = ["cargo", "api-check", "release"]
[package.metadata.api-check]
profiles = [{ default-features = true, features = [] }]

[features]
# Experimental APIs that may change without notice.
unstable = ["dep:bitflags"]

[dependencies]
crossbeam.workspace = true

[target.'cfg(target_os = "macos")'.dependencies]
libc = "0.2.186"

[target.'cfg(windows)'.dependencies]
bitflags = { version = "2", optional = true }
windows-sys = { version = "0.61.1", features = [
"Win32_Foundation",
"Win32_Security",
Expand All @@ -30,5 +35,8 @@ windows-sys = { version = "0.61.1", features = [
[dev-dependencies]
tempfile.workspace = true

[target.'cfg(windows)'.dev-dependencies]
bitflags = "2"

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/dua-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ use macos::ReadDir as NativeReadDir;
#[cfg(target_os = "macos")]
use std::fs::read_dir as read_dir_types;

#[cfg(all(windows, any(test, feature = "unstable")))]
pub use windows::FileAttributes;

#[cfg(windows)]
pub use windows::{Entry, FileType, Metadata};

Expand Down
20 changes: 17 additions & 3 deletions crates/dua-lib/src/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{
ffi::{CString, OsString},
fs, io,
fmt, fs, io,
num::NonZeroU64,
os::unix::{ffi::OsStrExt, fs::MetadataExt},
path::{Path, PathBuf},
Expand Down Expand Up @@ -32,7 +32,7 @@ const DIRECTORY_BUFFER_BYTES: usize = if cfg!(dua_macos_bulk) { 64 * 1024 } else

/// A macOS filesystem entry produced from native directory metadata.
pub struct Entry {
/// Distance from the walk root: `0` for the root, `1` and highger for its children.
/// Distance from the walk root: `0` for the root, `1` and higher for its children.
pub depth: usize,
/// File name relative to `parent_path`.
pub file_name: OsString,
Expand Down Expand Up @@ -98,7 +98,7 @@ impl Entry {
}

/// macOS filesystem entry type obtained without following symbolic links.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub struct FileType {
kind: u32,
}
Expand Down Expand Up @@ -136,6 +136,20 @@ impl FileType {
}
}

impl fmt::Debug for FileType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let kind = match self.kind {
VREG => "File",
VDIR => "Directory",
VLNK => "Symlink",
_ => "Other",
};
f.debug_tuple("FileType")
.field(&format_args!("{kind}"))
.finish()
}
}

/// macOS metadata obtained during native directory enumeration.
#[derive(Clone, Copy)]
pub struct Metadata {
Expand Down
Loading
Loading