add YggdrasilService interface and implementors

This commit is contained in:
Nikolay Brovko 2020-01-26 14:14:26 +03:00
parent 1b720e4b5d
commit c3ca4e0055
No known key found for this signature in database
GPG key ID: 32258A3DEC9B6F07
6 changed files with 120 additions and 3 deletions

View file

@ -13,14 +13,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Utils {
namespace Yggtk.Utils {
string mktempdir () throws Error {
public bool is_command_available (string command) {
try {
string cmd_stdout, cmd_stderr;
int cmd_status = -1;
Process.spawn_command_line_sync (@"which $command", out cmd_stdout, out cmd_stderr, out cmd_status);
if (cmd_status == 0 && cmd_stderr.length == 0 && cmd_stdout.length > 0) {
return true;
}
} catch (SpawnError e) {
return false;
}
return false;
}
public string mktempdir () throws SpawnError {
string temp_dir = null;
Process.spawn_command_line_sync ("mktemp -d", out temp_dir);
return temp_dir.strip ();
}
}