[Bug ada/56055] New: Delete_File won't delete special files
bjorn@xn--rombobjrn-67a.se
gcc-bugzilla@gcc.gnu.org
Mon Jan 21 00:53:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56055
Bug #: 56055
Summary: Delete_File won't delete special files
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bjorn@xn--rombobjrn-67a.se
According to the Ada Reference Manual, Ada.Directories.Delete_File "deletes an
existing ordinary or special file", that is any kind of file except a
directory. Libgnat's implementation refuses to delete a socket (at least on
GNU/Linux), claiming falsely that the socket doesn't exist.
A more correct approach would be to check first that the file isn't a
directory, then call unlink, and if unlink fails then check errno to see
whether Name_Error or Use_Error should be raised. (To really do the right
thing, fetch the error string with strerror_r and include it in the exception
message.)
Looking through a-direct.adb I see that several subprograms call
Is_Regular_File, and I suspect that most of them will fail in the presence of
special files. Rename for example should probably call File_Exists instead of
Is_Regular_File and Is_Directory.
More information about the Gcc-bugs
mailing list