Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataLoaders 0: utility for hierarchical EntityPath from file path #4516

Merged
merged 2 commits into from
Dec 15, 2023
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ arrow2 = { workspace = true, features = [
] }
backtrace.workspace = true
bytemuck.workspace = true
clean-path.workspace = true
document-features.workspace = true
fixed = { workspace = true, default-features = false, features = ["serde"] }
# `fixed` depends on `half`, so even though `half` is not directly used in this crate,
Expand Down
15 changes: 14 additions & 1 deletion crates/re_log_types/src/path/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,24 @@ impl EntityPath {
///
/// The file path separators will NOT become splits in the new path.
/// The returned path will only have one part.
#[cfg(not(target_arch = "wasm32"))]
pub fn from_file_path_as_single_string(file_path: &std::path::Path) -> Self {
Self::from_single_string(file_path.to_string_lossy().to_string())
}

/// Treat the file path as an entity path hierarchy.
///
/// The file path separators will become splits in the new path.
pub fn from_file_path(file_path: &std::path::Path) -> Self {
use clean_path::Clean as _;
Self::new(
file_path
.clean()
.iter()
.map(|p| EntityPathPart::from(p.to_string_lossy().to_string()))
.collect(),
)
}

/// Treat the string as one opaque string, NOT splitting on any slashes.
///
/// The given string is expected to be unescaped, i.e. any `\` is treated as a normal character.
Expand Down
Loading