From f97f72ea9c8e639064159ddf4370bdfe76c28488 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sat, 3 Feb 2018 12:11:38 +0100 Subject: [PATCH] New folder guard to stay in current folder --- src/alire-os_lib.adb | 12 ++++++++++++ src/alire-os_lib.ads | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/alire-os_lib.adb b/src/alire-os_lib.adb index 3c2e41aa..46a75ca5 100644 --- a/src/alire-os_lib.adb +++ b/src/alire-os_lib.adb @@ -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 -- -------------- diff --git a/src/alire-os_lib.ads b/src/alire-os_lib.ads index 02fec614..63349df6 100644 --- a/src/alire-os_lib.ads +++ b/src/alire-os_lib.ads @@ -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;