From 8b7495e1044dcde8d2b6ad2a58aab32f5dc9bdf0 Mon Sep 17 00:00:00 2001 From: yoogx Date: Sun, 8 Nov 2020 09:57:39 -0500 Subject: [PATCH] * Add variant of Remove_Directory_Separator for string --- src/backends/ocarina-backends-utils.adb | 10 ++++++++++ src/backends/ocarina-backends-utils.ads | 1 + 2 files changed, 11 insertions(+) diff --git a/src/backends/ocarina-backends-utils.adb b/src/backends/ocarina-backends-utils.adb index db580041..5845bb27 100644 --- a/src/backends/ocarina-backends-utils.adb +++ b/src/backends/ocarina-backends-utils.adb @@ -227,6 +227,16 @@ package body Ocarina.Backends.Utils is return Name_Find; end Remove_Directory_Separator; + function Remove_Directory_Separator (Path : String) return String is + begin + if Path'Length >= 1 and then + Path (Path'Last) = Directory_Separator + then + return Path (Path'First .. Path'Last - 1); + end if; + return Path; + end Remove_Directory_Separator; + -------------------- -- Copy_Directory -- -------------------- diff --git a/src/backends/ocarina-backends-utils.ads b/src/backends/ocarina-backends-utils.ads index fc64bbf2..9e77589b 100644 --- a/src/backends/ocarina-backends-utils.ads +++ b/src/backends/ocarina-backends-utils.ads @@ -64,6 +64,7 @@ package Ocarina.Backends.Utils is -- string. function Remove_Directory_Separator (Path : Name_Id) return Name_Id; + function Remove_Directory_Separator (Path : String) return String; -- If there is a directory separator at the end of the path, then -- remove it and return the result. Else, return the same string.