aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2024-06-04 10:57:28 +0100
committerdam <dam@gudinoff>2024-06-04 15:11:48 +0100
commit45aef04664df07913c9ab75a0b329a2e370a5ecc (patch)
treed0dc968e9d28dd6b2bbc91afadff5952c595eeed
parentb809105861edc0c639863e2575e61f156c137ae1 (diff)
downloadtask-time-tracker-45aef04664df07913c9ab75a0b329a2e370a5ecc.tar.zst
task-time-tracker-45aef04664df07913c9ab75a0b329a2e370a5ecc.zip
Fix data path finding when no system folders are found.v2.2
-rw-r--r--.gitignore1
-rw-r--r--ttt.jai17
2 files changed, 13 insertions, 5 deletions
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);
}