This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
System.OS_Lib.Copy_Files provides a subprogram to copy a file. When overwrite mode is specified, the target file is truncated at the very beginning of the procedure. This change modifies this behaviour so that the target file is truncated only if the source file was succesfully opened. If the source file exists but can't be read, the target file is thus preserved. The following test must display "dest" when run on a UNIX system: gnatmake -q unreadable_src rm -f src dest echo src > src chmod 0 src echo dest > dest unreadable_src cat dest -- source code follows with GNAT.OS_Lib; use GNAT.OS_Lib; with Ada.Text_IO; use Ada.Text_IO; procedure Unreadable_Src is Success : Boolean; begin Copy_File ("src", "dest", Success => Success, Mode => Overwrite); if Success then Put_Line ("Copy_File should have failed"); end if; end Unreadable_Src; Tested on i686-pc-linux-gnu, committed on trunk 2008-05-23 Thomas Quinot <quinot@adacore.com> * s-os_lib.adb: (copy_File): Do not open destination file if source file is unreadable.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |