* UnixDirectoryInfo.cs, UnixDriveInfo.cs, UnixEnvironment.cs,
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixDirectoryInfo.cs
index 2b6e066e6d8706e371f843ed4dff665fb865b3d5..2def70312257ddffe3d535250c2b4e407c593bd1 100644 (file)
@@ -119,6 +119,7 @@ namespace Mono.Unix {
                        base.Refresh ();
                }
 
+               [Obsolete ("The return type will change to Mono.Unix.Native.Dirent[] in the next release")]
                public Dirent[] GetEntries ()
                {
                        IntPtr dirp = Syscall.opendir (FullPath);
@@ -159,6 +160,7 @@ namespace Mono.Unix {
                        return (Dirent[]) entries.ToArray (typeof(Dirent));
                }
 
+               [Obsolete ("The return type will change to Mono.Unix.Native.Dirent[] in the next release")]
                public Dirent[] GetEntries (Regex regex)
                {
                        IntPtr dirp = Syscall.opendir (FullPath);
@@ -195,6 +197,7 @@ namespace Mono.Unix {
                        return (Dirent[]) entries.ToArray (typeof(Dirent));
                }
 
+               [Obsolete ("The return type will change to Mono.Unix.Native.Dirent[] in the next release")]
                public Dirent[] GetEntries (string regex)
                {
                        Regex re = new Regex (regex);
@@ -226,6 +229,25 @@ namespace Mono.Unix {
                        Regex re = new Regex (regex);
                        return GetFileSystemEntries (re);
                }
+
+               public static string GetCurrentDirectory ()
+               {
+                       StringBuilder buf = new StringBuilder (16);
+                       IntPtr r = IntPtr.Zero;
+                       do {
+                               buf.Capacity *= 2;
+                               r = Syscall.getcwd (buf, (ulong) buf.Capacity);
+                       } while (r == IntPtr.Zero && Syscall.GetLastError() == Error.ERANGE);
+                       if (r == IntPtr.Zero)
+                               UnixMarshal.ThrowExceptionForLastError ();
+                       return buf.ToString ();
+               }
+
+               public static void SetCurrentDirectory (string path)
+               {
+                       int r = Syscall.chdir (path);
+                       UnixMarshal.ThrowExceptionForLastErrorIf (r);
+               }
        }
 }