aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2023-09-19 09:45:16 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-10-10 14:12:28 +0200
commit34992e156b6a4d737440e675b86cd2f8ac103363 (patch)
treed48f1b3a606930ba2837a089d5ae17703c3592a4
parentf71c6312b64a9115ce6243ec12affc9d444033a5 (diff)
downloadgcc-34992e156b6a4d737440e675b86cd2f8ac103363.zip
gcc-34992e156b6a4d737440e675b86cd2f8ac103363.tar.gz
gcc-34992e156b6a4d737440e675b86cd2f8ac103363.tar.bz2
ada: Fix filesystem entry filtering
This patch fixes the behavior of Ada.Directories.Search when being requested to filter out regular files or directories. One of the configurations in which that behavior was incorrect was that when the caller requested only the regular and special files but not the directories, the directories would still be returned. gcc/ada/ * libgnat/a-direct.adb: Fix filesystem entry filtering.
-rw-r--r--gcc/ada/libgnat/a-direct.adb30
1 files changed, 16 insertions, 14 deletions
diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb
index 4b08d41..f7a1d5d 100644
--- a/gcc/ada/libgnat/a-direct.adb
+++ b/gcc/ada/libgnat/a-direct.adb
@@ -1414,24 +1414,26 @@ package body Ada.Directories is
elsif Exists = 1 then
if Is_Regular_File_Attr (Path_C'Address, Attr'Access) = 1
- and then Filter (Ordinary_File)
then
- Found := True;
- Kind := Ordinary_File;
- Size :=
- File_Size
- (File_Length_Attr
- (-1, Path_C'Address, Attr'Access));
+ if Filter (Ordinary_File) then
+ Found := True;
+ Kind := Ordinary_File;
+ Size :=
+ File_Size
+ (File_Length_Attr
+ (-1, Path_C'Address, Attr'Access));
+ end if;
elsif Is_Directory_Attr (Path_C'Address, Attr'Access) = 1
- and then Filter (File_Kind'First)
then
- Found := True;
- Kind := File_Kind'First;
- -- File_Kind'First is used instead of Directory due
- -- to a name overload issue with the procedure
- -- parameter Directory.
- Size := 0;
+ if Filter (File_Kind'First) then
+ Found := True;
+ Kind := File_Kind'First;
+ -- File_Kind'First is used instead of Directory due
+ -- to a name overload issue with the procedure
+ -- parameter Directory.
+ Size := 0;
+ end if;
elsif Filter (Special_File) then
Found := True;