static
int _starpu_opencl_locate_file(const char *source_file_name, char *located_file_name, char *located_dir_name)
{
	int ret = EXIT_FAILURE;

	_STARPU_DEBUG("Trying to locate <%s>\n", source_file_name);
	if (access(source_file_name, R_OK) == 0)
	{
		strcpy(located_file_name, source_file_name);
		ret = EXIT_SUCCESS;
	}

	if (ret == EXIT_FAILURE && _starpu_opencl_program_dir)
	{
		sprintf(located_file_name, "%s/%s", _starpu_opencl_program_dir, source_file_name);
		_STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
		if (access(located_file_name, R_OK) == 0)
			ret = EXIT_SUCCESS;
	}

	if (ret == EXIT_FAILURE)
	{
		sprintf(located_file_name, "%s/%s", STARPU_SRC_DIR, source_file_name);
		_STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
		if (access(located_file_name, R_OK) == 0)
			ret = EXIT_SUCCESS;
	}

	if (ret == EXIT_FAILURE)
	{
		sprintf(located_file_name, "%s/%s", _STARPU_STRINGIFY(STARPU_OPENCL_DATADIR), source_file_name);
		_STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
		if (access(located_file_name, R_OK) == 0)
			ret = EXIT_SUCCESS;
	}

	if (ret == EXIT_FAILURE)
	{
		strcpy(located_file_name, "");
		strcpy(located_dir_name, "");
		_STARPU_ERROR("Cannot locate file <%s>\n", source_file_name);
	}
	else
	{
		char *last = strrchr(located_file_name, '/');

		if (!last)
		{
			strcpy(located_dir_name, "");
		}
		else
		{
			sprintf(located_dir_name, "%s", located_file_name);
			located_dir_name[strlen(located_file_name)-strlen(last)+1] = '\0';
		}
	}

	return ret;
}
Beispiel #2
0
static
int _starpu_opencl_locate_file(char *source_file_name, char *located_file_name) {
    _STARPU_DEBUG("Trying to locate <%s>\n", source_file_name);
    if (access(source_file_name, R_OK) == 0) {
        strcpy(located_file_name, source_file_name);
        return EXIT_SUCCESS;
    }
    if (_starpu_opencl_program_dir) {
        sprintf(located_file_name, "%s/%s", _starpu_opencl_program_dir, source_file_name);
        _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
        if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;
    }
    sprintf(located_file_name, "%s/%s", _STARPU_STRINGIFY(STARPU_OPENCL_DATADIR), source_file_name);
    _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
    if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;
    sprintf(located_file_name, "%s/%s", STARPU_SRC_DIR, source_file_name);
    _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
    if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;

    strcpy(located_file_name, "");
    _STARPU_ERROR("Cannot locate file <%s>\n", source_file_name);
    return EXIT_FAILURE;
}