Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2006-07-06 19:24:55 +0400
committerDick Porter <dick@acm.org>2006-07-06 19:24:55 +0400
commit6359b6b6208bf91af31f168f55a481c8eb94768a (patch)
tree52f52cc4f9b075a625853dc6ad4b313e0dd9b50e
parent8f0a649921a4d99c9168b48d30f1534221ac2a8f (diff)
2006-07-06 Dick Porter <dick@ximian.com>
* Directory.cs: When creating a directory treat ERROR_FILE_EXISTS (ie a file already exists with that name) the same as ERROR_ALREADY_EXISTS (ie a directory already exists with that name.) Keeps bug 50753 fixed when I fix the io-layer CreateDirectory() behaviour. 2006-07-06 Dick Porter <dick@ximian.com> * DirectoryTest.cs: Test creating a directory when a file or directory already exists with the requested name. svn path=/branches/mono-1-1-13/mcs/; revision=62319
-rw-r--r--mcs/class/corlib/System.IO/ChangeLog8
-rw-r--r--mcs/class/corlib/System.IO/Directory.cs3
-rw-r--r--mcs/class/corlib/Test/System.IO/ChangeLog5
-rw-r--r--mcs/class/corlib/Test/System.IO/DirectoryTest.cs43
4 files changed, 58 insertions, 1 deletions
diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog
index ec9a240cada..9826447f25b 100644
--- a/mcs/class/corlib/System.IO/ChangeLog
+++ b/mcs/class/corlib/System.IO/ChangeLog
@@ -1,3 +1,11 @@
+2006-07-06 Dick Porter <dick@ximian.com>
+
+ * Directory.cs: When creating a directory treat ERROR_FILE_EXISTS
+ (ie a file already exists with that name) the same as
+ ERROR_ALREADY_EXISTS (ie a directory already exists with that
+ name.) Keeps bug 50753 fixed when I fix the io-layer
+ CreateDirectory() behaviour.
+
2006-04-29 Atsushi Enomoto <atsushi@ximian.com>
* UnexceptionalStreamReader.cs (Read): Fix for #78218, where we
diff --git a/mcs/class/corlib/System.IO/Directory.cs b/mcs/class/corlib/System.IO/Directory.cs
index d212b28dd0e..6783bf2952f 100644
--- a/mcs/class/corlib/System.IO/Directory.cs
+++ b/mcs/class/corlib/System.IO/Directory.cs
@@ -101,7 +101,8 @@ namespace System.IO
// and having di.Exists return false afterwards.
// I hope we don't break anyone's code, as they should be catching
// the exception anyway.
- if (error != MonoIOError.ERROR_ALREADY_EXISTS)
+ if (error != MonoIOError.ERROR_ALREADY_EXISTS &&
+ error != MonoIOError.ERROR_FILE_EXISTS)
throw MonoIO.GetException (path, error);
}
diff --git a/mcs/class/corlib/Test/System.IO/ChangeLog b/mcs/class/corlib/Test/System.IO/ChangeLog
index eab80c443be..e6deb5eb358 100644
--- a/mcs/class/corlib/Test/System.IO/ChangeLog
+++ b/mcs/class/corlib/Test/System.IO/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-06 Dick Porter <dick@ximian.com>
+
+ * DirectoryTest.cs: Test creating a directory when a file or
+ directory already exists with the requested name.
+
2006-03-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* FileStreamTest.cs: new test from bug #77863.
diff --git a/mcs/class/corlib/Test/System.IO/DirectoryTest.cs b/mcs/class/corlib/Test/System.IO/DirectoryTest.cs
index c2d3ce6e4b9..e0082718491 100644
--- a/mcs/class/corlib/Test/System.IO/DirectoryTest.cs
+++ b/mcs/class/corlib/Test/System.IO/DirectoryTest.cs
@@ -101,6 +101,43 @@ public class DirectoryTest : Assertion {
}
[Test]
+ public void CreateDirectoryAlreadyExists ()
+ {
+ string path = TempFolder + DSC + "DirectoryTest.Test.Exists";
+ DeleteDirectory (path);
+ try {
+ DirectoryInfo info1 = Directory.CreateDirectory (path);
+ DirectoryInfo info2 = Directory.CreateDirectory (path);
+
+ AssertEquals ("test#01", true, info2.Exists);
+ AssertEquals ("test#02", true, info2.FullName.EndsWith ("DirectoryTest.Test.Exists"));
+ AssertEquals ("test#03", "DirectoryTest.Test.Exists", info2.Name);
+ } finally {
+ DeleteDirectory (path);
+ }
+ }
+
+ [Test]
+ public void CreateDirectoryAlreadyExistsAsFile ()
+ {
+ string path = TempFolder + DSC + "DirectoryTest.Test.ExistsAsFile";
+ DeleteDirectory (path);
+ DeleteFile (path);
+ try {
+ FileStream fstream = File.Create (path);
+ fstream.Close();
+
+ DirectoryInfo dinfo = Directory.CreateDirectory (path);
+ AssertEquals ("test#01", false, dinfo.Exists);
+ AssertEquals ("test#02", true, dinfo.FullName.EndsWith ("DirectoryTest.Test.ExistsAsFile"));
+ AssertEquals ("test#03", "DirectoryTest.Test.ExistsAsFile", dinfo.Name);
+ } finally {
+ DeleteDirectory (path);
+ DeleteFile (path);
+ }
+ }
+
+ [Test]
public void Delete ()
{
string path = TempFolder + DSC + "DirectoryTest.Test.Delete.1";
@@ -1192,5 +1229,11 @@ public class DirectoryTest : Assertion {
if (Directory.Exists (path))
Directory.Delete (path, true);
}
+
+ private void DeleteFile (string path)
+ {
+ if (File.Exists (path))
+ File.Delete (path);
+ }
}
}