Exemplo n.º 1
0
/**
 * Default directory fallback is:
 *   - (command line argument)
 *   - <exePath>/data
 *   - <platform dependent>
 */
void platform_resolve_openrct_data_path()
{
	const char separator[2] = { platform_get_path_separator(), 0 };

	if (gCustomOpenrctDataPath[0] != 0) {
		if (realpath(gCustomOpenrctDataPath, _openrctDataDirectoryPath)) {
			log_error("Could not resolve path \"%s\"", gCustomUserDataPath);
			return;
		}

		// Ensure path ends with separator
		int len = strlen(_openrctDataDirectoryPath);
		if (_openrctDataDirectoryPath[len - 1] != separator[0]) {
			strncat(_openrctDataDirectoryPath, separator, MAX_PATH - 1);
		}
		return;
	}

	char buffer[MAX_PATH] = { 0 };
	platform_get_exe_path(buffer);

	strncat(buffer, separator, MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
	strncat(buffer, "data", MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
	log_verbose("Looking for OpenRCT2 data in %s", buffer);
	if (platform_directory_exists(buffer))
	{
		_openrctDataDirectoryPath[0] = '\0';
		safe_strcpy(_openrctDataDirectoryPath, buffer, MAX_PATH);
		log_verbose("Found OpenRCT2 data in %s", _openrctDataDirectoryPath);
		return;
	}

	platform_posix_sub_resolve_openrct_data_path(_openrctDataDirectoryPath);
	log_verbose("Trying to use OpenRCT2 data in %s", _openrctDataDirectoryPath);
}
Exemplo n.º 2
0
/**
 * Default directory fallback is:
 *   - (command line argument)
 *   - <exePath>/data
 *   - <platform dependent>
 */
void platform_resolve_openrct_data_path()
{
    if (gCustomOpenrctDataPath[0] != 0) {
        // NOTE: second argument to `realpath` is meant to either be NULL or `PATH_MAX`-sized buffer,
        // since our `MAX_PATH` macro is set to some other value, pass NULL to have `realpath` return
        // a `malloc`ed buffer.
        char *resolved_path = realpath(gCustomOpenrctDataPath, NULL);
        if (resolved_path == NULL) {
            log_error("Could not resolve path \"%s\", errno = %d", gCustomOpenrctDataPath, errno);
            return;
        } else {
            safe_strcpy(_openrctDataDirectoryPath, resolved_path, MAX_PATH);
            free(resolved_path);
        }

        path_end_with_separator(_openrctDataDirectoryPath, MAX_PATH);
        return;
    }

    char buffer[MAX_PATH];
    platform_get_exe_path(buffer, sizeof(buffer));

    safe_strcat_path(buffer, "data", MAX_PATH);
    log_verbose("Looking for OpenRCT2 data in %s", buffer);
    if (platform_directory_exists(buffer))
    {
        _openrctDataDirectoryPath[0] = '\0';
        safe_strcpy(_openrctDataDirectoryPath, buffer, MAX_PATH);
        log_verbose("Found OpenRCT2 data in %s", _openrctDataDirectoryPath);
        return;
    }

    platform_posix_sub_resolve_openrct_data_path(_openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
    log_verbose("Trying to use OpenRCT2 data in %s", _openrctDataDirectoryPath);
}
Exemplo n.º 3
0
 static void openrct2_set_exe_path()
 {
     platform_get_exe_path(gExePath, sizeof(gExePath));
     log_verbose("Setting exe path to %s", gExePath);
 }