Skip to content
Open
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
33 changes: 15 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@
//! ```rust
//! use framels::{basic_listing, extended_listing, parse_dir, paths::{Paths,Join}, recursive_dir};
//!
//! fn main() {
//! // Perform directory listing
//! let in_paths: Paths = parse_dir("./samples/small");
//!
//! // Perform directory listing
//! let in_paths: Paths = parse_dir("./samples/small");
//!
//! // Generate results based on arguments
//! // Generate results based on arguments
//! let results: String = basic_listing(in_paths, false).get_paths().join("\n");
//!
//! println!("{}", results)
//! }
//! ```
mod exr_metadata;
pub mod paths;
Expand Down Expand Up @@ -135,7 +134,7 @@ pub fn recursive_dir(input_path: &str) -> Paths {
WalkDir::new(input_path)
.sort(true)
.into_iter()
.filter_map(|entry| entry.ok().and_then(|e| Some(e.path())))
.filter_map(|entry| entry.ok().map(|e| e.path()))

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map operation returns &Path but the collection expects PathBuf. This will cause a type mismatch. Change to .filter_map(|entry| entry.ok().map(|e| e.path().to_path_buf())) to convert &Path to PathBuf.

Suggested change
.filter_map(|entry| entry.ok().map(|e| e.path()))
.filter_map(|entry| entry.ok().map(|e| e.path().to_path_buf()))

Copilot uses AI. Check for mistakes.
.collect::<Vec<PathBuf>>(),
)
}
Expand All @@ -149,7 +148,7 @@ fn extract_regex(x: &str) -> (String, String) {
static ref RE_FLS: Regex = Regex::new(r"(?x)(.*)(\.|_)(?P<frames>\d{2,9})\.(\w{2,5})$")
.expect("Can't compile regex");
}
let result_caps: Option<Captures> = RE_FLS.captures(&x);
let result_caps: Option<Captures> = RE_FLS.captures(x);

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The explicit type annotation Option<Captures> is redundant since the compiler can infer it from the captures() method return type. Consider removing it for cleaner code.

Suggested change
let result_caps: Option<Captures> = RE_FLS.captures(x);
let result_caps = RE_FLS.captures(x);

Copilot uses AI. Check for mistakes.
match result_caps {
None => (x.to_string(), "None".to_string()),
caps_wrap => {
Expand Down Expand Up @@ -187,14 +186,14 @@ fn extract_regex_simd(x: &str) -> (String, String) {
start -= 1;
}
let digit_count = end - start;
if digit_count < 2 || digit_count > 9 {
if !(2..=9).contains(&digit_count) {
return extract_regex(x);
}
if start < 2 || !(bytes[start - 1] == b'.' || bytes[start - 1] == b'_') {
return extract_regex(x);
}
let ext_len = len - dot - 1;
if ext_len < 2 || ext_len > 5 {
if !(2..=5).contains(&ext_len) {
return extract_regex(x);
}
let mut masked = x.to_string();
Expand Down Expand Up @@ -307,15 +306,13 @@ fn create_frame_string(value: Vec<String>) -> String {
/// ```rust
/// use framels::{basic_listing, parse_dir, paths::{Paths,Join}};
///
/// fn main() {
/// // Perform directory listing
/// let in_paths: Paths = parse_dir("./samples/small");
/// // Perform directory listing
/// let in_paths: Paths = parse_dir("./samples/small");
///
/// // Generate results based on arguments
/// let results: String = basic_listing(in_paths, false).get_paths().join("\n");
/// // Generate results based on arguments
/// let results: String = basic_listing(in_paths, false).get_paths().join("\n");
///
/// println!("{}", results)
/// }
/// println!("{}", results)
/// ```
pub fn basic_listing(frames: Paths, multithreaded: bool) -> PathsPacked {
let frames_dict: HashMap<String, Vec<String>> = parse_result(frames, multithreaded);
Expand All @@ -333,7 +330,7 @@ pub fn basic_listing(frames: Paths, multithreaded: bool) -> PathsPacked {

let paths_packed_data = frames_list
.iter()
.map(|s| PathBuf::from(s)) // Convert to PathBuf
.map(PathBuf::from) // Convert to PathBuf
.collect::<Vec<PathBuf>>();

PathsPacked::from(paths_packed_data)
Expand Down Expand Up @@ -384,7 +381,7 @@ pub fn extended_listing(root_path: String, frames: Paths, multithreaded: bool) -
let to = value.first().unwrap();
let from = String::from_utf8(vec![b'*'; to.len()]).unwrap();
let new_path = &key.replace(&from, to);
out_frames.push_metadata(get_exr_metada(&root_path, &new_path));
out_frames.push_metadata(get_exr_metada(&root_path, new_path));
out_frames.push_paths(format!("{}@{}", key, create_frame_string(value)).into());
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ impl Paths {
pub fn len(&self) -> usize {
self.data.len()
}
/// # is_empty
///
/// ## Description
///
/// Return true if the paths collection is empty, false otherwise
///
/// ## Example
///
/// ```rust
/// use framels::paths::Paths;
/// use std::path::PathBuf;
///
/// let empty_paths = Paths::from(vec![]);
/// assert_eq!(empty_paths.is_empty(), true);
///
/// let paths = Paths::from(vec![PathBuf::from("foo")]);
/// assert_eq!(paths.is_empty(), false);
/// ```
pub fn is_empty(&self) -> bool {
self.data.is_empty()
}
/// # iter
///
/// ## Description
Expand Down
Loading