Commit e401e17b by Thomas Quinot Committed by Arnaud Charlet

2008-05-23 Thomas Quinot <quinot@adacore.com>

	* s-os_lib.adb:
	(copy_File): Do not open destination file if source file is unreadable.

From-SVN: r135805
parent d313a1b6
...@@ -452,7 +452,13 @@ package body System.OS_Lib is ...@@ -452,7 +452,13 @@ package body System.OS_Lib is
begin begin
From := Open_Read (Name, Binary); 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 (From, To);
-- Copy attributes -- Copy attributes
...@@ -545,10 +551,14 @@ package body System.OS_Lib is ...@@ -545,10 +551,14 @@ package body System.OS_Lib is
if Is_Regular_File (Pathname) then if Is_Regular_File (Pathname) then
-- Append mode and destination file exists, append data at the -- 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); 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); Lseek (To, 0, Seek_End);
Copy (From, To); Copy (From, To);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment