Spawn and redirect

This commit is contained in:
Alejandro R. Mosteo
2018-02-11 23:42:10 +01:00
parent 549eb878d8
commit 518fb55d50
2 changed files with 28 additions and 1 deletions
+23 -1
View File
@@ -177,10 +177,32 @@ package body Alire.OS_Lib is
Code : constant Integer := Spawn (Command, Arguments, Understands_Verbose, Force_Quiet);
begin
if Code /= 0 then
raise Program_Error with "Exit code:" & Code'Image;
raise Program_Error with "Exit code:" & Code'Img;
end if;
end Spawn;
------------------------
-- Spawn_And_Redirect --
------------------------
procedure Spawn_And_Redirect (Out_File : String;
Command : String;
Arguments : String := "";
Err_To_Out : Boolean := False)
is
File : constant File_Descriptor := Create_File (Out_File, Text);
Code : Integer;
begin
Spawn (Locate_In_Path (Command),
Argument_String_To_List (Arguments).all,
File, Code, Err_To_Out);
Close (File);
if Code /= 0 then
raise Program_Error with "Exit code:" & Code'Img;
end if;
end Spawn_And_Redirect;
------------------
-- Spawn_Bypass --
------------------
+5
View File
@@ -19,6 +19,11 @@ package Alire.OS_Lib is
Arguments : String := "");
-- Direct launch, without any shenanigangs on output, for example for respawning the canonical version
procedure Spawn_And_Redirect (Out_File : String;
Command : String;
Arguments : String := "";
Err_To_Out : Boolean := False);
type Folder_Guard (<>) is limited private;
-- use this type in conjunction with Enter_Folder to ensure that
-- the CWD is modified and restored when creating/destroying the Folder_Guard