From c98b825308a59e73598f30dd14827a8c57567369 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 30 Jul 2014 16:26:55 +0200 Subject: [multiple changes] 2014-07-30 Robert Dewar * sem_ch3.adb, sem_ch3.ads: Minor code reorganization. 2014-07-30 Pascal Obry * clean.adb (Clean_Project): Properly check for directory existence before trying to enter it. From-SVN: r213284 --- gcc/ada/clean.adb | 91 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 39 deletions(-) (limited to 'gcc/ada/clean.adb') diff --git a/gcc/ada/clean.adb b/gcc/ada/clean.adb index 0a7108d..4abbc94 100644 --- a/gcc/ada/clean.adb +++ b/gcc/ada/clean.adb @@ -666,51 +666,58 @@ package body Clean is Canonical_Case_File_Name (Archive_Name); Canonical_Case_File_Name (DLL_Name); - Change_Dir (Lib_Directory); - Open (Direc, "."); + if Is_Directory (Lib_Directory) then + Change_Dir (Lib_Directory); + Open (Direc, "."); - -- For each regular file in the directory, if switch -n has not - -- been specified, make it writable and delete the file if it is - -- the library file. + -- For each regular file in the directory, if switch -n has not + -- not been specified, make it writable and delete the file if + -- it is the library file. - loop - Read (Direc, Name, Last); - exit when Last = 0; - - declare - Filename : constant String := Name (1 .. Last); + loop + Read (Direc, Name, Last); + exit when Last = 0; - begin - if Is_Regular_File (Filename) - or else Is_Symbolic_Link (Filename) - then - Canonical_Case_File_Name (Name (1 .. Last)); - Delete_File := False; + declare + Filename : constant String := Name (1 .. Last); - if (Project.Library_Kind = Static - and then Name (1 .. Last) = Archive_Name) - or else - ((Project.Library_Kind = Dynamic - or else - Project.Library_Kind = Relocatable) - and then - (Name (1 .. Last) = DLL_Name - or else - Name (1 .. Last) = Minor.all - or else - Name (1 .. Last) = Major.all)) + begin + if Is_Regular_File (Filename) + or else Is_Symbolic_Link (Filename) then - if not Do_Nothing then - Set_Writable (Filename); - end if; + Canonical_Case_File_Name (Name (1 .. Last)); + Delete_File := False; + + if (Project.Library_Kind = Static + and then Name (1 .. Last) = Archive_Name) + or else + ((Project.Library_Kind = Dynamic + or else + Project.Library_Kind = Relocatable) + and then + (Name (1 .. Last) = DLL_Name + or else + Name (1 .. Last) = Minor.all + or else + Name (1 .. Last) = Major.all)) + then + if not Do_Nothing then + Set_Writable (Filename); + end if; - Delete (Lib_Directory, Filename); + Delete (Lib_Directory, Filename); + end if; end if; - end if; - end; - end loop; + end; + end loop; - Close (Direc); + Close (Direc); + end if; + + if not Is_Directory (Lib_ALI_Directory) then + -- Nothing more to do, return now + return; + end if; Change_Dir (Lib_ALI_Directory); Open (Direc, "."); @@ -860,7 +867,10 @@ package body Clean is Processed_Projects.Increment_Last; Processed_Projects.Table (Processed_Projects.Last) := Project; - if Project.Object_Directory /= No_Path_Information then + if Project.Object_Directory /= No_Path_Information + and then Is_Directory + (Get_Name_String (Project.Object_Directory.Display_Name)) + then declare Obj_Dir : constant String := Get_Name_String (Project.Object_Directory.Display_Name); @@ -1188,7 +1198,10 @@ package body Clean is end; end if; - if Project.Object_Directory /= No_Path_Information then + if Project.Object_Directory /= No_Path_Information + and then Is_Directory + (Get_Name_String (Project.Object_Directory.Display_Name)) + then Delete_Binder_Generated_Files (Get_Name_String (Project.Object_Directory.Display_Name), Strip_Suffix (Main_Source_File)); -- cgit v1.1