diff options
| -rw-r--r-- | .hgignore | 1 | ||||
| -rw-r--r-- | ttt.jai | 37 |
2 files changed, 24 insertions, 14 deletions
diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 30bcfa4..0000000 --- a/.hgignore +++ /dev/null @@ -1 +0,0 @@ -.build/ @@ -14,11 +14,11 @@ DEBUG :: false; #import "UTF8"; TUI :: #import "TUI"(COLOR_MODE_BITS=4); -VERSION :: "2.0"; // Use only 3 chars (to fit layouts). +VERSION :: "2.1"; // Use only 3 chars (to fit layouts). YEAR :: "2024"; NUM_WEEK_DAYS :: 7; -APP_FOLDER_NAME :: ".task_time_tracker"; +APP_FOLDER_NAME :: "task_time_tracker"; DB_FILE_NAME :: "database.bin"; AR_FILE_NAME :: "archive.csv"; DB_FILE_SIGN_STR :: "TTT:B:02"; @@ -1168,25 +1168,37 @@ prompt_user_key :: (y: int, message: string) -> TUI.Key { main :: () { #if DEBUG { defer report_memory_leaks(); } - + context.logger = print_error; defer free_memory(); { // Initialize app directory. - home_dir, success_dir := get_home_directory(); // Returns system owned memory. - if success_dir == false { - home_dir = "."; - } + + auto_release_temp(); + + base_path := ""; + home_path := get_home_directory(); - home_path, success_path := get_absolute_path(home_dir); // Returns temporary memory. + #if OS == { + case .LINUX; + base_path = join(home_path, "/.local/share",, allocator = temporary_allocator); - if success_path == false { - log_error("Failed to find home directory '%'.", home_dir); - exit(1); + case .WINDOWS; + base_path = join(home_path, "\\Appdata\\Roaming",, allocator = temporary_allocator); + } + + // Try the most specific path. + if how_much_of_path_exists_on_the_local_filesystem(parse_path(base_path,, allocator = temporary_allocator)) == false { + // Try home path as fallback. + 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(); + } } - app_directory = join(home_path, "/", APP_FOLDER_NAME); + 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); @@ -1265,7 +1277,6 @@ main :: () { "\n", "Notes\n"); print("- All data files are stored in '%'.\n", app_directory); - print(" If the home directory is undefined, './%' will be used.\n", APP_FOLDER_NAME); write_strings( " The database tasks are stored in binary format on the 'database.bin' file.\n", " The archived entries are stored in CSV format on the 'archive.csv' file.\n", |
