From 8ac2508eb094459c062d0c31b6367da393b4fa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 19 Mar 2022 18:05:05 +0100 Subject: New upstream version 42.0 --- src/postprocessor.vala | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/postprocessor.vala (limited to 'src/postprocessor.vala') diff --git a/src/postprocessor.vala b/src/postprocessor.vala new file mode 100644 index 0000000..2d036c9 --- /dev/null +++ b/src/postprocessor.vala @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Copyright (C) 2022 Alexander Vogt + * Author: Alexander Vogt + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + +public class Postprocessor { + + public Postprocessor(){ + + } + + public int process(string script, string mime_type, bool keep_original, string source_file, string arguments) throws Error { + // Code copied and adapted from https://valadoc.org/glib-2.0/GLib.Process.spawn_sync.html + string[] spawn_args = {script, mime_type, keep_original ? "true" : "false", source_file, arguments }; + string[] spawn_env = Environ.get (); + string process_stdout; + string process_stderr; + int process_status; + + print ("Executing script%s\n", script); + Process.spawn_sync (null, // inherit parent's working dir + spawn_args, + spawn_env, + SpawnFlags.SEARCH_PATH, + null, + out process_stdout, + out process_stderr, + out process_status); + debug ("status: %d\n", process_status); + debug ("STDOUT: \n"); + debug ("process_stdout"); + debug ("STDERR: \n"); + debug ("process_stderr"); + + return process_status; + } +} -- cgit v1.2.3