Skip to content
Merged
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
52 changes: 21 additions & 31 deletions src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,23 +369,18 @@ pub fn export_to_gpx(
return Ok(());
}

let base_name = extract_base_name(input_path);

let output_dir = export_options
.output_dir
.as_deref()
.map(Path::new)
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));

// Use consistent naming: only add suffix for multiple logs
let log_suffix = if total_logs > 1 {
format!(".{:02}", log_index + 1)
} else {
"".to_string()
};
let gpx_filename = output_dir.join(format!("{}{}.gps.gpx", base_name, log_suffix));
// Use compute_export_paths to ensure consistent naming with CSV exports
let (_, _, gpx_path, _) =
compute_export_paths(input_path, export_options, log_index + 1, total_logs);

// Create output directory if it doesn't exist (match export_to_csv behavior)
if let Some(parent) = gpx_path.parent() {
if !parent.exists() {
std::fs::create_dir_all(parent)?;
}
}

let mut gpx_file = File::create(&gpx_filename)?;
let mut gpx_file = File::create(&gpx_path)?;
writeln!(gpx_file, r#"<?xml version="1.0" encoding="UTF-8"?>"#)?;
writeln!(
gpx_file,
Expand Down Expand Up @@ -434,23 +429,18 @@ pub fn export_to_event(
return Ok(());
}

let base_name = extract_base_name(input_path);

let output_dir = export_options
.output_dir
.as_deref()
.map(Path::new)
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));
// Use compute_export_paths to ensure consistent naming with CSV exports
let (_, _, _, event_path) =
compute_export_paths(input_path, export_options, log_index + 1, total_logs);

// Use consistent naming: only add suffix for multiple logs
let log_suffix = if total_logs > 1 {
format!(".{:02}", log_index + 1)
} else {
"".to_string()
};
let event_filename = output_dir.join(format!("{}{}.event", base_name, log_suffix));
// Create output directory if it doesn't exist (match export_to_csv behavior)
if let Some(parent) = event_path.parent() {
if !parent.exists() {
std::fs::create_dir_all(parent)?;
}
}

let mut event_file = File::create(&event_filename)?;
let mut event_file = File::create(&event_path)?;

// Export as JSONL format (individual JSON objects per line) to match blackbox_decode
for event in event_frames.iter() {
Expand Down