mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 23:54:48 +01:00
Fix Windows path issues
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use crate::system_helpers::*;
|
||||
|
||||
#[tauri::command]
|
||||
@@ -5,7 +6,8 @@ pub async fn get_lang(window: tauri::Window, lang: String) -> String {
|
||||
let lang = lang.to_lowercase();
|
||||
|
||||
// Send contents of language file back
|
||||
let contents = match std::fs::read_to_string(format!("{}/lang/{}.json", install_location(), lang)) {
|
||||
let lang_path: PathBuf = [&install_location(), "lang", &format!("{}.json", lang)].iter().collect();
|
||||
let contents = match std::fs::read_to_string(&lang_path) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
emit_lang_err(window, format!("Failed to read language file: {}", e));
|
||||
@@ -21,14 +23,14 @@ pub async fn get_languages() -> std::collections::HashMap<String, String> {
|
||||
// for each lang file, set the key as the filename and the value as the lang_name contained in the file
|
||||
let mut languages = std::collections::HashMap::new();
|
||||
|
||||
let mut lang_files = std::fs::read_dir(format!("{}/lang", install_location())).unwrap();
|
||||
let mut lang_files = std::fs::read_dir(Path::new(&install_location()).join("lang")).unwrap();
|
||||
|
||||
while let Some(entry) = lang_files.next() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
let filename = path.file_name().unwrap().to_str().unwrap();
|
||||
|
||||
let content = match std::fs::read_to_string(path.to_str().unwrap()) {
|
||||
let content = match std::fs::read_to_string(&path) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
println!("Failed to read language file: {}", e);
|
||||
|
||||
Reference in New Issue
Block a user