From 0b0559e3750c0cc0662640f293cfa7c1f8d0af17 Mon Sep 17 00:00:00 2001 From: dam Date: Thu, 16 Feb 2023 18:08:43 +0000 Subject: Initialize app directory and file paths. --- ttt.jai | 61 +++++++++++++++++++++++-------------------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index 345e3cc..1eaf8e1 100644 --- a/ttt.jai +++ b/ttt.jai @@ -1207,56 +1207,31 @@ bool read_enter_confirmation(int row, int style, const char *message) { } */ - main :: () { defer free_memory(); - { // Initialize app directory. - - home_dir, success := get_home_directory(); // Returns system owned memory. - if success == false { + { // Initialize app directory. + home_dir, success_dir := get_home_directory(); // Returns system owned memory. + if success_dir == false { home_dir = "."; } - app_directory, success = get_absolute_path(home_dir); // TODO Returns temporary memory. - if success == false { + home_path, success_path := get_absolute_path(home_dir); // Returns temporary memory. + if success_path == false { print_error("Failed to find home directory '%'.", home_dir); return; } - app_directory = join(app_directory, "/", APP_FOLDER_NAME, allocator = temp); // TODO Change to default allocator because we want to keep this during runtime. -// print(">%:%:%\n", temp, temp.data, context.temporary_storage.data); - print("#%\n", <%:%\n", app_directory.count, *app_directory.data); -// free(app_directory); - - /* WIP TEST THIS -some_pointer : *void = get_something(); -is_it_mine : bool = xx allocator.allocator_proc(.IS_THIS_YOURS, 0, 0, some_pointer, null); - */ + app_directory = join(home_path, "/", APP_FOLDER_NAME); + db_file_path = join(app_directory, "/", DB_FILE_NAME); + ar_file_path = join(app_directory, "/", AR_FILE_NAME); - - reset_temporary_storage(); - a := join("wow", "testsesesrserse", "2222222222222222"); - b := join("wow", "testsesesrserse", "2222222222222222"); - c := join("wow", "testsesesrserse", "2222222222222222"); - d := join("wow", "testsesesrserse", "2222222222222222"); - print("bazinga: '%'\n", app_directory); -// if make_directory_if_it_does_not_exist(app_directory, false) == false { -// print_error("Failed to create app directory '%'.", app_directory); -// return; -// } - db_file_path = join(app_directory, "/", DB_FILE_NAME, allocator = temp); // TODO Change to default allocator because we want to keep this during runtime. - ar_file_path = join(app_directory, "/", AR_FILE_NAME, allocator = temp); // TODO Change to default allocator because we want to keep this during runtime. + // TODO DEBUG + print_owner_allocator("home_path", home_path.data); + print_owner_allocator("app_directory", app_directory.data); + print_owner_allocator("db_file_path", db_file_path.data); + print_owner_allocator("ar_file_path", ar_file_path.data); } return; // TODO DEBUG @@ -1858,3 +1833,13 @@ main :: () { } */ + + +print_owner_allocator :: (tag: string, memory: *void) { + owner := "unkown"; + + if true == xx context.allocator.proc(.IS_THIS_YOURS, 0, 0, memory, null) then owner = "default"; + else if true == xx temp.proc(.IS_THIS_YOURS, 0, 0, memory, null) then owner = "temp"; + + print("'%' belongs to '%'\n", tag, owner); +} -- cgit v1.2.3