From 45aef04664df07913c9ab75a0b329a2e370a5ecc Mon Sep 17 00:00:00 2001 From: dam Date: Tue, 4 Jun 2024 10:57:28 +0100 Subject: Fix data path finding when no system folders are found. --- .gitignore | 1 + ttt.jai | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bcfa4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.build/ diff --git a/ttt.jai b/ttt.jai index d169ab1..ca78b4b 100644 --- a/ttt.jai +++ b/ttt.jai @@ -14,7 +14,7 @@ DEBUG :: false; #import "UTF8"; TUI :: #import "TUI"(COLOR_MODE_BITS=4); -VERSION :: "2.1"; // Use only 3 chars (to fit layouts). +VERSION :: "2.2"; // Use only 3 chars (to fit layouts). YEAR :: "2024"; NUM_WEEK_DAYS :: 7; @@ -1182,9 +1182,11 @@ main :: () { #if OS == { case .LINUX; + PATH_DELIMITER :: "/"; base_path = join(home_path, "/.local/share",, allocator = temporary_allocator); case .WINDOWS; + PATH_DELIMITER :: "\\"; base_path = join(home_path, "\\Appdata\\Roaming",, allocator = temporary_allocator); } @@ -1194,13 +1196,18 @@ main :: () { base_path = home_path; if how_much_of_path_exists_on_the_local_filesystem(parse_path(base_path,, allocator = temporary_allocator)) == false { // Default to current running executable path. - base_path = get_path_of_running_executable(); + base_path = path_strip_filename(get_path_of_running_executable()); } } - app_directory = join(base_path, "/", APP_FOLDER_NAME); - db_file_path = join(app_directory, "/", DB_FILE_NAME); - ar_file_path = join(app_directory, "/", AR_FILE_NAME); + if base_path[base_path.count-1] == PATH_DELIMITER[0] { + base_path.count -= 1; + } + + app_directory = join(base_path, PATH_DELIMITER, APP_FOLDER_NAME); + db_file_path = join(app_directory, PATH_DELIMITER, DB_FILE_NAME); + ar_file_path = join(app_directory, PATH_DELIMITER, AR_FILE_NAME); + make_directory_if_it_does_not_exist(app_directory, recursive = true); } -- cgit v1.2.3