diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog index c59dfbdf32894..0a7f119dc24e7 100644 --- a/mcs/class/corlib/System.IO/ChangeLog +++ b/mcs/class/corlib/System.IO/ChangeLog @@ -1,3 +1,8 @@ +2003-03-07 Gonzalo Paniagua Javier + + * Directory.cs: readded mkdir -p behavior. Thanks to kiwnix for + pointing it out. + 2003-03-05 Gonzalo Paniagua Javier * MemoryStream.cs: general fixes and reformatted. Passes all tests in diff --git a/mcs/class/corlib/System.IO/Directory.cs b/mcs/class/corlib/System.IO/Directory.cs index d4d70cfb9e5d5..1386d53f56bcc 100644 --- a/mcs/class/corlib/System.IO/Directory.cs +++ b/mcs/class/corlib/System.IO/Directory.cs @@ -42,13 +42,22 @@ public static DirectoryInfo CreateDirectory (string path) if (path == ":") throw new NotSupportedException ("Only ':' In path"); + return CreateDirectoriesInternal (path); + } + + static DirectoryInfo CreateDirectoriesInternal (string path) + { + DirectoryInfo info = new DirectoryInfo (path); + if (info.Parent != null && !info.Parent.Exists) + info.Parent.Create (); + MonoIOError error; if (!MonoIO.CreateDirectory (path, out error)) { if (error != MonoIOError.ERROR_ALREADY_EXISTS) throw MonoIO.GetException (error); } - return new DirectoryInfo (path); + return info; } public static void Delete (string path)