add YggdrasilService interface and implementors
This commit is contained in:
parent
1b720e4b5d
commit
c3ca4e0055
6 changed files with 120 additions and 3 deletions
|
@ -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 ();
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue