| 100 | } |
| 101 | |
| 102 | bool ErrorChecking::checkArchType(Context* context) |
| 103 | { |
| 104 | /* Checking that the game binary exists (again) */ |
| 105 | if (!std::filesystem::exists(context->gamepath)) { |
| 106 | critical(QString("Game path %1 was not found").arg(context->gamepath.c_str()), context->interactive); |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | /* Checking that the libtas.so library path is correct */ |
| 111 | if (!std::filesystem::exists(context->libtaspath)) { |
| 112 | critical(QString("libtas.so library at %1 was not found. Make sure that the libtas.so file is in the same directory as the libTAS executable").arg(context->libtaspath.c_str()), context->interactive); |
| 113 | return false; |
| 114 | } |
| 115 | |
| 116 | /* Checking the type of game binary */ |
| 117 | int gameArch = extractBinaryType(context->gamepath) & BT_TYPEMASK; // Remove the extra flags |
| 118 | |
| 119 | if (gameArch == BT_UNKNOWN) { |
| 120 | critical(QString("Could not determine arch of file %1").arg(context->gamepath.c_str()), context->interactive); |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | if (gameArch == BT_SH) { |
| 125 | critical(QString("libTAS does not support launching a game from a script. Please specify the game binary file instead"), context->interactive); |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | int libtasArch = extractBinaryType(context->libtaspath) & BT_TYPEMASK; |
| 130 | if (libtasArch <= 0) { |
| 131 | critical(QString("Could not determine arch of file %1").arg(context->libtaspath.c_str()), context->interactive); |
| 132 | return false; |
| 133 | } |
| 134 | |
| 135 | /* Checking that the game can be executed by the user, or try adding the flag. |
| 136 | * This is not needed for wine games. |
| 137 | * MacOS apps are directories, and thus executables */ |
| 138 | if (gameArch != BT_PE32 && gameArch != BT_PE32P && gameArch != BT_NE && access(context->gamepath.c_str(), X_OK) != 0) { |
| 139 | |
| 140 | std::filesystem::permissions(context->gamepath, std::filesystem::perms::owner_exec, std::filesystem::perm_options::add); |
| 141 | |
| 142 | if (std::filesystem::perms::none == (std::filesystem::status(context->gamepath).permissions() & std::filesystem::perms::owner_exec)) { |
| 143 | critical(QString("Game %1 is not executable by the user, could not add the executable flag").arg(context->gamepath.c_str()), context->interactive); |
| 144 | return false; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /* Check for a possible libtas alternate file */ |
| 149 | if (((gameArch == BT_ELF32) || (gameArch == BT_PE32)) && (libtasArch == BT_ELF64)) { |
| 150 | if (context->libtas32path.empty()) { |
| 151 | critical(QString("Trying to launch a 32-bit game with a 64-bit build of libTAS, but libTAS couldn't guess the path to libtas32.so. Use --libtas32-so-path (see --help)"), context->interactive); |
| 152 | return false; |
| 153 | } else if (access(context->libtas32path.c_str(), F_OK) != 0) { |
| 154 | critical(QString("Trying to launch a 32-bit game with a 64-bit build of libTAS, but no libtas32.so library could be found at %1. Make sure that libTAS was built with dual-arch support and that the libtas32.so file is in the same directory as the libTAS executable").arg(context->libtas32path.c_str()), context->interactive); |
| 155 | return false; |
| 156 | } else { |
| 157 | libtasArch = extractBinaryType(context->libtas32path) & BT_TYPEMASK; |
| 158 | } |
| 159 | } |
nothing calls this directly
no test coverage detected