Skip to content

Commit c67a8e8

Browse files
committed
fix: add missing directory creation to GPX and event exports
- Add std::fs::create_dir_all() to export_to_gpx before file creation - Add std::fs::create_dir_all() to export_to_event before file creation - Both functions now match export_to_csv behavior for directory handling - Fixes issue where exports to non-existent directories would fail with ENOENT Resolves: #26
1 parent 65b64cc commit c67a8e8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/export.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ pub fn export_to_gpx(
377377
.map(Path::new)
378378
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));
379379

380+
// Create output directory if it doesn't exist (match export_to_csv behavior)
381+
if !output_dir.exists() {
382+
std::fs::create_dir_all(output_dir)?;
383+
}
384+
380385
// Use consistent naming: only add suffix for multiple logs
381386
let log_suffix = if total_logs > 1 {
382387
format!(".{:02}", log_index + 1)
@@ -442,6 +447,11 @@ pub fn export_to_event(
442447
.map(Path::new)
443448
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));
444449

450+
// Create output directory if it doesn't exist (match export_to_csv behavior)
451+
if !output_dir.exists() {
452+
std::fs::create_dir_all(output_dir)?;
453+
}
454+
445455
// Use consistent naming: only add suffix for multiple logs
446456
let log_suffix = if total_logs > 1 {
447457
format!(".{:02}", log_index + 1)

0 commit comments

Comments
 (0)