From 696fba01a9983466e3050a34b926377a864eb57a Mon Sep 17 00:00:00 2001 From: Carigs Date: Tue, 6 Aug 2024 03:23:17 -0400 Subject: [PATCH 1/2] Removed folder prefix when calling loadIniFile --- src/components/IniFileViewer.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/IniFileViewer.vue b/src/components/IniFileViewer.vue index 9ee5345..fa2d35b 100644 --- a/src/components/IniFileViewer.vue +++ b/src/components/IniFileViewer.vue @@ -76,19 +76,18 @@ if (confirmNavigation) { cancelEditing(); - await loadIniFile(`.editordata/${newFileName}`); + await loadIniFile(`${newFileName}`); } else { // If the user cancels navigation, we need to revert the route change - // This assumes you're using vue-router. Adjust if you're using a different routing solution. history.pushState(history.state, '', `#/${oldFileName}`); - await loadIniFile(`.editordata/${oldFileName}`); + await loadIniFile(`${oldFileName}`); } } catch (error) { console.error("Error during navigation confirmation:", error); // Handle the error appropriately } } else { - await loadIniFile(`.editordata/${newFileName}`); + await loadIniFile(`${newFileName}`); } }, { immediate: true }); From c4490960f9a4d9326dd547d01432b4921dc4c192 Mon Sep 17 00:00:00 2001 From: Carigs Date: Tue, 6 Aug 2024 03:25:27 -0400 Subject: [PATCH 2/2] Fixed file path used when reading config files --- src-tauri/src/inihandler.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/inihandler.rs b/src-tauri/src/inihandler.rs index eb51442..9841fba 100644 --- a/src-tauri/src/inihandler.rs +++ b/src-tauri/src/inihandler.rs @@ -71,8 +71,14 @@ pub fn read_ini_file( .resolve_resource(path) .expect("Failed to resolve resource"); + // Get the current executable directory path + let exe_dir = env::current_dir().map_err(|e| e.to_string())?; + + // Append filename w/ extension to the executable directory path + let exe_file_path = exe_dir.join(PathBuf::from(path).file_name().unwrap()); + // Read the entire file content - let mut file = std::fs::File::open(resource_path).map_err(|e| e.to_string())?; + let mut file = std::fs::File::open(exe_file_path).map_err(|e| e.to_string())?; let mut content = String::new(); file.read_to_string(&mut content) .map_err(|e| e.to_string())?; @@ -205,7 +211,7 @@ fn write_to_file( writeln!(temp_file, "{}", line).map_err(|e| e.to_string())?; } else if trimmed.starts_with('#') && trimmed.contains('=') && in_section { // Remove comment so the key-value pair can be read and displayed in the UI - writeln!(temp_file, "{}", line.replace('#', "")).map_err(|e| e.to_string())?; + writeln!(temp_file, "{}", line.replace('#', "").trim()).map_err(|e| e.to_string())?; } else if trimmed.starts_with('#') { // Preserve comments outside of section grouping writeln!(temp_file, "{}", line).map_err(|e| e.to_string())?;