summaryrefslogtreecommitdiff
path: root/src/postprocessor.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-03-19 18:05:09 +0100
committerJörg Frings-Fürst <debian@jff.email>2022-03-19 18:05:09 +0100
commite2af6e905a98b8b90b0504bc8f245733196dd808 (patch)
treeed6425480e22209291077ee018858e2a7c9e26f9 /src/postprocessor.vala
parent14afa21f4a428f9a6a5788dc1fb8a3507a42d02f (diff)
parent8ac2508eb094459c062d0c31b6367da393b4fa6e (diff)
Update upstream source from tag 'upstream/42.0'
Update to upstream version '42.0' with Debian dir baa60a251498352959c048578d8f76023260a87e
Diffstat (limited to 'src/postprocessor.vala')
-rw-r--r--src/postprocessor.vala44
1 files changed, 44 insertions, 0 deletions
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 <a.vogt@fulguritus.com>
+ *
+ * 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;
+ }
+}