aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-22 17:08:25 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-22 17:08:25 +0200
commitbc0c8ead3f120402ada48780d1be42259384e0f4 (patch)
tree9a735609b5be265f0df9221056e96137a6f4749f
parent0dd0cf6f370abb602399b94711e6eff1002ddfcf (diff)
downloadFlightCore-bc0c8ead3f120402ada48780d1be42259384e0f4.tar.gz
FlightCore-bc0c8ead3f120402ada48780d1be42259384e0f4.zip
Add initial functionality to get NS log files
-rw-r--r--src-tauri/src/lib.rs28
-rw-r--r--src-tauri/src/main.rs12
-rw-r--r--src-ui/src/main.ts16
3 files changed, 54 insertions, 2 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 2ea9571b..f19a178c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -393,3 +393,31 @@ pub fn check_is_flightcore_outdated() -> Result<bool, String> {
// TODO: This shouldn't be a string compare but promper semver compare
Ok(version != newest_release_version)
}
+
+pub fn get_log_list(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
+ let ns_log_folder = format!("{}/R2Northstar/logs", game_install.game_path);
+
+ // Check if logs folder exists
+ if !std::path::Path::new(&ns_log_folder).exists() {
+ return Err("No logs folder found".to_string());
+ }
+
+ // List files in logs folder
+ let paths = std::fs::read_dir(ns_log_folder).unwrap();
+
+ // Stores paths of log files
+ let mut log_files: Vec<std::path::PathBuf> = Vec::new();
+
+ for path in paths {
+ let path = path.unwrap().path();
+ if path.display().to_string().contains("nslog") {
+ log_files.push(path);
+ }
+ }
+
+ if log_files.len() > 0 {
+ Ok(log_files)
+ } else {
+ Err("No logs found".to_string())
+ }
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 492c5935..945d6528 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -12,7 +12,8 @@ use std::{
use app::{
check_is_flightcore_outdated, check_is_valid_game_path, check_northstar_running,
check_origin_running, convert_release_candidate_number, find_game_install_location,
- get_host_os, get_northstar_version_number, install_northstar, launch_northstar, GameInstall,
+ get_host_os, get_log_list, get_northstar_version_number, install_northstar, launch_northstar,
+ GameInstall,
};
use tauri::{Manager, State};
use tokio::time::sleep;
@@ -78,7 +79,8 @@ fn main() {
install_northstar_caller,
update_northstar_caller,
launch_northstar_caller,
- check_is_flightcore_outdated_caller
+ check_is_flightcore_outdated_caller,
+ get_log_list_caller
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
@@ -247,3 +249,9 @@ async fn update_northstar_caller(
fn launch_northstar_caller(game_install: GameInstall) -> Result<String, String> {
launch_northstar(game_install)
}
+
+#[tauri::command]
+/// Get list of Northstar logs
+fn get_log_list_caller(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
+ get_log_list(game_install)
+}
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index dd28fedc..0505f0c2 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -301,4 +301,20 @@ document.addEventListener("DOMContentLoaded", async function () {
alert(error);
omniButtonEl.textContent = button_manual_find_string;
});
+
+
+ // --- This should be moved and is only placed here temporarily -----
+ let game_install = {
+ game_path: globalState.gamepath,
+ install_type: installTypeHolderEl.textContent
+ } as GameInstall;
+ await invoke("get_log_list_caller", { gameInstall: game_install })
+ .then((message) => {
+ console.log(message);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+ // ------------------------------------------------------------------
+
})