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())?; 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 });