New folder guard to stay in current folder

This commit is contained in:
Alejandro R. Mosteo
2018-02-03 12:11:38 +01:00
parent a5038bc3fc
commit f97f72ea9c
2 changed files with 16 additions and 2 deletions
+12
View File
@@ -62,6 +62,18 @@ package body Alire.OS_Lib is
end return;
end Enter_Folder;
----------------------------
-- Stay_In_Current_Folder --
----------------------------
function Stay_In_Current_Folder return Folder_Guard is
begin
return Guard : Folder_Guard (0) do
Log ("Staying in current folder", Debug);
Guard.Initialized := False;
end return;
end Stay_In_Current_Folder;
--------------
-- Finalize --
--------------
+4 -2
View File
@@ -15,7 +15,9 @@ package Alire.OS_Lib is
-- use this type in conjunction with Enter_Folder to ensure that
-- the CWD is modified and restored when creating/destroying the Folder_Guard
function Enter_Folder (Path : String) return Folder_Guard;
function Enter_Folder (Path : String) return Folder_Guard;
function Stay_In_Current_Folder return Folder_Guard;
function "/" (L, R : String) return String is
(Ada.Directories.Compose (L, R));
@@ -23,7 +25,7 @@ package Alire.OS_Lib is
private
type Folder_Guard (Original_Len : Positive) is new Ada.Finalization.Limited_Controlled with record
type Folder_Guard (Original_Len : Natural) is new Ada.Finalization.Limited_Controlled with record
Original : String (1 .. Original_Len);
Initialized : Boolean := False;
end record;