summaryrefslogtreecommitdiff
path: root/gcc/ada/s-os_lib.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-23 13:29:02 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-23 13:29:02 +0000
commitec47e507952a085b41f850c433079dac3ce70d55 (patch)
tree854259bd976214ac710b93b279badb63f5dcc42e /gcc/ada/s-os_lib.adb
parent0c7a5982c0ec7851a2d799bbc30165d50ffe8a20 (diff)
downloadgcc-ec47e507952a085b41f850c433079dac3ce70d55.tar.gz
2008-05-23 Thomas Quinot <quinot@adacore.com>
* s-os_lib.adb: (copy_File): Do not open destination file if source file is unreadable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135805 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-os_lib.adb')
-rwxr-xr-xgcc/ada/s-os_lib.adb16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb
index f3e369cf853..5655b3c0d7c 100755
--- a/gcc/ada/s-os_lib.adb
+++ b/gcc/ada/s-os_lib.adb
@@ -452,7 +452,13 @@ package body System.OS_Lib is
begin
From := Open_Read (Name, Binary);
- To := Create_File (To_Name, Binary);
+
+ -- Do not clobber destination file if source file could not be opened
+
+ if From /= Invalid_FD then
+ To := Create_File (To_Name, Binary);
+ end if;
+
Copy (From, To);
-- Copy attributes
@@ -545,10 +551,14 @@ package body System.OS_Lib is
if Is_Regular_File (Pathname) then
-- Append mode and destination file exists, append data at the
- -- end of Pathname.
+ -- end of Pathname. But if we fail to open source file, do not
+ -- touch destination file at all.
From := Open_Read (Name, Binary);
- To := Open_Read_Write (Pathname, Binary);
+ if From /= Invalid_FD then
+ To := Open_Read_Write (Pathname, Binary);
+ end if;
+
Lseek (To, 0, Seek_End);
Copy (From, To);