//
// Find the data/ folder regardless of where the binary was launched.
//
// We try cwd, then the exe's directory, then exe_dir/.. (so running
// ./build/player from the project root works).
//

setup_data_directory :: () {
    candidates: [..] string;
    array_add(*candidates, ".");

    exe_dir := path_strip_filename(get_path_of_running_executable());
    array_add(*candidates, copy_string(exe_dir));
    array_add(*candidates, tprint("%/..", exe_dir));

    for candidates {
        data_path := tprint("%/data", it);
        if file_exists(data_path) {
            set_working_directory(it);
            log_info("working dir: %", it);
            return;
        }
    }

    log_warn("could not locate data/ — fonts and shaders may fail to load");
}
