Spawn and redirect
This commit is contained in:
+23
-1
@@ -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 --
|
||||
------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user