| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file haiku.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par Licence: |
| 9 | * Copyright (c) 2015-2026 Carsten Teibes |
| 10 | * |
| 11 | * OpenJazz is distributed under the terms of |
| 12 | * the GNU General Public License, version 2.0 |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include "haiku.h" |
| 17 | |
| 18 | #ifdef __HAIKU__ |
| 19 | |
| 20 | #include <Alert.h> |
| 21 | #include <SupportDefs.h> |
| 22 | #include <FindDirectory.h> |
| 23 | #include <fs_info.h> |
| 24 | |
| 25 | #include "util.h" |
| 26 | #include "io/file.h" |
| 27 | |
| 28 | void HaikuPlatform::AddGamePaths() { |
| 29 | char dir_buffer[10 + B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; |
| 30 | dev_t volume = dev_for_path("/boot"); |
| 31 | |
| 32 | find_directory(B_USER_NONPACKAGED_DATA_DIRECTORY, |
| 33 | volume, false, dir_buffer, sizeof(dir_buffer)); |
| 34 | strncat(dir_buffer, "/openjazz/", sizeof(dir_buffer) - 1); |
| 35 | gamePaths.add(createString(dir_buffer), PATH_TYPE_GAME|PATH_TYPE_CONFIG); |
| 36 | |
| 37 | find_directory(B_SYSTEM_DATA_DIRECTORY, |
| 38 | volume, false, dir_buffer, sizeof(dir_buffer)); |
| 39 | strncat(dir_buffer, "/openjazz/", sizeof(dir_buffer) - 1); |
| 40 | gamePaths.add(createString(dir_buffer), PATH_TYPE_SYSTEM|PATH_TYPE_GAME); |
| 41 | } |
| 42 | |
| 43 | void HaikuPlatform::ErrorNoDatafiles() { |
| 44 | char dir_buffer[10 + B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; |
| 45 | find_directory(B_USER_NONPACKAGED_DATA_DIRECTORY, |
| 46 | dev_for_path("/boot"), false, dir_buffer, sizeof(dir_buffer)); |
| 47 | strncat(dir_buffer, "/openjazz/", sizeof(dir_buffer) - 1); |
| 48 | |
| 49 | char alertBuffer[100 + B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; |
| 50 | strcpy(alertBuffer, "Unable to find game data files!\n" |
| 51 | "Put the data into the folder:\n"); |
| 52 | strncat(alertBuffer, dir_buffer, sizeof(alertBuffer)); |
| 53 | |
| 54 | BAlert* alert = new BAlert("OpenJazz", alertBuffer, "Exit", NULL, NULL, |
| 55 | B_WIDTH_AS_USUAL, B_STOP_ALERT); |
| 56 | alert->Go(); |
| 57 | } |
| 58 | |
| 59 | #endif |