+
+ function Simple_Name_CI (Path : String) return String;
+ -- This function does the job. The difference between Simple_Name_CI
+ -- and Simple_Name (the parent function) is that the former is case
+ -- sensitive, while the latter is not. Path and Suffix are adjusted
+ -- appropriately before calling Simple_Name_CI under platforms where
+ -- the file system is not case sensitive.
+
+ --------------------
+ -- Simple_Name_CI --
+ --------------------
+
+ function Simple_Name_CI (Path : String) return String is
+ Cut_Start : Natural :=
+ Strings.Fixed.Index
+ (Path, Dir_Seps, Going => Strings.Backward);
+ Cut_End : Natural;
+
+ begin
+ -- Cut_Start point to the first simple name character
+
+ if Cut_Start = 0 then
+ Cut_Start := Path'First;
+
+ else
+ Cut_Start := Cut_Start + 1;
+ end if;
+
+ -- Cut_End point to the last simple name character
+
+ Cut_End := Path'Last;
+
+ Check_For_Standard_Dirs : declare
+ Offset : constant Integer := Path'First - Name'First;
+ BN : constant String :=
+ Name (Cut_Start - Offset .. Cut_End - Offset);
+ -- Here we use Simple_Name.Name to keep the original casing
+
+ Has_Drive_Letter : constant Boolean :=
+ System.OS_Lib.Path_Separator /= ':';
+ -- If Path separator is not ':' then we are on a DOS based OS
+ -- where this character is used as a drive letter separator.
+
+ begin
+ if BN = "." or else BN = ".." then
+ return "";
+
+ elsif Has_Drive_Letter
+ and then BN'Length > 2
+ and then Characters.Handling.Is_Letter (BN (BN'First))
+ and then BN (BN'First + 1) = ':'
+ then
+ -- We have a DOS drive letter prefix, remove it
+
+ return BN (BN'First + 2 .. BN'Last);
+
+ else
+ return BN;
+ end if;
+ end Check_For_Standard_Dirs;
+ end Simple_Name_CI;
+
+ -- Start of processing for Simple_Name
+