aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/clean.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-07-30 16:26:55 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-07-30 16:26:55 +0200
commitc98b825308a59e73598f30dd14827a8c57567369 (patch)
treee6820aa8254dde3d04565c8889d576814db35acb /gcc/ada/clean.adb
parent2e471ec7641db7c5f0291f1b90de6ccecc1aea4a (diff)
downloadgcc-c98b825308a59e73598f30dd14827a8c57567369.zip
gcc-c98b825308a59e73598f30dd14827a8c57567369.tar.gz
gcc-c98b825308a59e73598f30dd14827a8c57567369.tar.bz2
[multiple changes]
2014-07-30 Robert Dewar <dewar@adacore.com> * sem_ch3.adb, sem_ch3.ads: Minor code reorganization. 2014-07-30 Pascal Obry <obry@adacore.com> * clean.adb (Clean_Project): Properly check for directory existence before trying to enter it. From-SVN: r213284
Diffstat (limited to 'gcc/ada/clean.adb')
-rw-r--r--gcc/ada/clean.adb91
1 files changed, 52 insertions, 39 deletions
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));