bugDotGNU Portable.NET - Bugs: bug #10485, File.Delete(string) throws an...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #10485: File.Delete(string) throws an exception when the file does not exist

Submitter:  Marcus Urban <mathpup>
Submitted:  Fri 24 Sep 2004 12:38:19 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Fri 24 Sep 2004 02:52:22 AM UTC, comment #1: 

Fix committed to CVS - 24 Sep 2004.  The "gen_errno.sh"
script will now use the output of "gcc -dD -E" to find the
error codes, which should handle definitions in multiple
/usr/include header files.  If the compiler does not support
"-dD", it will fall back to the current "assume that they
are all in one file" method.

Rhys Weatherley <rweather>
Group administrator
Fri 24 Sep 2004 12:38:19 AM UTC, original submission:  

File.Delete(string) throws an exception when the file does not exist. I think that it has something to do with the mapping of error codes.

File.Delete() invokes a helper method, which returns an error code. If the error code is that the file does not exist, everything is okay. Otherwise, an exception is thrown.

The problem is that eventually ILDelete() is called, which first tries the rmdir() function and then tries unlink(). If the file does not exist unlink() returns ENOENT, which is the integer 2 on my system. However, ILSysIOConvertErrno() converts this value to 1 (EPERM). So eventually File.Delete() receives an error code corresponding to EPERM, when it should instead receive ENOENT.

Marcus Urban <mathpup>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #1795:  test-delete.cs added by mathpup (114B - text/x-csharp - Test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-09-24 rweather StatusNone Fixed
    Open/ClosedOpen Closed
2004-09-24 mathpup Attached File- Added test-delete.cs, #1700

Back to the top

Powered by Savane 3.13-4b48.
Corresponding source code