Ejemplo n.º 1
0
void OBSAbout::ShowLicense()
{
	std::string path;
	QString error = "Error! File could not be read.\n\n \
		Go to: https://github.com/obsproject/obs-studio/blob/master/COPYING";

	if (!GetDataFilePath("license/gplv2.txt", path)) {
		ui->textBrowser->setPlainText(error);
		return;
	}

	BPtr<char> text = os_quick_read_utf8_file(path.c_str());

	if (!text || !*text) {
		ui->textBrowser->setPlainText(error);
		return;
	}

	ui->textBrowser->setPlainText(QT_UTF8(text));

	ui->info->hide();
	ui->contribute->hide();
	ui->donate->hide();
	ui->getInvolved->hide();
	ui->textBrowser->show();
}
Ejemplo n.º 2
0
static inline bool load_offsets_from_file(struct graphics_offsets *offsets,
		const char *file)
{
	char *str = os_quick_read_utf8_file(file);
	bool success = false;
	if (str && *str)
		success = load_offsets_from_string(offsets, str);
	bfree(str);
	return success;
}
Ejemplo n.º 3
0
effect_t gs_create_effect_from_file(const char *file, char **error_string)
{
	char *file_string;
	effect_t effect = NULL;

	file_string = os_quick_read_utf8_file(file);
	if (!file_string) {
		blog(LOG_WARNING, "Could not load effect file '%s'", file);
		return NULL;
	}

	effect = gs_create_effect(file_string, file, error_string);
	bfree(file_string);

	return effect;
}
Ejemplo n.º 4
0
shader_t gs_create_pixelshader_from_file(const char *file, char **error_string)
{
	char *file_string;
	shader_t shader = NULL;

	file_string = os_quick_read_utf8_file(file);
	if (!file_string) {
		blog(LOG_WARNING, "Could not load pixel shader file '%s'",
				file);
		return NULL;
	}

	shader = gs_create_pixelshader(file_string, file, error_string);
	bfree(file_string);

	return shader;
}
template <typename Func> static void EnumSceneCollections(Func &&cb)
{
	char path[512];
	os_glob_t *glob;

	int ret = GetConfigPath(path, sizeof(path),
			"obs-studio/basic/scenes/*.json");
	if (ret <= 0) {
		blog(LOG_WARNING, "Failed to get config path for scene "
		                  "collections");
		return;
	}

	if (os_glob(path, 0, &glob) != 0) {
		blog(LOG_WARNING, "Failed to glob scene collections");
		return;
	}

	for (size_t i = 0; i < glob->gl_pathc; i++) {
		const char *filePath = glob->gl_pathv[i].path;

		if (glob->gl_pathv[i].directory)
			continue;

		BPtr<char> fileData = os_quick_read_utf8_file(filePath);
		if (!fileData)
			continue;

		obs_data_t *data = obs_data_create_from_json(fileData);
		std::string name = obs_data_get_string(data, "name");

		/* if no name found, use the file name as the name
		 * (this only happens when switching to the new version) */
		if (name.empty()) {
			name = strrchr(filePath, '/') + 1;
			name.resize(name.size() - 5);
		}

		obs_data_release(data);

		if (!cb(name.c_str(), filePath))
			break;
	}

	os_globfree(glob);
}
Ejemplo n.º 6
0
shader_t gs_create_vertexshader_from_file(const char *file, char **error_string)
{
	if (!thread_graphics || !file)
		return NULL;

	char *file_string;
	shader_t shader = NULL;

	file_string = os_quick_read_utf8_file(file);
	if (!file_string) {
		blog(LOG_ERROR, "Could not load vertex shader file '%s'",
				file);
		return NULL;
	}

	shader = gs_create_vertexshader(file_string, file, error_string);
	bfree(file_string);

	return shader;
}